local nmap = require("config.mappings").nmap local xmap = require("config.mappings").xmap local vmap = require("config.mappings").vmap local tmap = require("config.mappings").tmap local imap = require("config.mappings").imap -- Unmap keys vim.keymap.set("", "", "") nmap("Q", "") nmap("", "") nmap("", "") nmap("", "") nmap("", "") nmap("", "") nmap("v", "") nmap("p", "") nmap("J", "mzJ`z") nmap("", "zz") nmap("", "zz") nmap("n", "nzzzv") nmap("N", "Nzzzv") nmap("*", "*zz") nmap("#", "#zz") nmap("g*", "g*zz") nmap("g#", "g#zz") vim.keymap.set("n", ";", ";", { silent = false }) vim.keymap.set({ "n" }, "j", "gj", { desc = "Allows to navigate though wrapped lines", noremap = true }) vim.keymap.set({ "n" }, "k", "gk", { desc = "Allows to navigate though wrapped lines", noremap = true }) nmap("", "resize -2", "Resize window up") nmap("", "resize +2", "Resize window down") nmap("", "vertical resize -2", "Resize window left") nmap("", "vertical resize +2", "Resize window right") -- nmap("", "!tmux neww tmux-sessionizer", "Open tmux sessionizer") nmap("", "m .-2==", "Move line up") nmap("", "m .+1==", "Move line down") -- nmap("", ":%s///gI", "[S]ubstitute word") nmap("", [[:%s/\<\>//gI]], "[S]ubstitute word") nmap("Q", "@qj", "Run macro") nmap("oo", "updatesource", "Source current file") vim.keymap.set({ "n", "v", "x" }, "y", '"+y', { desc = "Yank to system clipboard" }) vim.keymap.set("n", "Y", '"+yy', { desc = "Yank line to system clipboard" }) vim.keymap.set({ "n", "v", "x" }, "d", '"+d', { desc = "Cut to system clipboard" }) vim.keymap.set({ "n", "v", "x" }, "p", '"+p', { desc = "Paste from system clipboard" }) vim.keymap.set("n", "P", '"+P', { desc = "Paste before cursor from system clipboard" }) vim.keymap.set("n", "cf", function() local file_path = vim.fn.expand("%:p") vim.cmd([[call setreg("+", "]] .. vim.fn.escape(file_path, '\\ "') .. '")') print("Copied current file path to clipboard: " .. vim.fn.expand("%:p")) end, { desc = "Copy file path to clipboard" }) xmap("Q", ":norm @q", "Run macro") xmap("p", '"_dP') vim.keymap.set( "c", "", 'pumvisible() ? "\\" : "\\"', { expr = true, noremap = true, desc = "Prev command" } ) vim.keymap.set( "c", "", 'pumvisible() ? "\\" : "\\"', { expr = true, noremap = true, desc = "Next command" } ) vmap(">", ">gv", "Right Indent") vmap("<", "", ":m '<-2gv=gv", "Move lines up") vmap("", ":m '>+1gv=gv", "Move lines down") -- tmap("t", "", "h") -- tmap("t", "", "j") -- tmap("t", "", "k") -- tmap("t", "", "l") local function fzf_sesh_connect() -- build the fzf-tmux command exactly as in your zsh widget local fzf_cmd = [[ sesh list --icons | fzf-tmux -p 80%,70% \ --no-sort --ansi \ --border-label ' sesh ' \ --prompt '⚡ ' \ --header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \ --bind 'tab:down,btab:up' \ --bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list --icons)' \ --bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t --icons)' \ --bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list -c --icons)' \ --bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z --icons)' \ --bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \ --bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \ --preview-window 'right:55%' \ --preview 'sesh preview {}' ]] -- spawn fzf-tmux, read its output local handle = io.popen(fzf_cmd) if not handle then vim.notify("Failed to launch fzf-tmux", vim.log.levels.ERROR) return end local session = handle:read("*a") handle:close() -- trim trailing newline/whitespace session = session:gsub("%s+$", "") if session == "" then -- user cancelled or no selection return end -- execute the tmux connect command -- opens a shell command in the current Neovim window vim.cmd('!sesh connect "' .. session .. '"') end -- bind in Normal mode to our function nmap("", fzf_sesh_connect)