mirror of https://github.com/LazyVim/starter
81 lines
2.2 KiB
Lua
81 lines
2.2 KiB
Lua
return {
|
|
{
|
|
"williamboman/mason.nvim",
|
|
config = function()
|
|
require("mason").setup({
|
|
ui = {
|
|
border = "rounded",
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
|
|
{
|
|
"williamboman/mason-lspconfig.nvim",
|
|
dependencies = { "williamboman/mason.nvim" },
|
|
config = function()
|
|
require("mason-lspconfig").setup({
|
|
ensure_installed = {
|
|
"lua_ls", -- Lua
|
|
"pyright", -- Python
|
|
"tsserver", -- TypeScript/JavaScript
|
|
"clangd", -- C/C++
|
|
"rust_analyzer", -- Rust
|
|
"gopls", -- Go
|
|
},
|
|
automatic_installation = true,
|
|
})
|
|
end,
|
|
},
|
|
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
dependencies = { "williamboman/mason-lspconfig.nvim" },
|
|
config = function()
|
|
local lspconfig = require("lspconfig")
|
|
|
|
-- Language Server Configurations
|
|
local servers = {
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" }, -- Avoid undefined 'vim' warnings
|
|
},
|
|
workspace = {
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
checkThirdParty = false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
pyright = {},
|
|
tsserver = {},
|
|
clangd = {},
|
|
rust_analyzer = {},
|
|
gopls = {},
|
|
}
|
|
|
|
for server, config in pairs(servers) do
|
|
lspconfig[server].setup(config)
|
|
end
|
|
|
|
-- LSP Keybindings
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
callback = function(event)
|
|
local opts = { buffer = event.buf, noremap = true, silent = true }
|
|
|
|
-- Keymaps
|
|
vim.keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
vim.keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
vim.keymap.set("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
vim.keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
vim.keymap.set("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
|
vim.keymap.set("n", "<leader>f", "<cmd>lua vim.lsp.buf.format({ async = true })<CR>", opts)
|
|
end,
|
|
})
|
|
end,
|
|
},
|
|
}
|
|
|