Update Cw keymaps

This commit is contained in:
xfy 2026-05-28 13:26:53 +08:00
parent 15a2ad9b20
commit 8138b7c761
3 changed files with 15 additions and 7 deletions

View File

@ -3,12 +3,9 @@ vim.g.mapleader = " "
local map = vim.keymap.set local map = vim.keymap.set
map("x", "p", [[_dP]], { desc = "Paste over selection without losing yanked text" }) map("x", "p", [[_dP]], { desc = "Paste over selection without losing yanked text" })
map("n", "<Esc>", ":nohl<CR>", { desc = "Clear search highlighting", silent = true }) map("n", "<Esc>", ":nohl<CR>", { desc = "Clear search highlighting", silent = true })
map("v", "<", "<gv", { desc = "Unindent and keep selection" }) map("v", "<", "<gv", { desc = "Unindent and keep selection" })
map("v", ">", ">gv", { desc = "Indent and keep selection" }) map("v", ">", ">gv", { desc = "Indent and keep selection" })
map("n", "J", "mzJ`z", { desc = "Join lines without moving cursor" }) map("n", "J", "mzJ`z", { desc = "Join lines without moving cursor" })
map( map(
@ -37,6 +34,12 @@ map("n", "<C-c>", "<cmd>%y+<CR>", { desc = "Copy whole file" })
map("t", "<C-x>", "<c-\\><c-n>", { desc = "Escape termainl" }) map("t", "<C-x>", "<c-\\><c-n>", { desc = "Escape termainl" })
map("n", "<leader>tt", ":term<CR>", { desc = "Open new terminal" }) map("n", "<leader>tt", ":term<CR>", { desc = "Open new terminal" })
-- window navigation
map("n", "<C-h>", "<C-w>h", { desc = "Switch to left window" })
map("n", "<C-j>", "<C-w>j", { desc = "Switch to down window" })
map("n", "<C-k>", "<C-w>k", { desc = "Switch to up window" })
map("n", "<C-l>", "<C-w>l", { desc = "Switch to right window" })
-- tabs -- tabs
map("n", "<leader>tc", ":tabclose<CR>", { desc = "Close current tab" }) map("n", "<leader>tc", ":tabclose<CR>", { desc = "Close current tab" })
map("n", "<leader>tn", ":tabnew<CR>", { desc = "New tab" }) map("n", "<leader>tn", ":tabnew<CR>", { desc = "New tab" })
@ -49,14 +52,13 @@ map("n", "<leader>yp", function()
vim.fn.setreg("+", path) vim.fn.setreg("+", path)
vim.notify("Copied relative path: " .. path, vim.log.levels.INFO) vim.notify("Copied relative path: " .. path, vim.log.levels.INFO)
end, { desc = "Yank relative file path" }) end, { desc = "Yank relative file path" })
map("n", "<leader>yP", function() map("n", "<leader>yP", function()
local path = vim.fn.expand("%:p") local path = vim.fn.expand("%:p")
vim.fn.setreg("+", path) vim.fn.setreg("+", path)
vim.notify("Copied absolute path: " .. path, vim.log.levels.INFO) vim.notify("Copied absolute path: " .. path, vim.log.levels.INFO)
end, { desc = "Yank absolute file path" }) end, { desc = "Yank absolute file path" })
-- buffer -- buffers
map("n", "<leader>x", function() map("n", "<leader>x", function()
local buf = vim.api.nvim_get_current_buf() local buf = vim.api.nvim_get_current_buf()
if vim.bo[buf].modified then if vim.bo[buf].modified then
@ -75,7 +77,6 @@ map("n", "<leader>x", function()
end end
end, { desc = "Close current buffer" }) end, { desc = "Close current buffer" })
map("n", "<leader>bn", "<cmd>enew<CR>", { desc = "Buffer new" }) map("n", "<leader>bn", "<cmd>enew<CR>", { desc = "Buffer new" })
map("n", "<leader>bo", function() map("n", "<leader>bo", function()
local current = vim.api.nvim_get_current_buf() local current = vim.api.nvim_get_current_buf()
local skipped_ft = { "NvimTree", "oil", "aerial" } local skipped_ft = { "NvimTree", "oil", "aerial" }

View File

@ -30,13 +30,16 @@ vim.opt.completeopt = "menuone,noselect,fuzzy,nosort"
vim.opt.shortmess:append("c") vim.opt.shortmess:append("c")
vim.opt.clipboard:append("unnamedplus") vim.opt.clipboard:append("unnamedplus")
vim.opt.isfname:append("@-@") vim.opt.isfname:append("@-@")
vim.opt.guicursor = ""
vim.opt.scrolloff = 8 vim.opt.scrolloff = 8
vim.opt.colorcolumn = "0" vim.opt.colorcolumn = "0"
vim.opt.signcolumn = "yes" vim.opt.signcolumn = "yes"
vim.opt.termguicolors = true vim.opt.termguicolors = true
vim.api.nvim_set_hl(0, "MiniDiffSignAdd", { link = "DiffAdd" })
vim.api.nvim_set_hl(0, "MiniDiffSignChange", { link = "DiffChange" })
vim.api.nvim_set_hl(0, "MiniDiffSignDelete", { link = "DiffDelete" })
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text", desc = "Highlight when yanking (copying) text",
callback = function() callback = function()

View File

@ -126,6 +126,10 @@ end)
lazy.on_event("diff", "BufReadPost", "*", function() lazy.on_event("diff", "BufReadPost", "*", function()
require("mini.diff").setup({ require("mini.diff").setup({
source = require("mini.diff").gen_source.git({ index = false }), source = require("mini.diff").gen_source.git({ index = false }),
view = {
style = "sign",
signs = { add = "", change = "", delete = "" },
},
mappings = { mappings = {
apply = "gs", apply = "gs",
textobject = "", textobject = "",