summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/justsaumit/lsp-config.lua
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-07-15 13:45:03 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-07-15 13:45:03 +0530
commit32077b19df1d8895e051de1c4e323aeff6b084c9 (patch)
tree0d4910945a5399cbdafb96e060d49c3d2a09b7df /.config/nvim/lua/justsaumit/lsp-config.lua
parent52264cfdf74e4b3d84b860d53250c866ac72f0a1 (diff)
nvim: Adding mason-nvim package manager and mason-lsp
Diffstat (limited to '.config/nvim/lua/justsaumit/lsp-config.lua')
-rw-r--r--.config/nvim/lua/justsaumit/lsp-config.lua83
1 files changed, 83 insertions, 0 deletions
diff --git a/.config/nvim/lua/justsaumit/lsp-config.lua b/.config/nvim/lua/justsaumit/lsp-config.lua
new file mode 100644
index 0000000..f4db75f
--- /dev/null
+++ b/.config/nvim/lua/justsaumit/lsp-config.lua
@@ -0,0 +1,83 @@
+local on_attach = function(client, bufnr)
+ local function buf_set_keymap(...)
+ vim.api.nvim_buf_set_keymap(bufnr, ...)
+ end
+ local function buf_set_option(...)
+ vim.api.nvim_buf_set_option(bufnr, ...)
+ end
+
+ buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
+
+ local opts = { noremap = true, silent = true }
+
+ buf_set_keymap("n", "gd", ":lua vim.lsp.buf.definition()<CR>", opts) --> jumps to the definition of the symbol under the cursor
+ buf_set_keymap("n", "<leader>lh", ":lua vim.lsp.buf.hover()<CR>", opts) --> information about the symbol under the cursos in a floating window
+ buf_set_keymap("n", "gi", ":lua vim.lsp.buf.implementation()<CR>", opts) --> lists all the implementations for the symbol under the cursor in the quickfix window
+ buf_set_keymap("n", "<leader>rn", ":lua vim.lsp.util.rename()<CR>", opts) --> renaname old_fname to new_fname
+ buf_set_keymap("n", "<leader>ca", ":lua vim.lsp.buf.code_action()<CR>", opts) --> selects a code action available at the current cursor position
+ buf_set_keymap("n", "gr", ":lua vim.lsp.buf.references()<CR>", opts) --> lists all the references to the symbl under the cursor in the quickfix window
+ buf_set_keymap("n", "<leader>ld", ":lua vim.diagnostic.open_float()<CR>", opts)
+ buf_set_keymap("n", "[d", ":lua vim.diagnostic.goto_prev()<CR>", opts)
+ buf_set_keymap("n", "]d", ":lua vim.diagnostic.goto_next()<CR>", opts)
+ buf_set_keymap("n", "<leader>lq", ":lua vim.diagnostic.setloclist()<CR>", opts)
+ buf_set_keymap("n", "<leader>lf", ":lua vim.lsp.buf.formatting()<CR>", opts) --> formats the current buffer
+end
+
+---@diagnostic disable-next-line: undefined-global
+local capabilities = vim.lsp.protocol.make_client_capabilities()
+capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
+
+require("lspconfig")["clangd"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["pyright"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["bashls"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["cssls"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["gopls"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["html"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["lua_ls"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["marksman"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["rust_analyzer"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["tsserver"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})
+
+require("lspconfig")["yamlls"].setup({
+ on_attach = on_attach,
+ capabilities = capabilities,
+})