feat: centralized nvim lspconfig config in a single file
This commit is contained in:
parent
0e1adb69be
commit
9fca7e1a9a
@ -1,8 +0,0 @@
|
|||||||
-- packages
|
|
||||||
require'lspconfig'.dockerls.setup {
|
|
||||||
on_attach = require'lspbinds',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- variables
|
|
||||||
|
|
||||||
-- keybindings
|
|
@ -1,7 +1,4 @@
|
|||||||
-- packages
|
-- packages
|
||||||
require'lspconfig'.pyright.setup {
|
|
||||||
on_attach = require'lspbinds',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- variables
|
-- variables
|
||||||
vim.cmd("let g:black_linelength=79")
|
vim.cmd("let g:black_linelength=79")
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
-- packages
|
|
||||||
require'lspconfig'.bashls.setup{
|
|
||||||
on_attach = require'lspbinds',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- variables
|
|
||||||
|
|
||||||
-- keybindings
|
|
@ -1,7 +1,4 @@
|
|||||||
-- packages
|
-- packages
|
||||||
require'lspconfig'.yamlls.setup {
|
|
||||||
on_attach = require'lspbinds',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- variables
|
-- variables
|
||||||
vim.o.shiftwidth = 2
|
vim.o.shiftwidth = 2
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- packages
|
-- packages
|
||||||
vim.cmd("packadd nvim-treesitter")
|
vim.cmd("packadd nvim-treesitter")
|
||||||
require'nvim-treesitter.configs'.setup {
|
require"nvim-treesitter.configs".setup {
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {enable = true},
|
highlight = {enable = true},
|
||||||
}
|
}
|
||||||
@ -8,12 +8,13 @@ require'nvim-treesitter.configs'.setup {
|
|||||||
vim.cmd("packadd black")
|
vim.cmd("packadd black")
|
||||||
|
|
||||||
vim.cmd("packadd indent-blankline")
|
vim.cmd("packadd indent-blankline")
|
||||||
require'indent_blankline'.setup {
|
require"indent_blankline".setup {
|
||||||
show_current_context = true,
|
show_current_context = true,
|
||||||
show_current_context_start = true,
|
show_current_context_start = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.cmd("packadd nvim-lspconfig")
|
vim.cmd("packadd nvim-lspconfig")
|
||||||
|
require"pack_lspconfig"
|
||||||
|
|
||||||
vim.cmd("packadd vim-dirdiff")
|
vim.cmd("packadd vim-dirdiff")
|
||||||
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
-- Mappings.
|
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
||||||
local opts = { noremap=true, silent=true }
|
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
|
||||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|
||||||
|
|
||||||
return function(client, bufnr)
|
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
||||||
|
|
||||||
-- Mappings.
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
||||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
||||||
end
|
|
41
.config/nvim/lua/pack_lspconfig.lua
Normal file
41
.config/nvim/lua/pack_lspconfig.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
lspconfig = require"lspconfig"
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
local servers = {
|
||||||
|
"bashls",
|
||||||
|
"dockerls",
|
||||||
|
"pyright",
|
||||||
|
"yamlls",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, server in ipairs(servers) do
|
||||||
|
lspconfig[server].setup{on_attach = function(client, bufnr)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
|
end}
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user