update: nvim
This commit is contained in:
+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