nvimdotfiles/after/plugin/lsp/lsp-common.lua

26 lines
1.4 KiB
Lua
Raw Normal View History

vim.api.nvim_create_autocmd('LspAttach', {
callback = function(ev)
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>gr', builtin.lsp_references);
2023-10-15 16:07:01 +00:00
local opts = { noremap = true, silent = false, buffer = ev.buf }
vim.keymap.set('n', '<leader>ci', vim.lsp.buf.incoming_calls, opts);
vim.keymap.set('n', '<leader>gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.keymap.set('n', '<leader>ga', '<Cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.keymap.set('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.keymap.set('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.keymap.set('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.keymap.set('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.keymap.set('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.keymap.set('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float({scope="buffer"})<CR>', opts)
vim.keymap.set('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
vim.keymap.set('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
vim.keymap.set('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>fo', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})