59 lines
2.0 KiB
Lua
59 lines
2.0 KiB
Lua
require'lspinstall'.setup()
|
|
local u = require('utils')
|
|
local nvim_lsp = require'lspconfig'
|
|
|
|
local on_attach = function(client, bufnr)
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
buf_set_keymap('n', '<c-]>', ':lua vim.lsp.buf.definition()<CR>', opts)
|
|
buf_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()<CR>', opts)
|
|
buf_set_keymap('n', 'gD', ':lua vim.lsp.buf.implementation()<CR>', opts)
|
|
buf_set_keymap('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
buf_set_keymap('n', '1gD', ':lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
buf_set_keymap('n', 'gr', ':lua vim.lsp.buf.references()<CR>', opts)
|
|
buf_set_keymap('n', 'g0', ':lua vim.lsp.buf.document_symbol()<CR>', opts)
|
|
buf_set_keymap('n', 'gW', ':lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
|
buf_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()<CR>', opts)
|
|
buf_set_keymap('n', 'ga', ':lua vim.lsp.buf.code_action()<CR>', opts)
|
|
buf_set_keymap('n', 'ff', ':lua vim.lsp.buf.formatting()<CR>', opts)
|
|
|
|
require'completion'.on_attach(client)
|
|
|
|
-- Set highlight colors
|
|
local highlights = {
|
|
Error = "Red",
|
|
Warning = "Yellow",
|
|
Information = "Blue",
|
|
Hint = "Green",
|
|
}
|
|
|
|
for typ, color in pairs(highlights) do
|
|
u.hi('LspDiagnosticsDefault'..typ, {ctermfg = color})
|
|
u.hi('LspDiagnosticsUnderline'..typ, {cterm = 'underline'})
|
|
end
|
|
|
|
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(
|
|
vim.lsp.diagnostic.on_publish_diagnostics,
|
|
{
|
|
virtual_text = true,
|
|
signs = true,
|
|
update_in_insert = true,
|
|
underline = true
|
|
}
|
|
)
|
|
end
|
|
|
|
local servers = require'lspinstall'.installed_servers()
|
|
for _, lsp in ipairs(servers) do
|
|
nvim_lsp[lsp].setup{
|
|
on_attach = on_attach,
|
|
flags = {debounce_text_changes = 150}
|
|
}
|
|
end
|
|
|