2021-07-16 15:05:05 +00:00
|
|
|
|
" nvim-lspconfig
|
2021-04-02 20:43:11 +00:00
|
|
|
|
sign define LspDiagnosticsSignError text=✗ texthl=LspDiagnosticsSignError linehl= numhl=
|
|
|
|
|
sign define LspDiagnosticsSignWarning text=⚠ texthl=LspDiagnosticsSignWarning linehl= numhl=
|
|
|
|
|
sign define LspDiagnosticsSignInformation text=ℹ texthl=LspDiagnosticsSignInformation linehl= numhl=
|
|
|
|
|
sign define LspDiagnosticsSignHint text= texthl=LspDiagnosticsSignHint linehl= numhl=
|
|
|
|
|
|
2021-04-02 22:44:58 +00:00
|
|
|
|
set completeopt=menuone,noinsert,noselect
|
|
|
|
|
|
2021-07-10 16:45:41 +00:00
|
|
|
|
lua << EOF
|
|
|
|
|
lsp_mappings = function()
|
|
|
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
|
|
|
|
|
|
-- Mappings.
|
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<c-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
|
|
|
|
|
|
|
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
|
|
|
|
|
|
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', 'g0', '<cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', 'gW', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
|
|
|
|
|
|
|
|
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
|
|
|
|
end
|
|
|
|
|
EOF
|
2021-04-02 22:44:58 +00:00
|
|
|
|
|
2021-03-21 22:08:47 +00:00
|
|
|
|
lua << EOF
|
|
|
|
|
local nvim_lsp = require('lspconfig')
|
2021-11-01 20:34:37 +00:00
|
|
|
|
-- lspkind-nvim
|
2021-11-02 13:20:01 +00:00
|
|
|
|
cmp_format = require('lspkind').cmp_format{
|
|
|
|
|
with_text = false,
|
|
|
|
|
preset = 'codicons',
|
|
|
|
|
menu = {nvim_lsp = "[LSP]", buffer = "[Buffer]", path = "[Path]"}
|
|
|
|
|
}
|
2021-03-28 00:17:24 +00:00
|
|
|
|
|
|
|
|
|
local on_attach = function(client, bufnr)
|
2021-07-20 21:40:13 +00:00
|
|
|
|
vim.api.nvim_command('autocmd CursorHoldI <buffer> lua vim.lsp.diagnostic.show_line_diagnostics({show_header = false})')
|
2021-07-10 16:45:41 +00:00
|
|
|
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
2021-11-02 13:20:01 +00:00
|
|
|
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
|
|
|
update_in_insert = true,
|
|
|
|
|
virtual_text = false
|
|
|
|
|
}
|
2021-07-10 16:45:41 +00:00
|
|
|
|
)
|
2021-11-02 13:20:01 +00:00
|
|
|
|
require('cmp').setup{
|
2021-11-01 20:34:37 +00:00
|
|
|
|
formatting = {format = cmp_format},
|
2021-11-02 13:20:01 +00:00
|
|
|
|
sources = {
|
|
|
|
|
{name = 'nvim_lsp'},
|
|
|
|
|
{name = 'buffer', keyword_length = 5},
|
|
|
|
|
{name = 'path'}
|
|
|
|
|
},
|
|
|
|
|
}
|
2021-07-10 16:45:41 +00:00
|
|
|
|
lsp_mappings()
|
2021-03-28 00:17:24 +00:00
|
|
|
|
end
|
|
|
|
|
|
2021-07-09 22:30:23 +00:00
|
|
|
|
local settings = require('lsp_settings')
|
2021-07-05 13:23:26 +00:00
|
|
|
|
local servers = {'pylsp', 'clangd'}
|
2021-11-01 20:05:24 +00:00
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
2021-03-21 22:08:47 +00:00
|
|
|
|
for _, lsp in ipairs(servers) do
|
2021-11-01 20:05:24 +00:00
|
|
|
|
nvim_lsp[lsp].setup{on_attach=on_attach, settings={[lsp]=settings[lsp]},
|
|
|
|
|
capabilities=capabilities}
|
2021-03-21 22:08:47 +00:00
|
|
|
|
end
|
|
|
|
|
EOF
|
2020-01-22 20:35:16 +00:00
|
|
|
|
|
2021-11-01 20:21:53 +00:00
|
|
|
|
" cmp
|
2021-11-01 20:05:24 +00:00
|
|
|
|
" Setup buffer configuration (nvim-lua source only enables in Lua filetype).
|
|
|
|
|
autocmd FileType gitcommit lua require'cmp'.setup.buffer {
|
|
|
|
|
\ sources = {
|
|
|
|
|
\ { name = 'spell' },
|
2021-11-02 13:20:01 +00:00
|
|
|
|
\ { name = 'buffer', keyword_length = 5 },
|
2021-11-01 20:05:24 +00:00
|
|
|
|
\ { name = 'path' },
|
|
|
|
|
\ },
|
|
|
|
|
\ }
|