Agragados mappings para los LSP
This commit is contained in:
parent
cb0f10f7c5
commit
b9ef74b412
1 changed files with 42 additions and 4 deletions
46
init.lua
46
init.lua
|
|
@ -66,10 +66,47 @@ ts.setup {ensure_installed = 'maintained', highlight = {enable = true, indent =
|
||||||
|
|
||||||
---- LSP ----
|
---- LSP ----
|
||||||
local lsp = require 'lspconfig'
|
local lsp = require 'lspconfig'
|
||||||
-- Golang --
|
|
||||||
require'lspconfig'.golangci_lint_ls.setup{on_attach=require'completion'.on_attach}
|
-- Use an on_attach function to only map the following keys
|
||||||
-- Rust --
|
-- after the language server attaches to the current buffer
|
||||||
require'lspconfig'.rust_analyzer.setup{on_attach=require'completion'.on_attach}
|
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
|
||||||
|
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- 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', '<Leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>rn', '<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', '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', '[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', '<Leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<F3>', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||||
|
-- map buffer local keybindings when the language server attaches
|
||||||
|
local servers = { 'gopls', 'rust_analyzer' }
|
||||||
|
for _, server in ipairs(servers) do
|
||||||
|
lsp[server].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
---- Plugins ----
|
---- Plugins ----
|
||||||
---- ale
|
---- ale
|
||||||
|
|
@ -78,6 +115,7 @@ g.ale_linters = {
|
||||||
c = {},
|
c = {},
|
||||||
cpp = {},
|
cpp = {},
|
||||||
css = {'stylelint'},
|
css = {'stylelint'},
|
||||||
|
go = {'gobuild', 'golangci-lint'},
|
||||||
html = {'tidy'},
|
html = {'tidy'},
|
||||||
javascript = {'eslint'},
|
javascript = {'eslint'},
|
||||||
python = {'flake8'},
|
python = {'flake8'},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue