From 51ad9f4bdfc829ce84172750061ca42bf016f9af Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Wed, 3 Apr 2024 12:53:42 -0500 Subject: [PATCH] chg: Only do LSP related keybinds on LspAttach --- laptop/config/keymaps.lua | 5 ----- laptop/plugin/lsp_config.lua | 10 ++++++++++ server/plugin/lsp_config.lua | 9 +++++++++ vps/plugin/lsp_config.lua | 9 +++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/laptop/config/keymaps.lua b/laptop/config/keymaps.lua index f656603..d363b1a 100644 --- a/laptop/config/keymaps.lua +++ b/laptop/config/keymaps.lua @@ -8,11 +8,6 @@ local opt = vim.opt g.mapleader = ',' g.maplocalleader = ';' --- Set K to hover and ,a to show code actions -api.nvim_create_user_command("LspHover", "lua vim.lsp.buf.hover()", { nargs = '+' }) -opt.keywordprg = ":LspHover" -map('n', 'a', vim.lsp.buf.code_action, { remap = false }) - -- Use ctrl-[hjkl] to select the active split! map('n', '', ":wincmd k", { silent = true }) map('n', '', ":wincmd j", { silent = true }) diff --git a/laptop/plugin/lsp_config.lua b/laptop/plugin/lsp_config.lua index 26d96f5..299514e 100644 --- a/laptop/plugin/lsp_config.lua +++ b/laptop/plugin/lsp_config.lua @@ -1,4 +1,5 @@ local lspconfig = require('lspconfig') +local map = vim.keymap.set require 'lspconfig'.pyright.setup({ settings = { @@ -17,3 +18,12 @@ lspconfig.lua_ls.setup({ }, } }) + +-- Set ;k to hover and ;a to show code actions +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local bufnr = args.buf + map('n', 'k', vim.lsp.buf.hover, { remap = false }) + map('n', 'a', vim.lsp.buf.code_action, { remap = false }) + end, +}) diff --git a/server/plugin/lsp_config.lua b/server/plugin/lsp_config.lua index b88019a..08eb6dd 100644 --- a/server/plugin/lsp_config.lua +++ b/server/plugin/lsp_config.lua @@ -11,3 +11,12 @@ local lspconfig = require('lspconfig') -- }, -- }, -- } + +-- Set ;k to hover and ;a to show code actions +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local bufnr = args.buf + map('n', 'k', vim.lsp.buf.hover, { remap = false }) + map('n', 'a', vim.lsp.buf.code_action, { remap = false }) + end, +}) diff --git a/vps/plugin/lsp_config.lua b/vps/plugin/lsp_config.lua index b88019a..08eb6dd 100644 --- a/vps/plugin/lsp_config.lua +++ b/vps/plugin/lsp_config.lua @@ -11,3 +11,12 @@ local lspconfig = require('lspconfig') -- }, -- }, -- } + +-- Set ;k to hover and ;a to show code actions +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local bufnr = args.buf + map('n', 'k', vim.lsp.buf.hover, { remap = false }) + map('n', 'a', vim.lsp.buf.code_action, { remap = false }) + end, +})