first
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
vim.g.coq_settings = {
|
||||
auto_start = 'shut-up',
|
||||
}
|
||||
|
||||
local coq = require('coq')
|
||||
|
||||
local lspstatus = require('lsp-status')
|
||||
lspstatus.register_progress()
|
||||
|
||||
local lsp_confs = {
|
||||
sumneko_lua = {
|
||||
settings = {
|
||||
Lua = {
|
||||
-- Settings for working with nvim (copied from https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua)
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = {'vim'},
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
rust_analyzer = {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
checkOnSave = {
|
||||
command = "clippy",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ccls = {},
|
||||
pyright = {},
|
||||
gopls = {},
|
||||
|
||||
}
|
||||
|
||||
local lsp_special_setup = {
|
||||
}
|
||||
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
for server, conf in pairs(lsp_confs) do
|
||||
local source_on_attach = conf.on_attach
|
||||
if source_on_attach == nil then
|
||||
conf.on_attach = on_attach
|
||||
else
|
||||
conf.on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
source_on_attach(client, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
conf.capabilities = vim.tbl_deep_extend(
|
||||
"keep",
|
||||
conf.capabilities or {},
|
||||
lspstatus.capabilities
|
||||
)
|
||||
|
||||
local final_config = coq.lsp_ensure_capabilities(conf)
|
||||
|
||||
local special_setup = lsp_special_setup[server]
|
||||
if special_setup then
|
||||
special_setup(final_config)
|
||||
else
|
||||
lspconfig[server].setup(final_config)
|
||||
end
|
||||
end
|
||||
|
||||
local null_ls = require('null-ls')
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.diagnostics.chktex,
|
||||
null_ls.builtins.diagnostics.cppcheck,
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
},
|
||||
})
|
||||
|
||||
vim.diagnostic.config({
|
||||
severity_sort = true,
|
||||
update_in_insert = true,
|
||||
float = {
|
||||
source = true,
|
||||
},
|
||||
})
|
||||
|
||||
do -- signs
|
||||
local signs = {
|
||||
{'DiagnosticSignError', text='×', texthl='DiagnosticSignError'},
|
||||
{'DiagnosticSignWarn', text='>', texthl='DiagnosticSignWarn'},
|
||||
{'DiagnosticSignInfo', text='I', texthl='DiagnosticSignInfo'},
|
||||
{'DiagnosticSignHint', text='H', texthl='DiagnosticSignHint'},
|
||||
}
|
||||
for _, sign in pairs(signs) do
|
||||
local name = sign[1]
|
||||
local opts = sign
|
||||
opts[1] = nil
|
||||
vim.fn.sign_define(name, opts)
|
||||
end
|
||||
end
|
||||
|
||||
local map = vim.api.nvim_set_keymap
|
||||
map(
|
||||
'n',
|
||||
'K',
|
||||
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? 'K' : '<Cmd>lua vim.lsp.buf.hover()<CR>']],
|
||||
{noremap = true, expr = true}
|
||||
)
|
||||
map(
|
||||
'n',
|
||||
'<C-]>',
|
||||
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? '<C-]>' : '<Cmd>lua vim.lsp.buf.definition()<CR>']],
|
||||
{noremap = true, expr = true}
|
||||
)
|
||||
|
||||
vim.cmd [[
|
||||
augroup lspconfig
|
||||
au!
|
||||
" diagnostic on hover
|
||||
au CursorHold * lua vim.diagnostic.open_float({focus = false})
|
||||
augroup END
|
||||
]]
|
||||
|
||||
Reference in New Issue
Block a user