summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachIR <zachir@librem.one>2025-06-29 13:45:14 -0500
committerZachIR <zachir@librem.one>2025-06-29 13:45:14 -0500
commit7811be6ae04782a054868529d5c3e8a3f22179e4 (patch)
treea08fcb792ef50b7df10aed56726daa346d5b9508
parentde01a7b92da2962d841dc38fd5f32cf5dfeecc73 (diff)
Add lsp to neovim
-rw-r--r--nvim/init.lua1
-rw-r--r--nvim/lua/lsp.lua22
-rw-r--r--nvim/lua/plugins.lua20
3 files changed, 43 insertions, 0 deletions
diff --git a/nvim/init.lua b/nvim/init.lua
index cf11420..4b295d5 100644
--- a/nvim/init.lua
+++ b/nvim/init.lua
@@ -1,5 +1,6 @@
require('options')
require('keymaps')
+require('lsp')
require('plugins')
require('colorscheme')
require('term')
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", "<space>rn", lsp.buf.rename, bufopts)
+ keymap.set("n", "K", lsp.buf.hover, bufopts)
+ keymap.set("n", "<space>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',