.dotfiles/.config/nvim/lua/nvwynd/plugins/lsp.lua

137 lines
3.0 KiB
Lua

return {
{
"neovim/nvim-lspconfig",
dependencies = {
{ "j-hui/fidget.nvim", opts = {} },
},
config = function()
local lsp_zero = require("lsp-zero")
lsp_zero.extend_lspconfig()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Python
lspconfig.pyright.setup({
capabilities = capabilities,
})
-- Rust
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
hover = {
actions = {
references = { enable = true },
},
},
inlayHints = {
closureReturnTypeHints = { enable = "always" },
lifetimeElisionHints = { enable = "always" },
reborrowHints = { enable = "always" },
},
},
},
})
-- HTMX
-- lspconfig.htmx.setup({
-- capabilities = capabilities,
-- filetypes = { "html", "templ", "htmldjango" },
-- })
-- Lua
local lua_rtp = vim.split(package.path, ";")
table.insert(lua_rtp, "lua/?.lua")
table.insert(lua_rtp, "lua/?/init.lua")
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = lua_rtp,
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
diagnostics = {
globals = { "vim" },
},
telemetry = {
enable = false,
},
},
},
})
-- Zig
lspconfig.zls.setup({
capabilities = capabilities,
})
-- Bash
lspconfig.bashls.setup({
capabilities = capabilities,
})
-- HTML
lspconfig.html.setup({
capabilities = capabilities,
filetypes = { "html", "templ", "htmldjango" },
})
-- CSS
lspconfig.cssls.setup({
capabilities = capabilities,
})
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("nvwynd-lsp-attach", { clear = true }),
callback = function(event)
-- does word highlighting (across the entire file) whenever the cursor is on one
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end,
})
end,
},
{
"VonHeikemen/lsp-zero.nvim",
opts = {},
lazy = true,
dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/nvim-cmp", "L3MON4D3/LuaSnip" },
config = function()
local lsp_zero = require("lsp-zero")
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({
buffer = bufnr,
preserve_mappings = false,
})
end)
end,
},
{
"folke/neodev.nvim",
opts = {},
},
}