From 7b4c3a3f3a56e3b179742ffbb683dbaabbc89410 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Fri, 5 Apr 2024 12:26:39 -0400 Subject: [PATCH] nvim: use buffer local and maplocalleader for binds --- src/.config/nvim/init.vim | 1 + src/.config/nvim/lua/coding.lua | 12 ++++++------ src/.config/nvim/lua/confutil.lua | 8 +++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/.config/nvim/init.vim b/src/.config/nvim/init.vim index c9d2f2f..02ace65 100755 --- a/src/.config/nvim/init.vim +++ b/src/.config/nvim/init.vim @@ -27,6 +27,7 @@ set lazyredraw nocursorline ttyfast set shortmess+=I let mapleader = "," +let maplocalleader = " " " " use system clipboard instead of internal " set clipboard=unnamedplus diff --git a/src/.config/nvim/lua/coding.lua b/src/.config/nvim/lua/coding.lua index 4ba4986..ff09166 100644 --- a/src/.config/nvim/lua/coding.lua +++ b/src/.config/nvim/lua/coding.lua @@ -111,21 +111,21 @@ local on_attach = function(client, bufnr) -- Enable completion triggered by 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('rn', vim.lsp.buf.rename, opts) - keymap('ss', vim.lsp.buf.workspace_symbol, opts) + keymap('rn', vim.lsp.buf.rename, opts) + keymap('ss', vim.lsp.buf.workspace_symbol, opts) keymap('gr', vim.lsp.buf.references, opts) - keymap('e', vim.lsp.diagnostic.show_line_diagnostics, opts) + keymap('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('ca', vim.lsp.buf.code_action, opts) - keymap('f', vim.lsp.buf.format, opts) + keymap('ca', vim.lsp.buf.code_action, opts) + keymap('f', vim.lsp.buf.format, opts) end -- table declares LSPs to be set up diff --git a/src/.config/nvim/lua/confutil.lua b/src/.config/nvim/lua/confutil.lua index 6cc9131..de10196 100644 --- a/src/.config/nvim/lua/confutil.lua +++ b/src/.config/nvim/lua/confutil.lua @@ -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