You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1016 B
Lua

local vim = vim
local noremap = function(type, rhs, lhs, bufopts, desc)
bufopts.desc = desc
vim.keymap.set(type, rhs, lhs, bufopts)
end
local nnoremap = function(rhs, lhs, bufopts, desc)
noremap("n", rhs, lhs, bufopts, desc)
end
local vnoremap = function(rhs, lhs, bufopts, desc)
noremap("v", rhs, lhs, bufopts, desc)
end
local bufopts = { noremap = true, silent = true }
nnoremap("<Leader>gD", vim.lsp.buf.declaration, bufopts, "Go to declaration")
nnoremap("<Leader>gd", vim.lsp.buf.definition, bufopts, "Go to definition")
nnoremap("<Leader>gi", vim.lsp.buf.implementation, bufopts, "Go to implementation")
nnoremap("<Leader>td", vim.lsp.buf.type_definition, bufopts, "Go to type definition")
nnoremap("<Leader>gr", vim.lsp.buf.references, bufopts, "Go to references")
nnoremap("<Leader>rn", vim.lsp.buf.rename, bufopts, "Rename")
nnoremap("<Leader>ca", vim.lsp.buf.code_action, bufopts, "Code actions")
vnoremap("<Leader>ca", "<ESC><CMD>lua vim.lsp.buf.range_code_action()<CR>", bufopts, "Code Actions")