110 lines
2.4 KiB
Lua
110 lines
2.4 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.opt.pumheight = 8
|
|
|
|
local diag_inline_enabled = true
|
|
|
|
local function diag_virtual_text()
|
|
if not diag_inline_enabled then
|
|
return false
|
|
end
|
|
|
|
return {
|
|
severity = vim.diagnostic.severity.ERROR,
|
|
}
|
|
end
|
|
|
|
local function configure_diagnostics()
|
|
vim.diagnostic.config({
|
|
severity_sort = true,
|
|
signs = true,
|
|
underline = true,
|
|
update_in_insert = false,
|
|
virtual_text = diag_virtual_text(),
|
|
float = {
|
|
border = "rounded",
|
|
source = "if_many",
|
|
},
|
|
})
|
|
end
|
|
|
|
configure_diagnostics()
|
|
|
|
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,
|
|
})
|
|
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({
|
|
ensure_installed = managed_servers,
|
|
automatic_enable = managed_servers,
|
|
})
|