update: nvim
This commit is contained in:
@@ -1,27 +1,32 @@
|
||||
local bind = require("keymap.bind")
|
||||
local map_cr = bind.map_cr
|
||||
local map_cmd = bind.map_cmd
|
||||
local map_callback = bind.map_callback
|
||||
|
||||
local plug_map = {
|
||||
["n|<A-f>"] = map_cmd("<Cmd>FormatToggle<CR>"):with_noremap():with_desc("formatter: Toggle format on save"),
|
||||
local mappings = {
|
||||
fmt = {
|
||||
["n|<A-f>"] = map_cr("FormatToggle"):with_noremap():with_silent():with_desc("formatter: Toggle format on save"),
|
||||
["n|<A-S-f>"] = map_cr("Format"):with_noremap():with_silent():with_desc("formatter: Format buffer manually"),
|
||||
},
|
||||
}
|
||||
bind.nvim_load_mapping(plug_map)
|
||||
bind.nvim_load_mapping(mappings.fmt)
|
||||
|
||||
local mapping = {}
|
||||
--- The following code allows this file to be exported ---
|
||||
--- for use with LSP lazy-loaded keymap bindings ---
|
||||
|
||||
function mapping.lsp(buf)
|
||||
local M = {}
|
||||
|
||||
---@param buf integer
|
||||
function M.lsp(buf)
|
||||
local map = {
|
||||
-- LSP-related keymaps, ONLY effective in buffers with LSP(s) attached
|
||||
["n|<leader>li"] = map_cr("LspInfo"):with_silent():with_buffer(buf):with_desc("lsp: Info"),
|
||||
["n|<leader>lr"] = map_cr("LspRestart"):with_silent():with_buffer(buf):with_nowait():with_desc("lsp: Restart"),
|
||||
["n|go"] = map_cr("AerialToggle!"):with_silent():with_buffer(buf):with_desc("lsp: Toggle outline"),
|
||||
["n|gto"] = map_callback(function()
|
||||
require("telescope").extensions.aerial.aerial()
|
||||
["n|go"] = map_callback(function()
|
||||
require("edgy").toggle("right")
|
||||
end)
|
||||
:with_silent()
|
||||
:with_buffer(buf)
|
||||
:with_desc("lsp: Toggle outline in Telescope"),
|
||||
:with_desc("lsp: Toggle outline"),
|
||||
["n|g["] = map_cr("Lspsaga diagnostic_jump_prev")
|
||||
:with_silent()
|
||||
:with_buffer(buf)
|
||||
@@ -62,6 +67,18 @@ function mapping.lsp(buf)
|
||||
:with_silent()
|
||||
:with_buffer(buf)
|
||||
:with_desc("lsp: Show outgoing calls"),
|
||||
["n|<leader>lv"] = map_callback(function()
|
||||
_toggle_virtualtext()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Toggle virtual text display of current buffer"),
|
||||
["n|<leader>lh"] = map_callback(function()
|
||||
_toggle_inlayhint()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Toggle inlay hints dispaly of current buffer"),
|
||||
}
|
||||
bind.nvim_load_mapping(map)
|
||||
|
||||
@@ -71,4 +88,4 @@ function mapping.lsp(buf)
|
||||
end
|
||||
end
|
||||
|
||||
return mapping
|
||||
return M
|
||||
|
||||
@@ -5,105 +5,136 @@ local map_cmd = bind.map_cmd
|
||||
local map_callback = bind.map_callback
|
||||
local et = bind.escape_termcode
|
||||
|
||||
local plug_map = {
|
||||
-- Plugin persisted.nvim
|
||||
["n|<leader>ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"),
|
||||
["n|<leader>sl"] = map_cu("SessionLoad"):with_noremap():with_silent():with_desc("session: Load current"),
|
||||
["n|<leader>sd"] = map_cu("SessionDelete"):with_noremap():with_silent():with_desc("session: Delete"),
|
||||
local mappings = {
|
||||
builtins = {
|
||||
-- Builtins: Save & Quit
|
||||
["n|<C-s>"] = map_cu("write"):with_noremap():with_silent():with_desc("edit: Save file"),
|
||||
["n|<C-q>"] = map_cr("wq"):with_desc("edit: Save file and quit"),
|
||||
["n|<A-S-q>"] = map_cr("q!"):with_desc("edit: Force quit"),
|
||||
|
||||
-- Plugin: nvim-bufdel
|
||||
["n|<A-q>"] = map_cr("BufDel"):with_noremap():with_silent():with_desc("buffer: Close current"),
|
||||
-- Builtins: Insert mode
|
||||
["i|<C-u>"] = map_cmd("<C-G>u<C-U>"):with_noremap():with_desc("edit: Delete previous block"),
|
||||
["i|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Move cursor to left"),
|
||||
["i|<C-a>"] = map_cmd("<ESC>^i"):with_noremap():with_desc("edit: Move cursor to line start"),
|
||||
["i|<C-s>"] = map_cmd("<Esc>:w<CR>"):with_desc("edit: Save file"),
|
||||
["i|<C-q>"] = map_cmd("<Esc>:wq<CR>"):with_desc("edit: Save file and quit"),
|
||||
|
||||
-- Plugin: comment.nvim
|
||||
["n|gcc"] = map_callback(function()
|
||||
return vim.v.count == 0 and et("<Plug>(comment_toggle_linewise_current)")
|
||||
or et("<Plug>(comment_toggle_linewise_count)")
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_expr()
|
||||
:with_desc("edit: Toggle comment for line"),
|
||||
["n|gbc"] = map_callback(function()
|
||||
return vim.v.count == 0 and et("<Plug>(comment_toggle_blockwise_current)")
|
||||
or et("<Plug>(comment_toggle_blockwise_count)")
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_expr()
|
||||
:with_desc("edit: Toggle comment for block"),
|
||||
["n|gc"] = map_cmd("<Plug>(comment_toggle_linewise)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for line with operator"),
|
||||
["n|gb"] = map_cmd("<Plug>(comment_toggle_blockwise)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for block with operator"),
|
||||
["x|gc"] = map_cmd("<Plug>(comment_toggle_linewise_visual)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for line with selection"),
|
||||
["x|gb"] = map_cmd("<Plug>(comment_toggle_blockwise_visual)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for block with selection"),
|
||||
-- Builtins: Command mode
|
||||
["c|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Left"),
|
||||
["c|<C-f>"] = map_cmd("<Right>"):with_noremap():with_desc("edit: Right"),
|
||||
["c|<C-a>"] = map_cmd("<Home>"):with_noremap():with_desc("edit: Home"),
|
||||
["c|<C-e>"] = map_cmd("<End>"):with_noremap():with_desc("edit: End"),
|
||||
["c|<C-d>"] = map_cmd("<Del>"):with_noremap():with_desc("edit: Delete"),
|
||||
["c|<C-h>"] = map_cmd("<BS>"):with_noremap():with_desc("edit: Backspace"),
|
||||
["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]])
|
||||
:with_noremap()
|
||||
:with_desc("edit: Complete path of current file"),
|
||||
|
||||
-- Plugin: diffview.nvim
|
||||
["n|<leader>gd"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"),
|
||||
["n|<leader>gD"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"),
|
||||
-- Builtins: Visual mode
|
||||
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"):with_desc("edit: Move this line down"),
|
||||
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"):with_desc("edit: Move this line up"),
|
||||
["v|<"] = map_cmd("<gv"):with_desc("edit: Decrease indent"),
|
||||
["v|>"] = map_cmd(">gv"):with_desc("edit: Increase indent"),
|
||||
|
||||
-- Plugin: hop.nvim
|
||||
["nv|<leader>w"] = map_cmd("<Cmd>HopWordMW<CR>"):with_noremap():with_desc("jump: Goto word"),
|
||||
["nv|<leader>j"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
|
||||
["nv|<leader>k"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
|
||||
["nv|<leader>c"] = map_cmd("<Cmd>HopChar1MW<CR>"):with_noremap():with_desc("jump: Goto one char"),
|
||||
["nv|<leader>C"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),
|
||||
-- Builtins: "Suckless" - named after r/suckless
|
||||
["n|Y"] = map_cmd("y$"):with_desc("edit: Yank text to EOL"),
|
||||
["n|D"] = map_cmd("d$"):with_desc("edit: Delete text to EOL"),
|
||||
["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"),
|
||||
["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"),
|
||||
["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"),
|
||||
["n|<S-Tab>"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"),
|
||||
["n|<Esc>"] = map_callback(function()
|
||||
_flash_esc_or_noh()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("edit: Clear search highlight"),
|
||||
["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"),
|
||||
},
|
||||
plugins = {
|
||||
-- Plugin: persisted.nvim
|
||||
["n|<leader>ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"),
|
||||
["n|<leader>sl"] = map_cu("SessionLoad"):with_noremap():with_silent():with_desc("session: Load current"),
|
||||
["n|<leader>sd"] = map_cu("SessionDelete"):with_noremap():with_silent():with_desc("session: Delete"),
|
||||
|
||||
-- Plugin: smart-splits.nvim
|
||||
["n|<A-h>"] = map_cu("SmartResizeLeft"):with_silent():with_noremap():with_desc("window: Resize -3 horizontally"),
|
||||
["n|<A-j>"] = map_cu("SmartResizeDown"):with_silent():with_noremap():with_desc("window: Resize -3 vertically"),
|
||||
["n|<A-k>"] = map_cu("SmartResizeUp"):with_silent():with_noremap():with_desc("window: Resize +3 vertically"),
|
||||
["n|<A-l>"] = map_cu("SmartResizeRight"):with_silent():with_noremap():with_desc("window: Resize +3 horizontally"),
|
||||
["n|<C-h>"] = map_cu("SmartCursorMoveLeft"):with_silent():with_noremap():with_desc("window: Focus left"),
|
||||
["n|<C-j>"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"),
|
||||
["n|<C-k>"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"),
|
||||
["n|<C-l>"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"),
|
||||
["n|<leader>Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window leftward"),
|
||||
["n|<leader>Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window downward"),
|
||||
["n|<leader>Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"),
|
||||
["n|<leader>Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window rightward"),
|
||||
-- Plugin: comment.nvim
|
||||
["n|gcc"] = map_callback(function()
|
||||
return vim.v.count == 0 and et("<Plug>(comment_toggle_linewise_current)")
|
||||
or et("<Plug>(comment_toggle_linewise_count)")
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_expr()
|
||||
:with_desc("edit: Toggle comment for line"),
|
||||
["n|gbc"] = map_callback(function()
|
||||
return vim.v.count == 0 and et("<Plug>(comment_toggle_blockwise_current)")
|
||||
or et("<Plug>(comment_toggle_blockwise_count)")
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_expr()
|
||||
:with_desc("edit: Toggle comment for block"),
|
||||
["n|gc"] = map_cmd("<Plug>(comment_toggle_linewise)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for line with operator"),
|
||||
["n|gb"] = map_cmd("<Plug>(comment_toggle_blockwise)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for block with operator"),
|
||||
["x|gc"] = map_cmd("<Plug>(comment_toggle_linewise_visual)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for line with selection"),
|
||||
["x|gb"] = map_cmd("<Plug>(comment_toggle_blockwise_visual)")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: Toggle comment for block with selection"),
|
||||
|
||||
-- Plugin: nvim-spectre
|
||||
["n|<leader>Ss"] = map_callback(function()
|
||||
require("spectre").toggle()
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("editn: Toggle search & replace panel"),
|
||||
["n|<leader>Sp"] = map_callback(function()
|
||||
require("spectre").open_visual({ select_word = true })
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("editn: search&replace current word (project)"),
|
||||
["v|<leader>Sp"] = map_callback(function()
|
||||
require("spectre").open_visual()
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: search & replace current word (project)"),
|
||||
["n|<leader>Sf"] = map_callback(function()
|
||||
require("spectre").open_file_search({ select_word = true })
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("editn: search & replace current word (file)"),
|
||||
-- Plugin: diffview.nvim
|
||||
["n|<leader>gd"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"),
|
||||
["n|<leader>gD"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"),
|
||||
|
||||
-- Plugin: nvim-treehopper
|
||||
["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"),
|
||||
-- Plugin: hop.nvim
|
||||
["nv|<leader>w"] = map_cmd("<Cmd>HopWordMW<CR>"):with_noremap():with_desc("jump: Goto word"),
|
||||
["nv|<leader>j"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
|
||||
["nv|<leader>k"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
|
||||
["nv|<leader>c"] = map_cmd("<Cmd>HopChar1MW<CR>"):with_noremap():with_desc("jump: Goto one char"),
|
||||
["nv|<leader>C"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),
|
||||
|
||||
-- Plugin suda.vim
|
||||
["n|<A-s>"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"),
|
||||
-- Plugin: grug-far
|
||||
["n|<leader>Ss"] = map_callback(function()
|
||||
require("grug-far").open()
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("editn: Toggle search & replace panel"),
|
||||
["n|<leader>Sp"] = map_callback(function()
|
||||
require("grug-far").open({ prefills = { search = vim.fn.expand("<cword>") } })
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("editn: search&replace current word (project)"),
|
||||
["v|<leader>Sp"] = map_callback(function()
|
||||
require("grug-far").with_visual_selection()
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("edit: search & replace current word (project)"),
|
||||
["n|<leader>Sf"] = map_callback(function()
|
||||
require("grug-far").open({ prefills = { paths = vim.fn.expand("%") } })
|
||||
end)
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("editn: search & replace current word (file)"),
|
||||
|
||||
-- Plugin: nvim-treehopper
|
||||
["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"),
|
||||
|
||||
-- Plugin: suda.vim
|
||||
["n|<A-s>"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"),
|
||||
},
|
||||
}
|
||||
|
||||
bind.nvim_load_mapping(plug_map)
|
||||
bind.nvim_load_mapping(mappings.builtins)
|
||||
bind.nvim_load_mapping(mappings.plugins)
|
||||
|
||||
@@ -3,14 +3,20 @@ _G._command_panel = function()
|
||||
lhs_filter = function(lhs)
|
||||
return not string.find(lhs, "Þ")
|
||||
end,
|
||||
layout_config = {
|
||||
width = 0.6,
|
||||
height = 0.6,
|
||||
prompt_position = "top",
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
_G._flash_esc_or_noh = function()
|
||||
local flash_active, state = pcall(function()
|
||||
return require("flash.plugins.char").state
|
||||
end)
|
||||
if flash_active and state then
|
||||
state:hide()
|
||||
else
|
||||
pcall(vim.cmd.noh)
|
||||
end
|
||||
end
|
||||
|
||||
_G._telescope_collections = function(picker_type)
|
||||
local actions = require("telescope.actions")
|
||||
local action_state = require("telescope.actions.state")
|
||||
@@ -38,14 +44,27 @@ _G._telescope_collections = function(picker_type)
|
||||
:find()
|
||||
end
|
||||
|
||||
_G._flash_esc_or_noh = function()
|
||||
local flash_active, state = pcall(function()
|
||||
return require("flash.plugins.char").state
|
||||
end)
|
||||
if flash_active and state then
|
||||
state:hide()
|
||||
else
|
||||
pcall(vim.cmd.noh)
|
||||
_G._toggle_inlayhint = function()
|
||||
local is_enabled = vim.lsp.inlay_hint.is_enabled()
|
||||
|
||||
vim.lsp.inlay_hint.enable(not is_enabled)
|
||||
vim.notify(
|
||||
(is_enabled and "Inlay hint disabled successfully" or "Inlay hint enabled successfully"),
|
||||
vim.log.levels.INFO,
|
||||
{ title = "LSP Inlay Hint" }
|
||||
)
|
||||
end
|
||||
|
||||
local _vt_enabled = require("core.settings").diagnostics_virtual_text
|
||||
_G._toggle_virtualtext = function()
|
||||
if vim.diagnostic.is_enabled() then
|
||||
_vt_enabled = not _vt_enabled
|
||||
vim.diagnostic[_vt_enabled and "show" or "hide"]()
|
||||
vim.notify(
|
||||
(_vt_enabled and "Virtual text is now displayed" or "Virtual text is now hidden"),
|
||||
vim.log.levels.INFO,
|
||||
{ title = "LSP Diagnostic" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,27 +1,42 @@
|
||||
require("keymap.helpers")
|
||||
local bind = require("keymap.bind")
|
||||
local map_cr = bind.map_cr
|
||||
-- local map_cu = bind.map_cu
|
||||
-- local map_cmd = bind.map_cmd
|
||||
-- local map_callback = bind.map_callback
|
||||
|
||||
local plug_map = {
|
||||
-- Package manager: lazy.nvim
|
||||
["n|<leader>ph"] = map_cr("Lazy"):with_silent():with_noremap():with_nowait():with_desc("package: Show"),
|
||||
["n|<leader>ps"] = map_cr("Lazy sync"):with_silent():with_noremap():with_nowait():with_desc("package: Sync"),
|
||||
["n|<leader>pu"] = map_cr("Lazy update"):with_silent():with_noremap():with_nowait():with_desc("package: Update"),
|
||||
["n|<leader>pi"] = map_cr("Lazy install"):with_silent():with_noremap():with_nowait():with_desc("package: Install"),
|
||||
["n|<leader>pl"] = map_cr("Lazy log"):with_silent():with_noremap():with_nowait():with_desc("package: Log"),
|
||||
["n|<leader>pc"] = map_cr("Lazy check"):with_silent():with_noremap():with_nowait():with_desc("package: Check"),
|
||||
["n|<leader>pd"] = map_cr("Lazy debug"):with_silent():with_noremap():with_nowait():with_desc("package: Debug"),
|
||||
["n|<leader>pp"] = map_cr("Lazy profile"):with_silent():with_noremap():with_nowait():with_desc("package: Profile"),
|
||||
["n|<leader>pr"] = map_cr("Lazy restore"):with_silent():with_noremap():with_nowait():with_desc("package: Restore"),
|
||||
["n|<leader>px"] = map_cr("Lazy clean"):with_silent():with_noremap():with_nowait():with_desc("package: Clean"),
|
||||
local mappings = {
|
||||
core = {
|
||||
-- Package manager: lazy.nvim
|
||||
["n|<leader>ph"] = map_cr("Lazy"):with_silent():with_noremap():with_nowait():with_desc("package: Show"),
|
||||
["n|<leader>ps"] = map_cr("Lazy sync"):with_silent():with_noremap():with_nowait():with_desc("package: Sync"),
|
||||
["n|<leader>pu"] = map_cr("Lazy update")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_nowait()
|
||||
:with_desc("package: Update"),
|
||||
["n|<leader>pi"] = map_cr("Lazy install")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_nowait()
|
||||
:with_desc("package: Install"),
|
||||
["n|<leader>pl"] = map_cr("Lazy log"):with_silent():with_noremap():with_nowait():with_desc("package: Log"),
|
||||
["n|<leader>pc"] = map_cr("Lazy check"):with_silent():with_noremap():with_nowait():with_desc("package: Check"),
|
||||
["n|<leader>pd"] = map_cr("Lazy debug"):with_silent():with_noremap():with_nowait():with_desc("package: Debug"),
|
||||
["n|<leader>pp"] = map_cr("Lazy profile")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_nowait()
|
||||
:with_desc("package: Profile"),
|
||||
["n|<leader>pr"] = map_cr("Lazy restore")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_nowait()
|
||||
:with_desc("package: Restore"),
|
||||
["n|<leader>px"] = map_cr("Lazy clean"):with_silent():with_noremap():with_nowait():with_desc("package: Clean"),
|
||||
},
|
||||
}
|
||||
|
||||
bind.nvim_load_mapping(plug_map)
|
||||
bind.nvim_load_mapping(mappings.core)
|
||||
|
||||
-- Plugin keymaps
|
||||
-- Builtin & Plugin keymaps
|
||||
require("keymap.completion")
|
||||
require("keymap.editor")
|
||||
require("keymap.lang")
|
||||
@@ -29,7 +44,7 @@ require("keymap.tool")
|
||||
require("keymap.ui")
|
||||
|
||||
-- User keymaps
|
||||
local ok, mappings = pcall(require, "user.keymap.init")
|
||||
local ok, def = pcall(require, "user.keymap.init")
|
||||
if ok then
|
||||
require("modules.utils.keymap").replace(mappings)
|
||||
require("modules.utils.keymap").replace(def)
|
||||
end
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
local bind = require("keymap.bind")
|
||||
local map_cr = bind.map_cr
|
||||
-- local map_cu = bind.map_cu
|
||||
-- local map_cmd = bind.map_cmd
|
||||
-- local map_callback = bind.map_callback
|
||||
|
||||
local plug_map = {
|
||||
-- Plugin render-markdown.nvim
|
||||
["n|<F1>"] = map_cr("RenderMarkdown toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: toggle markdown preview within nvim"),
|
||||
-- Plugin MarkdownPreview
|
||||
["n|<F12>"] = map_cr("MarkdownPreviewToggle"):with_noremap():with_silent():with_desc("tool: Preview markdown"),
|
||||
local mappings = {
|
||||
plugins = {
|
||||
-- Plugin: render-markdown.nvim
|
||||
["n|<F1>"] = map_cr("RenderMarkdown toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: toggle markdown preview within nvim"),
|
||||
-- Plugin: MarkdownPreview
|
||||
["n|<F12>"] = map_cr("MarkdownPreviewToggle"):with_noremap():with_silent():with_desc("tool: Preview markdown"),
|
||||
},
|
||||
}
|
||||
|
||||
bind.nvim_load_mapping(plug_map)
|
||||
bind.nvim_load_mapping(mappings.plugins)
|
||||
|
||||
+201
-176
@@ -1,3 +1,4 @@
|
||||
local vim_path = require("core.global").vim_path
|
||||
local bind = require("keymap.bind")
|
||||
local map_cr = bind.map_cr
|
||||
local map_cu = bind.map_cu
|
||||
@@ -5,187 +6,211 @@ local map_cmd = bind.map_cmd
|
||||
local map_callback = bind.map_callback
|
||||
require("keymap.helpers")
|
||||
|
||||
local plug_map = {
|
||||
-- Plugin: vim-fugitive
|
||||
["n|gps"] = map_cr("G push"):with_noremap():with_silent():with_desc("git: Push"),
|
||||
["n|gpl"] = map_cr("G pull"):with_noremap():with_silent():with_desc("git: Pull"),
|
||||
["n|<leader>gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"),
|
||||
local mappings = {
|
||||
plugins = {
|
||||
-- Plugin: edgy
|
||||
["n|<C-n>"] = map_callback(function()
|
||||
require("edgy").toggle("left")
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("filetree: Toggle"),
|
||||
|
||||
-- Plugin: nvim-tree
|
||||
["n|<C-n>"] = map_cr("NvimTreeToggle"):with_noremap():with_silent():with_desc("filetree: Toggle"),
|
||||
["n|<leader>nf"] = map_cr("NvimTreeFindFile"):with_noremap():with_silent():with_desc("filetree: Find file"),
|
||||
["n|<leader>nr"] = map_cr("NvimTreeRefresh"):with_noremap():with_silent():with_desc("filetree: Refresh"),
|
||||
-- Plugin: vim-fugitive
|
||||
["n|gps"] = map_cr("G push"):with_noremap():with_silent():with_desc("git: Push"),
|
||||
["n|gpl"] = map_cr("G pull"):with_noremap():with_silent():with_desc("git: Pull"),
|
||||
["n|<leader>gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"),
|
||||
|
||||
-- Plugin: sniprun
|
||||
["v|<leader>r"] = map_cr("SnipRun"):with_noremap():with_silent():with_desc("tool: Run code by range"),
|
||||
["n|<leader>r"] = map_cu([[%SnipRun]]):with_noremap():with_silent():with_desc("tool: Run code by file"),
|
||||
-- Plugin: nvim-tree
|
||||
["n|<leader>nf"] = map_cr("NvimTreeFindFile"):with_noremap():with_silent():with_desc("filetree: Find file"),
|
||||
["n|<leader>nr"] = map_cr("NvimTreeRefresh"):with_noremap():with_silent():with_desc("filetree: Refresh"),
|
||||
|
||||
-- Plugin: toggleterm
|
||||
["t|<Esc><Esc>"] = map_cmd([[<C-\><C-n>]]):with_noremap():with_silent(), -- switch to normal mode in terminal.
|
||||
["n|<C-\\>"] = map_cr("ToggleTerm direction=horizontal")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle horizontal"),
|
||||
["i|<C-\\>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=horizontal<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle horizontal"),
|
||||
["t|<C-\\>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle horizontal"),
|
||||
["n|<A-\\>"] = map_cr("ToggleTerm direction=vertical")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["i|<A-\\>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=vertical<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["t|<A-\\>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle vertical"),
|
||||
["n|<F5>"] = map_cr("ToggleTerm direction=vertical")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["i|<F5>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=vertical<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["t|<F5>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle vertical"),
|
||||
["n|<A-d>"] = map_cr("ToggleTerm direction=float"):with_noremap():with_silent():with_desc("terminal: Toggle float"),
|
||||
["i|<A-d>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=float<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle float"),
|
||||
["t|<A-d>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle float"),
|
||||
["n|<leader>gg"] = map_callback(function()
|
||||
_toggle_lazygit()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("git: Toggle lazygit"),
|
||||
-- Plugin: sniprun
|
||||
["v|<leader>r"] = map_cr("SnipRun"):with_noremap():with_silent():with_desc("tool: Run code by range"),
|
||||
["n|<leader>r"] = map_cu([[%SnipRun]]):with_noremap():with_silent():with_desc("tool: Run code by file"),
|
||||
|
||||
-- Plugin: trouble
|
||||
["n|gt"] = map_cr("Trouble diagnostics toggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"),
|
||||
["n|<leader>lw"] = map_cr("Trouble diagnostics toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Show workspace diagnostics"),
|
||||
["n|<leader>lp"] = map_cr("Trouble project_diagnostics toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Show project diagnostics"),
|
||||
["n|<leader>ld"] = map_cr("Trouble diagnostics toggle filter.buf=0")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Show document diagnostics"),
|
||||
-- Plugin: toggleterm
|
||||
["t|<Esc><Esc>"] = map_cmd([[<C-\><C-n>]]):with_noremap():with_silent(), -- switch to normal mode in terminal.
|
||||
["n|<C-\\>"] = map_cr("ToggleTerm direction=horizontal")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle horizontal"),
|
||||
["i|<C-\\>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=horizontal<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle horizontal"),
|
||||
["t|<C-\\>"] = map_cmd("<Cmd>ToggleTerm<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle horizontal"),
|
||||
["n|<A-\\>"] = map_cr("ToggleTerm direction=vertical")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["i|<A-\\>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=vertical<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["t|<A-\\>"] = map_cmd("<Cmd>ToggleTerm<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["n|<F5>"] = map_cr("ToggleTerm direction=vertical")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["i|<F5>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=vertical<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle vertical"),
|
||||
["t|<F5>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle vertical"),
|
||||
["n|<A-d>"] = map_cr("ToggleTerm direction=float")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle float"),
|
||||
["i|<A-d>"] = map_cmd("<Esc><Cmd>ToggleTerm direction=float<CR>")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("terminal: Toggle float"),
|
||||
["t|<A-d>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle float"),
|
||||
["n|<leader>gg"] = map_callback(function()
|
||||
_toggle_lazygit()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("git: Toggle lazygit"),
|
||||
|
||||
-- Plugin: telescope
|
||||
["n|<C-p>"] = map_callback(function()
|
||||
_command_panel()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Toggle command panel"),
|
||||
["n|<leader>fc"] = map_callback(function()
|
||||
_telescope_collections(require("telescope.themes").get_dropdown())
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Open Telescope collections"),
|
||||
["n|<leader>ff"] = map_callback(function()
|
||||
require("search").open({ collection = "file" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Find files"),
|
||||
["n|<leader>fp"] = map_callback(function()
|
||||
require("search").open({ collection = "pattern" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Find patterns"),
|
||||
["v|<leader>fs"] = map_cu("Telescope grep_string")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Find word under cursor"),
|
||||
["n|<leader>fg"] = map_callback(function()
|
||||
require("search").open({ collection = "git" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Locate Git objects"),
|
||||
["n|<leader>fd"] = map_callback(function()
|
||||
require("search").open({ collection = "dossier" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Retrieve dossiers"),
|
||||
["n|<leader>fm"] = map_callback(function()
|
||||
require("search").open({ collection = "misc" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Miscellaneous"),
|
||||
-- Plugin: trouble
|
||||
["n|gt"] = map_cr("Trouble diagnostics toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Toggle trouble list"),
|
||||
["n|<leader>lw"] = map_cr("Trouble diagnostics toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Show workspace diagnostics"),
|
||||
["n|<leader>lp"] = map_cr("Trouble project_diagnostics toggle")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Show project diagnostics"),
|
||||
["n|<leader>ld"] = map_cr("Trouble diagnostics toggle filter.buf=0")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("lsp: Show document diagnostics"),
|
||||
|
||||
-- Plugin: dap
|
||||
["n|<F6>"] = map_callback(function()
|
||||
require("dap").continue()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Run/Continue"),
|
||||
["n|<F7>"] = map_callback(function()
|
||||
require("dap").terminate()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Stop"),
|
||||
["n|<F8>"] = map_callback(function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Toggle breakpoint"),
|
||||
["n|<F9>"] = map_callback(function()
|
||||
require("dap").step_into()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Step into"),
|
||||
["n|<F10>"] = map_callback(function()
|
||||
require("dap").step_out()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Step out"),
|
||||
["n|<F11>"] = map_callback(function()
|
||||
require("dap").step_over()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Step over"),
|
||||
["n|<leader>db"] = map_callback(function()
|
||||
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Set breakpoint with condition"),
|
||||
["n|<leader>dc"] = map_callback(function()
|
||||
require("dap").run_to_cursor()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Run to cursor"),
|
||||
["n|<leader>dl"] = map_callback(function()
|
||||
require("dap").run_last()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Run last"),
|
||||
["n|<leader>do"] = map_callback(function()
|
||||
require("dap").repl.open()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Open REPL"),
|
||||
-- Plugin: telescope
|
||||
["n|<C-p>"] = map_callback(function()
|
||||
_command_panel()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Toggle command panel"),
|
||||
["n|<leader>fc"] = map_callback(function()
|
||||
_telescope_collections(require("telescope.themes").get_dropdown())
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Open Telescope collections"),
|
||||
["n|<leader>ff"] = map_callback(function()
|
||||
require("search").open({ collection = "file" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Find files"),
|
||||
["n|<leader>fp"] = map_callback(function()
|
||||
require("search").open({ collection = "pattern" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Find patterns"),
|
||||
["v|<leader>fs"] = map_callback(function()
|
||||
local opts = vim.fn.getcwd() == vim_path and { additional_args = { "--no-ignore" } } or {}
|
||||
require("telescope-live-grep-args.shortcuts").grep_visual_selection(opts)
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Find word under cursor"),
|
||||
["n|<leader>fg"] = map_callback(function()
|
||||
require("search").open({ collection = "git" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Locate Git objects"),
|
||||
["n|<leader>fd"] = map_callback(function()
|
||||
require("search").open({ collection = "dossier" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Retrieve dossiers"),
|
||||
["n|<leader>fm"] = map_callback(function()
|
||||
require("search").open({ collection = "misc" })
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("tool: Miscellaneous"),
|
||||
|
||||
-- Plugin: dap
|
||||
["n|<F6>"] = map_callback(function()
|
||||
require("dap").continue()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Run/Continue"),
|
||||
["n|<F7>"] = map_callback(function()
|
||||
require("dap").terminate()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Stop"),
|
||||
["n|<F8>"] = map_callback(function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Toggle breakpoint"),
|
||||
["n|<F9>"] = map_callback(function()
|
||||
require("dap").step_into()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Step into"),
|
||||
["n|<F10>"] = map_callback(function()
|
||||
require("dap").step_out()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Step out"),
|
||||
["n|<F11>"] = map_callback(function()
|
||||
require("dap").step_over()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Step over"),
|
||||
["n|<leader>db"] = map_callback(function()
|
||||
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Set breakpoint with condition"),
|
||||
["n|<leader>dc"] = map_callback(function()
|
||||
require("dap").run_to_cursor()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Run to cursor"),
|
||||
["n|<leader>dl"] = map_callback(function()
|
||||
require("dap").run_last()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Run last"),
|
||||
["n|<leader>do"] = map_callback(function()
|
||||
require("dap").repl.open()
|
||||
end)
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("debug: Open REPL"),
|
||||
},
|
||||
}
|
||||
|
||||
bind.nvim_load_mapping(plug_map)
|
||||
bind.nvim_load_mapping(mappings.plugins)
|
||||
|
||||
+147
-81
@@ -1,105 +1,171 @@
|
||||
local bind = require("keymap.bind")
|
||||
local map_cr = bind.map_cr
|
||||
-- local map_cu = bind.map_cu
|
||||
-- local map_cmd = bind.map_cmd
|
||||
-- local map_callback = bind.map_callback
|
||||
local map_cu = bind.map_cu
|
||||
local map_cmd = bind.map_cmd
|
||||
local map_callback = bind.map_callback
|
||||
|
||||
local plug_map = {
|
||||
-- Plugin: bufferline.nvim
|
||||
["n|<A-i>"] = map_cr("BufferLineCycleNext"):with_noremap():with_silent():with_desc("buffer: Switch to next"),
|
||||
["n|<A-o>"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent():with_desc("buffer: Switch to prev"),
|
||||
["n|<A-S-i>"] = map_cr("BufferLineMoveNext"):with_noremap():with_silent():with_desc("buffer: Move current to next"),
|
||||
["n|<A-S-o>"] = map_cr("BufferLineMovePrev"):with_noremap():with_silent():with_desc("buffer: Move current to prev"),
|
||||
["n|<leader>be"] = map_cr("BufferLineSortByExtension"):with_noremap():with_desc("buffer: Sort by extension"),
|
||||
["n|<leader>bd"] = map_cr("BufferLineSortByDirectory"):with_noremap():with_desc("buffer: Sort by directory"),
|
||||
["n|<A-1>"] = map_cr("BufferLineGoToBuffer 1"):with_noremap():with_silent():with_desc("buffer: Goto buffer 1"),
|
||||
["n|<A-2>"] = map_cr("BufferLineGoToBuffer 2"):with_noremap():with_silent():with_desc("buffer: Goto buffer 2"),
|
||||
["n|<A-3>"] = map_cr("BufferLineGoToBuffer 3"):with_noremap():with_silent():with_desc("buffer: Goto buffer 3"),
|
||||
["n|<A-4>"] = map_cr("BufferLineGoToBuffer 4"):with_noremap():with_silent():with_desc("buffer: Goto buffer 4"),
|
||||
["n|<A-5>"] = map_cr("BufferLineGoToBuffer 5"):with_noremap():with_silent():with_desc("buffer: Goto buffer 5"),
|
||||
["n|<A-6>"] = map_cr("BufferLineGoToBuffer 6"):with_noremap():with_silent():with_desc("buffer: Goto buffer 6"),
|
||||
["n|<A-7>"] = map_cr("BufferLineGoToBuffer 7"):with_noremap():with_silent():with_desc("buffer: Goto buffer 7"),
|
||||
["n|<A-8>"] = map_cr("BufferLineGoToBuffer 8"):with_noremap():with_silent():with_desc("buffer: Goto buffer 8"),
|
||||
["n|<A-9>"] = map_cr("BufferLineGoToBuffer 9"):with_noremap():with_silent():with_desc("buffer: Goto buffer 9"),
|
||||
local mappings = {
|
||||
builtins = {
|
||||
-- Builtins: Buffer
|
||||
["n|<leader>bn"] = map_cu("enew"):with_noremap():with_silent():with_desc("buffer: New"),
|
||||
|
||||
-- Builtins: Terminal
|
||||
["t|<C-w>h"] = map_cmd("<Cmd>wincmd h<CR>"):with_silent():with_noremap():with_desc("window: Focus left"),
|
||||
["t|<C-w>l"] = map_cmd("<Cmd>wincmd l<CR>"):with_silent():with_noremap():with_desc("window: Focus right"),
|
||||
["t|<C-w>j"] = map_cmd("<Cmd>wincmd j<CR>"):with_silent():with_noremap():with_desc("window: Focus down"),
|
||||
["t|<C-w>k"] = map_cmd("<Cmd>wincmd k<CR>"):with_silent():with_noremap():with_desc("window: Focus up"),
|
||||
|
||||
-- Builtins: Tabpage
|
||||
["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"),
|
||||
["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"),
|
||||
["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"),
|
||||
["n|to"] = map_cr("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"),
|
||||
},
|
||||
plugins = {
|
||||
-- Plugin: nvim-bufdel
|
||||
["n|<A-q>"] = map_cr("BufDel"):with_noremap():with_silent():with_desc("buffer: Close current"),
|
||||
|
||||
-- Plugin: bufferline.nvim
|
||||
["n|<A-i>"] = map_cr("BufferLineCycleNext"):with_noremap():with_silent():with_desc("buffer: Switch to next"),
|
||||
["n|<A-o>"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent():with_desc("buffer: Switch to prev"),
|
||||
["n|<A-S-i>"] = map_cr("BufferLineMoveNext")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("buffer: Move current to next"),
|
||||
["n|<A-S-o>"] = map_cr("BufferLineMovePrev")
|
||||
:with_noremap()
|
||||
:with_silent()
|
||||
:with_desc("buffer: Move current to prev"),
|
||||
["n|<leader>be"] = map_cr("BufferLineSortByExtension"):with_noremap():with_desc("buffer: Sort by extension"),
|
||||
["n|<leader>bd"] = map_cr("BufferLineSortByDirectory"):with_noremap():with_desc("buffer: Sort by directory"),
|
||||
["n|<A-1>"] = map_cr("BufferLineGoToBuffer 1"):with_noremap():with_silent():with_desc("buffer: Goto buffer 1"),
|
||||
["n|<A-2>"] = map_cr("BufferLineGoToBuffer 2"):with_noremap():with_silent():with_desc("buffer: Goto buffer 2"),
|
||||
["n|<A-3>"] = map_cr("BufferLineGoToBuffer 3"):with_noremap():with_silent():with_desc("buffer: Goto buffer 3"),
|
||||
["n|<A-4>"] = map_cr("BufferLineGoToBuffer 4"):with_noremap():with_silent():with_desc("buffer: Goto buffer 4"),
|
||||
["n|<A-5>"] = map_cr("BufferLineGoToBuffer 5"):with_noremap():with_silent():with_desc("buffer: Goto buffer 5"),
|
||||
["n|<A-6>"] = map_cr("BufferLineGoToBuffer 6"):with_noremap():with_silent():with_desc("buffer: Goto buffer 6"),
|
||||
["n|<A-7>"] = map_cr("BufferLineGoToBuffer 7"):with_noremap():with_silent():with_desc("buffer: Goto buffer 7"),
|
||||
["n|<A-8>"] = map_cr("BufferLineGoToBuffer 8"):with_noremap():with_silent():with_desc("buffer: Goto buffer 8"),
|
||||
["n|<A-9>"] = map_cr("BufferLineGoToBuffer 9"):with_noremap():with_silent():with_desc("buffer: Goto buffer 9"),
|
||||
|
||||
-- Plugin: smart-splits.nvim
|
||||
["n|<A-h>"] = map_cu("SmartResizeLeft")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("window: Resize -3 horizontally"),
|
||||
["n|<A-j>"] = map_cu("SmartResizeDown"):with_silent():with_noremap():with_desc("window: Resize -3 vertically"),
|
||||
["n|<A-k>"] = map_cu("SmartResizeUp"):with_silent():with_noremap():with_desc("window: Resize +3 vertically"),
|
||||
["n|<A-l>"] = map_cu("SmartResizeRight")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("window: Resize +3 horizontally"),
|
||||
["n|<C-h>"] = map_cu("SmartCursorMoveLeft"):with_silent():with_noremap():with_desc("window: Focus left"),
|
||||
["n|<C-j>"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"),
|
||||
["n|<C-k>"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"),
|
||||
["n|<C-l>"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"),
|
||||
["n|<leader>Wh"] = map_cu("SmartSwapLeft")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("window: Move window leftward"),
|
||||
["n|<leader>Wj"] = map_cu("SmartSwapDown")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("window: Move window downward"),
|
||||
["n|<leader>Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"),
|
||||
["n|<leader>Wl"] = map_cu("SmartSwapRight")
|
||||
:with_silent()
|
||||
:with_noremap()
|
||||
:with_desc("window: Move window rightward"),
|
||||
},
|
||||
}
|
||||
|
||||
bind.nvim_load_mapping(plug_map)
|
||||
bind.nvim_load_mapping(mappings.builtins)
|
||||
bind.nvim_load_mapping(mappings.plugins)
|
||||
|
||||
local mapping = {}
|
||||
--- The following code enables this file to be exported ---
|
||||
--- for use with gitsigns lazy-loaded keymap bindings ---
|
||||
|
||||
function mapping.gitsigns(buf)
|
||||
local actions = require("gitsigns.actions")
|
||||
local M = {}
|
||||
|
||||
function M.gitsigns(bufnr)
|
||||
local gitsigns = require("gitsigns")
|
||||
local map = {
|
||||
["n|]g"] = bind.map_callback(function()
|
||||
if vim.wo.diff then
|
||||
return "]g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
actions.next_hunk()
|
||||
["n|]g"] = map_callback(function()
|
||||
if vim.wo.diff then
|
||||
return "]g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.nav_hunk("next")
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_expr()
|
||||
:with_desc("git: Goto next hunk"),
|
||||
["n|[g"] = bind.map_callback(function()
|
||||
if vim.wo.diff then
|
||||
return "[g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
actions.prev_hunk()
|
||||
["n|[g"] = map_callback(function()
|
||||
if vim.wo.diff then
|
||||
return "[g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.nav_hunk("prev")
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_expr()
|
||||
:with_desc("git: Goto prev hunk"),
|
||||
["n|<leader>gs"] = bind.map_callback(function()
|
||||
actions.stage_hunk()
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
:with_desc("git: Stage hunk"),
|
||||
["v|<leader>gs"] = bind.map_callback(function()
|
||||
actions.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
:with_desc("git: Stage hunk"),
|
||||
["n|<leader>gu"] = bind.map_callback(function()
|
||||
actions.undo_stage_hunk()
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
:with_desc("git: Undo stage hunk"),
|
||||
["n|<leader>gr"] = bind.map_callback(function()
|
||||
actions.reset_hunk()
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
["n|<leader>gs"] = map_callback(function()
|
||||
gitsigns.stage_hunk()
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Toggle staging/unstaging of hunk"),
|
||||
["v|<leader>gs"] = map_callback(function()
|
||||
gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Toggle staging/unstaging of selected hunk"),
|
||||
["n|<leader>gr"] = map_callback(function()
|
||||
gitsigns.reset_hunk()
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Reset hunk"),
|
||||
["v|<leader>gr"] = bind.map_callback(function()
|
||||
actions.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
["v|<leader>gr"] = map_callback(function()
|
||||
gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Reset hunk"),
|
||||
["n|<leader>gR"] = bind.map_callback(function()
|
||||
actions.reset_buffer()
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
["n|<leader>gR"] = map_callback(function()
|
||||
gitsigns.reset_buffer()
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Reset buffer"),
|
||||
["n|<leader>gp"] = bind.map_callback(function()
|
||||
actions.preview_hunk()
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
["n|<leader>gp"] = map_callback(function()
|
||||
gitsigns.preview_hunk()
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Preview hunk"),
|
||||
["n|<leader>gb"] = bind.map_callback(function()
|
||||
actions.blame_line({ full = true })
|
||||
end)
|
||||
:with_buffer(buf)
|
||||
["n|<leader>gb"] = map_callback(function()
|
||||
gitsigns.blame_line({ full = true })
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap()
|
||||
:with_desc("git: Blame line"),
|
||||
-- Text objects
|
||||
["ox|ih"] = bind.map_callback(function()
|
||||
actions.text_object()
|
||||
end):with_buffer(buf),
|
||||
["ox|ih"] = map_callback(function()
|
||||
gitsigns.select_hunk()
|
||||
end)
|
||||
:with_buffer(bufnr)
|
||||
:with_noremap(),
|
||||
}
|
||||
bind.nvim_load_mapping(map)
|
||||
end
|
||||
|
||||
return mapping
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user