1
0
Fork 0

nvim: add <LocalLeader>, reorganise lsp mappings

This commit is contained in:
tastytea 2022-08-12 00:05:54 +02:00
parent 2a6c37ea2c
commit 3bb3075151
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 17 additions and 16 deletions

View File

@ -2,7 +2,8 @@ function map(mode, shortcut, command)
vim.keymap.set(mode, shortcut, command, { noremap = true, silent = true })
end
vim.g.mapleader = ' ' -- <Leader>
vim.g.mapleader = ' ' -- <Leader>
vim.g.maplocalleader = ' ' -- <LocalLeader> (2 spaces)
local format = string.format
@ -78,4 +79,4 @@ for _, key in ipairs({ 'Left', 'Up', 'Down', 'Right' }) do
map({ 'v' }, format('<S-%s>', key), format('<%s>', key))
end
map('n', '<F9>', ':Lexplore 10<cr>') -- file explorer
map('n', '<F9>', ':Lexplore 20<cr>') -- file explorer, 20% width

View File

@ -14,25 +14,25 @@ packer.use {
-- only do this after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function maplsp(mode, shortcut, command)
local function map(mode, shortcut, command)
vim.keymap.set(mode, shortcut, command,
{ noremap = true, silent = true, buffer=bufnr })
end
maplsp('n', 'gD', vim.lsp.buf.declaration)
maplsp('n', 'gd', vim.lsp.buf.definition)
maplsp('n', 'K', vim.lsp.buf.hover)
maplsp('n', 'gi', vim.lsp.buf.implementation)
maplsp('n', '<C-k>', vim.lsp.buf.signature_help)
maplsp('n', '<Leader>wa', vim.lsp.buf.add_workspace_folder)
maplsp('n', '<Leader>wr', vim.lsp.buf.remove_workspace_folder)
maplsp('n', '<Leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
map('n', 'gD', vim.lsp.buf.declaration)
map('n', 'gd', vim.lsp.buf.definition)
map('n', 'gi', vim.lsp.buf.implementation)
map('n', 'gr', vim.lsp.buf.references)
map('n', 'K', vim.lsp.buf.hover)
map('n', '<C-k>', vim.lsp.buf.signature_help)
map('n', '<Leader>lwa', vim.lsp.buf.add_workspace_folder)
map('n', '<Leader>lwr', vim.lsp.buf.remove_workspace_folder)
map('n', '<Leader>lwl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end)
maplsp('n', '<Leader>rn', vim.lsp.buf.rename)
maplsp('n', '<Leader>a', vim.lsp.buf.code_action)
maplsp('n', 'gr', vim.lsp.buf.references)
maplsp('n', '<Leader>f', vim.lsp.buf.formatting)
map('n', '<Leader>lrn', vim.lsp.buf.rename)
map('n', '<Leader>la', vim.lsp.buf.code_action)
map('n', '<Leader>f', vim.lsp.buf.formatting)
-- highlight symbol under cursor
if client.resolved_capabilities.document_highlight then