chg: Only do LSP related keybinds on LspAttach

This commit is contained in:
Sayantan Santra 2024-04-03 12:53:42 -05:00
parent 8524170e28
commit 51ad9f4bdf
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F
4 changed files with 28 additions and 5 deletions

View file

@ -8,11 +8,6 @@ local opt = vim.opt
g.mapleader = ',' g.mapleader = ','
g.maplocalleader = ';' 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', '<leader>a', vim.lsp.buf.code_action, { remap = false })
-- Use ctrl-[hjkl] to select the active split! -- Use ctrl-[hjkl] to select the active split!
map('n', '<c-k>', ":wincmd k<cr>", { silent = true }) map('n', '<c-k>', ":wincmd k<cr>", { silent = true })
map('n', '<c-j>', ":wincmd j<cr>", { silent = true }) map('n', '<c-j>', ":wincmd j<cr>", { silent = true })

View file

@ -1,4 +1,5 @@
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
local map = vim.keymap.set
require 'lspconfig'.pyright.setup({ require 'lspconfig'.pyright.setup({
settings = { 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', '<localleader>k', vim.lsp.buf.hover, { remap = false })
map('n', '<localleader>a', vim.lsp.buf.code_action, { remap = false })
end,
})

View file

@ -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', '<localleader>k', vim.lsp.buf.hover, { remap = false })
map('n', '<localleader>a', vim.lsp.buf.code_action, { remap = false })
end,
})

View file

@ -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', '<localleader>k', vim.lsp.buf.hover, { remap = false })
map('n', '<localleader>a', vim.lsp.buf.code_action, { remap = false })
end,
})