nvim: use buffer local and maplocalleader for binds

This commit is contained in:
dogeystamp 2024-04-05 12:26:39 -04:00
parent b1709910dc
commit 7b4c3a3f3a
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 14 additions and 7 deletions

View File

@ -27,6 +27,7 @@ set lazyredraw nocursorline ttyfast
set shortmess+=I
let mapleader = ","
let maplocalleader = " "
" " use system clipboard instead of internal
" set clipboard=unnamedplus

View File

@ -111,21 +111,21 @@ local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
local opts = { noremap = true, silent = true }
local opts = { noremap = true, silent = true, buffer=bufnr }
keymap('gD', vim.lsp.buf.declaration, opts)
keymap('gd', vim.lsp.buf.definition, opts)
keymap('gK', vim.lsp.buf.hover, opts)
keymap('gi', vim.lsp.buf.implementation, opts)
keymap('gs', vim.lsp.buf.signature_help, opts)
keymap('gt', vim.lsp.buf.type_definition, opts)
keymap('<space>rn', vim.lsp.buf.rename, opts)
keymap('<space>ss', vim.lsp.buf.workspace_symbol, opts)
keymap('<localleader>rn', vim.lsp.buf.rename, opts)
keymap('<localleader>ss', vim.lsp.buf.workspace_symbol, opts)
keymap('gr', vim.lsp.buf.references, opts)
keymap('<space>e', vim.lsp.diagnostic.show_line_diagnostics, opts)
keymap('<localleader>e', vim.lsp.diagnostic.show_line_diagnostics, opts)
keymap('[d', vim.lsp.diagnostic.goto_prev, opts)
keymap(']d', vim.lsp.diagnostic.goto_next, opts)
keymap('<space>ca', vim.lsp.buf.code_action, opts)
keymap('<space>f', vim.lsp.buf.format, opts)
keymap('<localleader>ca', vim.lsp.buf.code_action, opts)
keymap('<localleader>f', vim.lsp.buf.format, opts)
end
-- table declares LSPs to be set up

View File

@ -17,6 +17,7 @@ function M.keymap(key, cmd, params)
silent = true,
mode = { 'n' },
noremap = true,
buffer = false,
}
setmetatable(params, {
__index = function(table, k)
@ -24,7 +25,12 @@ function M.keymap(key, cmd, params)
end
})
vim.keymap.set(params.mode, key, cmd, { silent = params.silent, noremap = params.noremap, expr = params.expr })
vim.keymap.set(params.mode, key, cmd, {
silent = params.silent,
noremap = params.noremap,
expr = params.expr,
buffer = params.buffer
})
end
-- see ~/.config/dot_profile.example for info