mirror of
https://github.com/harivansh-afk/nvim.git
synced 2026-04-15 04:03:30 +00:00
57 lines
No EOL
1.7 KiB
Lua
57 lines
No EOL
1.7 KiB
Lua
return {
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
dependencies = {
|
|
"williamboman/mason.nvim",
|
|
"williamboman/mason-lspconfig.nvim",
|
|
},
|
|
config = function()
|
|
require("mason").setup()
|
|
require("mason-lspconfig").setup({
|
|
ensure_installed = { "lua_ls", "pyright", "tsserver" },
|
|
automatic_installation = true,
|
|
})
|
|
|
|
local lspconfig = require("lspconfig")
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
-- Basic LSP keymaps
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
|
callback = function(ev)
|
|
local opts = { buffer = ev.buf }
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
|
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
|
vim.keymap.set("n", "<leader>f", function()
|
|
vim.lsp.buf.format({ async = true })
|
|
end, opts)
|
|
end,
|
|
})
|
|
|
|
-- Setup language servers
|
|
lspconfig.lua_ls.setup({
|
|
capabilities = capabilities,
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.pyright.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
lspconfig.tsserver.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
end,
|
|
},
|
|
} |