103 lines
2.5 KiB
Lua
103 lines
2.5 KiB
Lua
vim.pack.add({
|
|
{
|
|
src = "https://github.com/mason-org/mason.nvim",
|
|
name = "mason.nvim",
|
|
},
|
|
{
|
|
src = "https://github.com/mason-org/mason-lspconfig.nvim",
|
|
name = "mason-lspconfig.nvim",
|
|
},
|
|
{
|
|
src = "https://github.com/neovim/nvim-lspconfig",
|
|
name = "nvim-lspconfig",
|
|
},
|
|
})
|
|
|
|
local mason_lspconfig = require("mason-lspconfig")
|
|
|
|
vim.opt.completeopt = { "menu", "menuone", "noselect", "popup", "fuzzy" }
|
|
|
|
vim.diagnostic.config({
|
|
severity_sort = true,
|
|
signs = true,
|
|
underline = true,
|
|
update_in_insert = false,
|
|
virtual_text = false,
|
|
float = {
|
|
border = "rounded",
|
|
source = "if_many",
|
|
},
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
callback = function(ev)
|
|
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
|
if not client then
|
|
return
|
|
end
|
|
|
|
vim.lsp.completion.enable(true, client.id, ev.buf, {
|
|
autotrigger = true,
|
|
})
|
|
|
|
if client:supports_method("textDocument/inlayHint") then
|
|
vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf })
|
|
end
|
|
|
|
local opts = { buffer = ev.buf }
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
vim.keymap.set("n", "grd", vim.lsp.buf.references, opts)
|
|
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts)
|
|
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts)
|
|
end,
|
|
})
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
local managed_servers = {
|
|
"bashls",
|
|
"clangd",
|
|
"jsonls",
|
|
"lua_ls",
|
|
"marksman",
|
|
"taplo",
|
|
"ts_ls",
|
|
"yamlls",
|
|
}
|
|
local servers = {
|
|
bashls = {},
|
|
clangd = {},
|
|
jsonls = {},
|
|
marksman = {},
|
|
taplo = {},
|
|
ts_ls = {},
|
|
yamlls = {},
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
runtime = {
|
|
version = "LuaJIT",
|
|
},
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
for server_name, config in pairs(servers) do
|
|
config.capabilities = vim.tbl_deep_extend("force", {}, capabilities, config.capabilities or {})
|
|
vim.lsp.config(server_name, config)
|
|
end
|
|
|
|
require("mason").setup()
|
|
|
|
mason_lspconfig.setup({
|
|
automatic_enable = managed_servers,
|
|
})
|