some tuning of lsp config
This commit is contained in:
parent
520858f6ac
commit
b9c4ea5413
@ -16,9 +16,32 @@ return {
|
||||
require('mason-lspconfig').setup({
|
||||
automatic_installation = false,
|
||||
})
|
||||
local lspconfig = require 'lspconfig'
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceText",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = "#5a524c" }
|
||||
)
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceRead",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = 'DarkGreen' }
|
||||
)
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceWrite",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = 'DarkRed' }
|
||||
)
|
||||
|
||||
OpenDiagFloat = function()
|
||||
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if vim.api.nvim_win_get_config(winid).zindex then
|
||||
@ -73,39 +96,21 @@ return {
|
||||
|
||||
-- Set some keybinds conditional on server capabilities
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.format,
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end,
|
||||
{ noremap = true, silent = false, desc = 'Format file', buffer = bufnr })
|
||||
end
|
||||
if client.server_capabilities.documentRangeFormattingProvider then
|
||||
vim.keymap.set('x', '<space>f', vim.lsp.buf.format,
|
||||
vim.keymap.set('x', '<space>f', function()
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end,
|
||||
{ noremap = true, silent = false, desc = 'Format visual', buffer = bufnr })
|
||||
end
|
||||
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceText",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = "#5a524c" }
|
||||
)
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceRead",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = 'DarkGreen' }
|
||||
)
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceWrite",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = 'DarkRed' }
|
||||
)
|
||||
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
buffer = bufnr,
|
||||
@ -129,17 +134,17 @@ return {
|
||||
}, bufnr)
|
||||
end
|
||||
|
||||
require('lspconfig')['pyright'].setup {
|
||||
lspconfig['pyright'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
require('lspconfig')['groovyls'].setup {
|
||||
lspconfig['groovyls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
require('lspconfig')['cmake'].setup {
|
||||
lspconfig['cmake'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
@ -152,7 +157,7 @@ return {
|
||||
capabilities = clangd_capabilities,
|
||||
on_attach = on_attach,
|
||||
cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
||||
root_dir = require('lspconfig').util.root_pattern(
|
||||
root_dir = lspconfig.util.root_pattern(
|
||||
'.clangd',
|
||||
'.clang-tidy',
|
||||
'.clang-format',
|
||||
@ -180,7 +185,7 @@ return {
|
||||
-- },
|
||||
-- })
|
||||
|
||||
require('lspconfig')['jsonls'].setup {
|
||||
lspconfig['jsonls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
@ -188,7 +193,7 @@ return {
|
||||
local lua_rtp = vim.split(package.path, ';')
|
||||
table.insert(lua_rtp, 'lua/?.lua')
|
||||
table.insert(lua_rtp, 'lua/?/init.lua')
|
||||
require('lspconfig').sumneko_lua.setup {
|
||||
lspconfig.sumneko_lua.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
@ -216,12 +221,12 @@ return {
|
||||
}
|
||||
}
|
||||
|
||||
require('lspconfig')['dockerls'].setup {
|
||||
lspconfig['dockerls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
require('lspconfig')['yamlls'].setup {
|
||||
lspconfig['yamlls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
@ -235,6 +240,7 @@ return {
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
-- null_ls.builtins.formatting.black,
|
||||
null_ls.builtins.formatting.autopep8,
|
||||
null_ls.builtins.formatting.prettier,
|
||||
null_ls.builtins.formatting.xmlformat,
|
||||
@ -242,6 +248,7 @@ return {
|
||||
null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.cmake_format,
|
||||
},
|
||||
debug = true,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user