From 7811be6ae04782a054868529d5c3e8a3f22179e4 Mon Sep 17 00:00:00 2001 From: ZachIR Date: Sun, 29 Jun 2025 13:45:14 -0500 Subject: Add lsp to neovim --- nvim/lua/lsp.lua | 22 ++++++++++++++++++++++ nvim/lua/plugins.lua | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 nvim/lua/lsp.lua (limited to 'nvim/lua') diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua new file mode 100644 index 0000000..343c76b --- /dev/null +++ b/nvim/lua/lsp.lua @@ -0,0 +1,22 @@ +-- Remove Global Default Key mapping +vim.keymap.del("n", "grn") +vim.keymap.del("n", "gra") +vim.keymap.del("n", "grr") +vim.keymap.del("n", "gri") +vim.keymap.del("n", "gO") + +-- Create keymapping +-- LspAttach: After an LSP Client performs "initialize" and attaches to a buffer. +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local keymap = vim.keymap + local lsp = vim.lsp + local bufopts = { noremap = true, silent = true } + + keymap.set("n", "gr", lsp.buf.references, bufopts) + keymap.set("n", "gd", lsp.buf.definition, bufopts) + keymap.set("n", "rn", lsp.buf.rename, bufopts) + keymap.set("n", "K", lsp.buf.hover, bufopts) + keymap.set("n", "f", lsp.buf.format, bufopts) + end +}) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 0801939..8056494 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -12,6 +12,26 @@ end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ + -- LSP manager + { "mason-org/mason.nvim", opts = {} }, + { + "mason-org/mason-lspconfig.nvim", + dependencies = { + "mason-org/mason.nvim", + "neovim/nvim-lspconfig", + }, + opts = { + ensure_installed = { "pylsp", "clangd", "rust_analyzer", "zls" }, + }, + }, + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + + lspconfig.pylsp.setup({}) + end, + }, "tanvirtin/monokai.nvim", 'preservim/nerdtree', 'ziglang/zig.vim', -- cgit v1.2.3