From 85f647fea444994eca583fad9047fa3b35347cdf Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Fri, 2 May 2025 18:37:01 +0300 Subject: Changed some keymaps/options from lazyvim --- .config/nvim/lua/keymaps.lua | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to '.config/nvim/lua/keymaps.lua') diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 86547a2..144b591 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -1,5 +1,4 @@ local set = vim.keymap.set -local silent = { silent = true } ---@param mode string|table ---@param keymap string local function unbind(mode, keymap) @@ -12,33 +11,18 @@ local function toggle_zen() vim.cmd('UndotreeHide') end -local function yank_filepath_to_clipboard(os) +local function yank_filepath_to_clipboard(absolute) return function() local filepath = vim.fn.expand('%:p') - -- TODO: simplify bcz idc about windows anymore - if os == 'linux' then + if not absolute then local home_dir = vim.fn.expand('~') filepath = filepath:gsub(home_dir, '~') - elseif os == 'windows' then - local mnt = '/mnt/' - if filepath:sub(1, #mnt) == mnt then - filepath = filepath:sub(#mnt + 1, #mnt + 1) .. ':' .. filepath:sub(#mnt + 2) - else - filepath = '//wsl.localhost/openSUSE-Tumbleweed' .. filepath - end - filepath = filepath:gsub('/', '\\') end vim.fn.setreg('+', filepath) end end -function RemoveClipboardCR() - local clipboard = vim.fn.getreg('+'):gsub('\r', '') - vim.fn.setreg('+', clipboard) -end - local function paste() - RemoveClipboardCR() local value = vim.fn.getreg('+') if vim.fn.mode() == 'c' then -- value = vim.split(value, '\n')[1] -- only use first line (default with normal pasting) @@ -67,22 +51,22 @@ set('v', '', ":m '<-2gv", { noremap = true }) -- Misc set({ 'n', 'i' }, '', 'ggVG', { desc = 'Visually Highlight [A]ll' }) set('i', '', '', { desc = 'Ctrl + Backspace to delete word' }) -set('n', '', 'nohlsearch', silent) +set('n', '', 'nohlsearch', { silent = true }) set({ 'i', 'c' }, '', paste) set('n', 'z', toggle_zen, { desc = '[Z]en Mode', silent = true }) +set('n', '', 'bprevious', { desc = 'Prev Buffer' }) +set('n', '', 'bnext', { desc = 'Next Buffer' }) +set('n', '', 'e #', { desc = 'Switch to Other Buffer' }) unbind({ 'i', 'n', 'v' }, '') set('n', 'U', 'redo') set('i', '', 'undo') set({ 'i', 'n', 'v' }, '', 'wqa') -set('n', 'yp', yank_filepath_to_clipboard('linux'), { desc = '[Y]oink File [P]ath (linux)' }) -set('n', 'yP', yank_filepath_to_clipboard('windows'), { desc = '[Y]oink File [P]ath (windows)' }) +set('n', 'yp', yank_filepath_to_clipboard(true), { desc = '[Y]oink File [P]ath (linux)' }) +set('n', 'yP', yank_filepath_to_clipboard(false), { desc = '[Y]oink File [P]ath (windows)' }) --- Window Navigation - NO NEED BECAUSE IT CONFLICTS WITH TMUX --- set('n', '', '', { desc = 'Move focus to the left window' }) --- set('n', '', '', { desc = 'Move focus to the down window' }) --- set('n', '', '', { desc = 'Move focus to the up window' }) --- set('n', '', '', { desc = 'Move focus to the right window' }) +-- Terminal +set('t', '', 'close', { desc = 'Hide Terminal' }) -- Window resizing local resize = 2 @@ -91,6 +75,13 @@ set({ 'n', 't' }, '', string.format('resize -%d', resize), { desc set({ 'n', 't' }, '', string.format('resize +%d', resize), { desc = 'Resize Down' }) set({ 'n', 't' }, '', string.format('vertical resize +%d', resize), { desc = 'Resize Right' }) +-- highlights under cursor +set('n', 'ui', vim.show_pos, { desc = 'Inspect Pos' }) +set('n', 'uI', function() + vim.treesitter.inspect_tree() + vim.api.nvim_input('I') +end, { desc = 'Inspect Tree' }) + -- Keep selection after < and > in visual mode set('v', '<', '', '>gv') -- cgit v1.3.1