Fix up NeoVim config for new .vimrc

This commit is contained in:
Leon Grünewald 2022-03-09 22:51:30 +01:00
parent 4725220ba7
commit 58a35c1730

View file

@ -1,19 +1,58 @@
source ~/.vimrc
lua << EOF
local nvim_lsp = require('lspconfig')
local on_attach = require'completion'.on_attach
local servers = { "html", "clangd", "vimls", "vuels", "phpactor", "rust_analyzer", "tsserver" }
local coq = require('coq')
local null_ls = require('null-ls')
local servers = { "html", "clangd", "vimls", "vuels", "phpactor", "rust_analyzer", "tsserver", "pyright"}
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
-- Mappings.
local opts = { noremap=true, silent=true }
-- 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.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', '<space>ca', '<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', '<space>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_next()<CR>', opts)
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
buf_set_keymap('n', '=', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = require'completion'.on_attach,
nvim_lsp[lsp].setup(coq.lsp_ensure_capabilities({
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
}
}
))
end
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.php,
null_ls.builtins.formatting.clang_format,
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.eslint,
null_ls.builtins.formatting.phpcsfixer,
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.phpcbf,
}
});
EOF