Add global on_attach function to avoid duplicate code
This commit is contained in:
parent
45cce73a02
commit
19f6f06421
6 changed files with 17 additions and 55 deletions
|
@ -4,15 +4,5 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco
|
||||||
|
|
||||||
require'lspconfig'.ansiblels.setup {
|
require'lspconfig'.ansiblels.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = function()
|
on_attach = global_attach,
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<CR>', { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float, { buffer = 0, remap = false })
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,5 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco
|
||||||
|
|
||||||
require'lspconfig'.bashls.setup {
|
require'lspconfig'.bashls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = function()
|
on_attach = global_attach,
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<CR>', { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float, { buffer = 0, remap = false })
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,7 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco
|
||||||
|
|
||||||
require'lspconfig'.texlab.setup {
|
require'lspconfig'.texlab.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = function()
|
on_attach = global_attach,
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<CR>', { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float, { buffer = 0, remap = false })
|
|
||||||
end,
|
|
||||||
settings = {
|
settings = {
|
||||||
texlab = {
|
texlab = {
|
||||||
chktex = {
|
chktex = {
|
||||||
|
|
|
@ -4,17 +4,7 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco
|
||||||
|
|
||||||
require'lspconfig'.sumneko_lua.setup {
|
require'lspconfig'.sumneko_lua.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = function()
|
on_attach = global_attach,
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<CR>', { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float, { buffer = 0, remap = false })
|
|
||||||
end,
|
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
|
|
|
@ -4,15 +4,5 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco
|
||||||
|
|
||||||
require'lspconfig'.marksman.setup {
|
require'lspconfig'.marksman.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = function()
|
on_attach = global_attach,
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<CR>', { buffer = 0, remap = false })
|
|
||||||
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float, { buffer = 0, remap = false })
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
-- LSP Servers
|
-- LSP Servers
|
||||||
|
|
||||||
|
global_attach = function()
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float, { buffer = 0, remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<CR>', { buffer = 0, remap = false })
|
||||||
|
end
|
||||||
|
|
||||||
require('lsp.ansible')
|
require('lsp.ansible')
|
||||||
require('lsp.bash')
|
require('lsp.bash')
|
||||||
require('lsp.latex')
|
require('lsp.latex')
|
||||||
|
|
Loading…
Add table
Reference in a new issue