Update nvim conf

main
Micke Nordin 2 years ago
parent 2bde8b6aed
commit eac1e2910f
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -44,6 +44,14 @@ nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" "
" lsp diagnostics " lsp diagnostics
lua <<EOF lua <<EOF
local notify = vim.notify
vim.notify = function(msg, ...)
if msg:match("warning: multiple different client offset_encodings") then
return
end
notify(msg, ...)
end
require'toggle_lsp_diagnostics'.init({ start_on = true }) require'toggle_lsp_diagnostics'.init({ start_on = true })
EOF EOF
nmap <leader>td <Plug>(toggle-lsp-diag) nmap <leader>td <Plug>(toggle-lsp-diag)
@ -79,6 +87,9 @@ EOF
" Lua config for lsp " Lua config for lsp
lua << EOF lua << EOF
local nvim_lsp = require('lspconfig') local nvim_lsp = require('lspconfig')
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, { focusable = false }
)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
@ -94,16 +105,16 @@ local on_attach = function(client, bufnr)
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) 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', '<leader>d', '<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', '<leader>h', '<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', '<leader>i', '<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', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<leader>r', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) buf_set_keymap('n', '<leader>r', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) buf_set_keymap('n', '<leader>a', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts) buf_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts) buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
@ -183,7 +194,7 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco
-- Use a loop to conveniently call 'setup' on multiple servers and -- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches -- map buffer local keybindings when the language server attaches
local servers = { 'pyright', 'bashls', 'clangd'} local servers = { 'pyright', 'pylsp', 'bashls', 'clangd'}
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup { nvim_lsp[lsp].setup {
capabilities = capabilities, capabilities = capabilities,
@ -196,16 +207,16 @@ end
-- set up formatting -- set up formatting
require "lspconfig".efm.setup { -- require "lspconfig".efm.setup {
init_options = {documentFormatting = true}, -- init_options = {documentFormatting = true},
settings = { -- settings = {
rootMarkers = {".git/"}, -- rootMarkers = {".git/"},
languages = { -- languages = {
python = { -- python = {
{formatCommand = "yapf --quiet", formatStdin = true}, -- {formatCommand = "yapf --quiet", formatStdin = true},
{formatCommand = "isort -d -", formatStdin = true} -- {formatCommand = "isort -d -", formatStdin = true}
} -- }
} -- }
} -- }
} -- }
EOF EOF

Loading…
Cancel
Save