mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(keymaps): Use cd to LSP Rename (N)
This commit is contained in:
parent
0164b1ca8a
commit
e8d5568745
6 changed files with 56 additions and 11 deletions
|
|
@ -7,6 +7,37 @@ local M = {
|
|||
{ keys = "<leader>,", cmd = vim.lsp.buf.code_action, opts = { desc = "Code Action" } },
|
||||
{ keys = "ga", cmd = vim.lsp.buf.code_action, opts = { desc = "Code Action" } },
|
||||
{ keys = "gh", cmd = vim.lsp.buf.hover, opts = { desc = "Show hover" } },
|
||||
-- [c]hange [d]efinition
|
||||
{ keys = "cd", cmd = vim.lsp.buf.rename, opts = { desc = "Rename symbol under cursor" } },
|
||||
}
|
||||
|
||||
-- local function smart_split_definition()
|
||||
-- local width = vim.api.nvim_win_get_width(0)
|
||||
-- if width > 80 then -- Adjust 80 to your preference
|
||||
-- vim.api.nvim_command("vsp")
|
||||
-- else
|
||||
-- vim.api.nvim_command("sp")
|
||||
-- end
|
||||
-- vim.lsp.buf.definition()
|
||||
-- end
|
||||
-- vim.keymap.set("n", "<C-w>d", smart_split_definition, { desc = "Go to Definition (Smart Split)" })
|
||||
|
||||
local function smart_split(func)
|
||||
local width = vim.api.nvim_win_get_width(0)
|
||||
if width > 80 then
|
||||
vim.api.nvim_command("vsp")
|
||||
else
|
||||
vim.api.nvim_command("sp")
|
||||
end
|
||||
func()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<C-w>d", function()
|
||||
smart_split(vim.lsp.buf.definition)
|
||||
end, { desc = "Go to Definition (Smart Split)" })
|
||||
|
||||
vim.keymap.set("n", "<C-w>D", function()
|
||||
smart_split(vim.lsp.buf.declaration)
|
||||
end, { desc = "Go to Declaration (Smart Split)" })
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue