mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
feat(neovim): Keymap enhacements
- Keep keymaps 2 character long - In case of conflicts choose Capital letter - Lsp: cI -> ch - LspSaga: cpf -> cF, cpt -> cT, cpi -> cI, - navbuddy: o -> / (search at current level) - new: snack: gL -> Popup git line log - new: Ctrl+` -> floating terminal (Lspsaga) - Whichkey: Consistent icons
This commit is contained in:
@@ -71,6 +71,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
end)
|
||||
end
|
||||
|
||||
-- Keymaps
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or "n"
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
@@ -86,9 +87,9 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
-- LspSaga
|
||||
map("<C-.>", "<cmd>Lspsaga code_action<cr>", "Code Actions")
|
||||
map("<leader>cr", "<cmd>Lspsaga finder<cr>", "Goto References")
|
||||
map("<leader>cpf", "<cmd>Lspsaga peek_definition<cr>", "Peek definition: Function")
|
||||
map("<leader>cpt", "<cmd>Lspsaga peek_type_definition<cr>", "Peek definition: Class")
|
||||
map("<leader>cpi", "<cmd>Lspsaga finder imp<cr>", "Peek: Implementations")
|
||||
map("<leader>cF", "<cmd>Lspsaga peek_definition<cr>", "Peek definition: Function")
|
||||
map("<leader>cT", "<cmd>Lspsaga peek_type_definition<cr>", "Peek definition: Class")
|
||||
map("<leader>cI", "<cmd>Lspsaga finder imp<cr>", "Peek: Implementations")
|
||||
-- e to jump to the symbol under cursor; q to quit
|
||||
map("<leader>co", "<cmd>Lspsaga outline<cr>", "Outline Panel on Left")
|
||||
|
||||
@@ -99,60 +100,13 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
map("<leader>ct", require("telescope.builtin").lsp_type_definitions, "Goto Type Definition")
|
||||
map("<leader>cd", require("telescope.builtin").diagnostics, "List Diagnostics")
|
||||
|
||||
-- The following two autocommands are used to highlight references of the
|
||||
-- word under cursor when cursor rests there for a little while.
|
||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Native lsp inline virtual text / inlay hints
|
||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
|
||||
vim.lsp.inlay_hint.enable() -- enabled by default
|
||||
vim.lsp.inlay_hint.enable()
|
||||
|
||||
map("<leader>cI", function()
|
||||
map("<leader>ch", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
|
||||
end, "Toggle Inlay Hints")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Change diagnostic symbols in the sign column (gutter)
|
||||
if vim.g.have_nerd_font then
|
||||
local signs = require("config.util").icons.diagnostics
|
||||
local diagnostic_signs = {}
|
||||
for type, icon in pairs(signs) do
|
||||
diagnostic_signs[vim.diagnostic.severity[type]] = icon
|
||||
end
|
||||
vim.diagnostic.config({ signs = { text = diagnostic_signs } })
|
||||
end
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
enabled = true,
|
||||
spacing = 5,
|
||||
severity = { min = vim.diagnostic.severity.ERROR },
|
||||
},
|
||||
virtual_lines = {
|
||||
current_line = true,
|
||||
severity = { min = vim.diagnostic.severity.INFO },
|
||||
},
|
||||
})
|
||||
|
||||
@@ -243,17 +243,18 @@ return {
|
||||
-- kind = require("config.util").icons.kind_lspsaga,
|
||||
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
|
||||
},
|
||||
implement = { enabled = true },
|
||||
symbol_in_winbar = {
|
||||
enable = true,
|
||||
hide_keyword = true,
|
||||
},
|
||||
lightbulb = {
|
||||
virtual_text = false,
|
||||
},
|
||||
lightbulb = { virtual_text = false },
|
||||
outline = { auto_preview = false },
|
||||
})
|
||||
|
||||
-- Keymaps in code-lsp.lua
|
||||
vim.keymap.set({ "n", "t" }, "<C-`>", "<cmd>Lspsaga term_toggle<cr>", { desc = "Toggle Floating Terminal" })
|
||||
|
||||
-- Rest of the keymaps in ../core/lsp.lua
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -277,20 +278,16 @@ return {
|
||||
size = "80%",
|
||||
},
|
||||
mappings = {
|
||||
-- Fuzzy finder at current level.
|
||||
["f"] = actions.telescope({
|
||||
-- Telescope search symbols at current level
|
||||
["/"] = actions.telescope({
|
||||
layout_config = {
|
||||
height = 0.8,
|
||||
width = 0.8,
|
||||
},
|
||||
}),
|
||||
-- Show preview of current node
|
||||
["o"] = actions.toggle_preview(),
|
||||
|
||||
-- Default Mappings on the popup
|
||||
--
|
||||
-- ["f"] = Search the children nodes using telescope
|
||||
--
|
||||
-- ["J"] = actions.move_down(), -- Move focused node down
|
||||
-- ["K"] = actions.move_up(), -- Move focused node up
|
||||
--
|
||||
|
||||
@@ -81,10 +81,6 @@ return {
|
||||
map("n", "<leader>gsh", gs.stage_hunk, { desc = "Git: Stage Hunk" })
|
||||
map("n", "<leader>gsu", gs.undo_stage_hunk, { desc = "Git: Undo Stage Hunk" })
|
||||
map("n", "<leader>gsb", gs.stage_buffer, { desc = "Git: Stage Current File" })
|
||||
map("n", "<leader>gK", function()
|
||||
gs.blame_line({ full = true })
|
||||
end, { desc = "Git: Hover blame-line" })
|
||||
|
||||
-- visual mode
|
||||
map("v", "<leader>gsH", function()
|
||||
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||
@@ -93,8 +89,11 @@ return {
|
||||
-- normal mode
|
||||
map("n", "<leader>gp", gs.preview_hunk, { desc = "Git: Preview hunk" })
|
||||
|
||||
-- Toggles
|
||||
map("n", "<leader>gB", gs.toggle_current_line_blame, { desc = "Git: Toggle blame-line" })
|
||||
map("n", "<leader>gK", function()
|
||||
gs.blame_line({ full = true })
|
||||
end, { desc = "Git: Hover blame-line" })
|
||||
|
||||
map("n", "<leader>gB", gs.toggle_current_line_blame, { desc = "Git: Toggle virtual blame-line" })
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -108,7 +108,14 @@ return {
|
||||
function()
|
||||
Snacks.lazygit.log(opts)
|
||||
end,
|
||||
desc = "Git: Log",
|
||||
desc = "LazyGit: List Git Log",
|
||||
},
|
||||
{
|
||||
"<leader>gL",
|
||||
function()
|
||||
Snacks.git.blame_line(opts)
|
||||
end,
|
||||
desc = "Git: Line Log",
|
||||
},
|
||||
{
|
||||
"<leader>gf",
|
||||
@@ -117,6 +124,13 @@ return {
|
||||
end,
|
||||
desc = "Git: Show File Log",
|
||||
},
|
||||
{
|
||||
"<leader>gO",
|
||||
function()
|
||||
Snacks.gitbrowse.open(opts)
|
||||
end,
|
||||
desc = "Git: Open the file on Browser",
|
||||
},
|
||||
{
|
||||
"]]",
|
||||
function()
|
||||
@@ -154,13 +168,6 @@ return {
|
||||
end,
|
||||
desc = "Toggle Zen Mode",
|
||||
},
|
||||
{
|
||||
"<leader>gO",
|
||||
function()
|
||||
Snacks.gitbrowse.open(opts)
|
||||
end,
|
||||
desc = "Git: Open the file on Browser",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -226,10 +233,11 @@ return {
|
||||
-- Document existing key chains
|
||||
spec = {
|
||||
{ "<leader>/", group = "NVIM Scratch Buffer" },
|
||||
{ "<leader>a", group = "AI" },
|
||||
{ "<leader>b", group = "Buffer Operations", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>a", group = "AI", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>b", group = "Buffer Operations", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>c", group = "Code", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>d", group = "Diagnostics", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>d", group = "Diagnostics", icon = { icon = "🔬", color = "orange" } },
|
||||
{ "<leader>D", group = "Debug", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>g", group = "Git", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>h", group = "Help", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>n", group = "Neovim Things", icon = { icon = "", color = "orange" } },
|
||||
@@ -237,6 +245,7 @@ return {
|
||||
{ "<leader>s", group = "Search/Grep", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>t", group = "Unit Test" },
|
||||
{ "<leader>x", group = "Delete/Disable/Remove", icon = { icon = "", color = "orange" } },
|
||||
-- More icons: https://github.com/echasnovski/mini.icons/blob/main/lua/mini/icons.lua#L686
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user