23 lines
1.4 KiB
Lua
23 lines
1.4 KiB
Lua
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||
|
callback = function(ev)
|
||
|
local opts = { noremap=true, silent=false, buffer = ev.buf }
|
||
|
|
||
|
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', '<leader>gr', '<cmd>lua vim.lsp.buf.references()<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', function() vim.lsp.buf.definition() end, opts)
|
||
|
vim.keymap.set('n', '<leader>fo', function()
|
||
|
vim.lsp.buf.format { async = true }
|
||
|
end, opts)
|
||
|
end,
|
||
|
})
|