diff options
author | tdback <tyler@tdback.net> | 2024-12-04 18:48:24 -0500 |
---|---|---|
committer | tdback <tyler@tdback.net> | 2024-12-04 18:48:24 -0500 |
commit | 3b2163b821f4dbf1003804b9b19fd276dc4bc350 (patch) | |
tree | 809a679142eae8e7d3b4d2b3cf1426416883a7f9 /lua/custom/plugins/lsp.lua |
initial commit to new repo
Diffstat (limited to 'lua/custom/plugins/lsp.lua')
-rw-r--r-- | lua/custom/plugins/lsp.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua new file mode 100644 index 0000000..256b460 --- /dev/null +++ b/lua/custom/plugins/lsp.lua @@ -0,0 +1,35 @@ +return { + "neovim/nvim-lspconfig", + config = function() + local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + + local on_attach = function(client, bufnr) + local opts = { buffer = bufnr, noremap = true, silent = true } + + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true) + end + + vim.diagnostic.config({ virtual_text = true }) + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + end + + local lspc = require("lspconfig") + local servers = { + "clangd", + "gopls", + "hls", + "nixd", + "pylsp", + "rust_analyzer", + "zls", + } + + for _, s in ipairs(servers) do + lspc[s].setup({ on_attach = on_attach, capabilities = capabilities }) + end + end, +} |