nvim/lua/plugins/mason-lspconfig.lua

100 lines
2.9 KiB
Lua

return {
'williamboman/mason-lspconfig.nvim',
config = function()
local cmp_nvim_lsp = require 'cmp_nvim_lsp'
local capabilities = cmp_nvim_lsp.default_capabilities()
local lspconfig = require 'lspconfig'
local function on_attach(client, bufnr)
--[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]]
if client.name == 'jdtls' or client.name == 'jdt.ls' then
client.server_capabilities.documentFormattingProvider = false
vim.lsp.codelens.refresh()
if JAVA_DAP_ACTIVE then
require('jdtls').setup_dap { hotcodereplace = 'auto' }
require('jdtls.setup').add_commands()
require('jdtls.dap').setup_dap_main_class_configs()
end
end
-- -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format")
client.server_capabilities.documentFormattingProvider = true
-- client.server_capabilities.documentFormattingProvider = true
client.server_capabilities.semanticTokensProvider = nil
end
require('mason-lspconfig').setup_handlers {
function(server_name) -- default handler (optional)
lspconfig[server_name].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end,
['clangd'] = function()
local clangd_flags = {
'-j=5',
'--all-scopes-completion',
'--suggest-missing-includes',
'--background-index',
'--pch-storage=disk',
'--cross-file-rename',
'--log=info',
'--completion-style=detailed',
'--enable-config', -- clangd 11+ supports reading from .clangd configuration file
'--clang-tidy',
-- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type",
-- "--fallback-style=Google",
-- "--header-insertion=never",
-- "--query-driver=<list-of-white-listed-complers>"
}
lspconfig.clangd.setup {
on_attach = on_attach,
capabilities = capabilities,
arg = {
unpack(clangd_flags)
}
}
end,
['lua_ls'] = function()
lspconfig.lua_ls.setup {
on_attach = on_attach,
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
},
settings = {
Lua = {
diagnostics = {
globals = { 'vim' },
},
-- workspace = {
-- library = {
-- [vim.fn.expand '$VIMRUNTIME/lua'] = true,
-- [vim.fn.stdpath 'config' .. '/lua'] = true,
-- },
-- },
telemetry = {
enable = false,
},
},
},
}
end,
['jdtls'] = function()
end,
['rust_analyzer'] = function()
require('rust-tools').setup {
server = {
on_attach = on_attach,
standalone = false,
},
}
end,
}
end
}
-- if server == 'elixirls' then
-- local elixir_opts = {
-- cmd = { "/home/user/.local/share/nvim/mason/packages/elixir-ls/language_server.sh" },
-- }
-- opts = vim.tbl_deep_extend('force', elixir_opts, opts)
-- end