-- Global mappings migrated from the original init.vim. -- Load after setting vim.g.mapleader = " " and after defining required commands. -- Plugin-owned mappings (LSP, Gitsigns, Tree-sitter, Trouble) remain in their setup files. vim.g.mapleader = vim.g.mapleader or " " local map = vim.keymap.set local all = { "n", "x", "s", "o" } -- Vimscript :noremap modes local function find_in_dir() local dir = vim.fn.resolve(vim.fn.expand("%:p:h")) require("telescope.builtin").find_files({ search_dirs = { dir }, path_display = { "shorten" }, hidden = true, }) end local function shift_char(delta) local pos = vim.api.nvim_win_get_cursor(0) local line = vim.api.nvim_get_current_line() local col = pos[2] + 1 local char_index = vim.fn.strchars(line:sub(1, col - 1)) local char = vim.fn.strcharpart(line, char_index, 1) if char == "" then return end local code = vim.fn.char2nr(char) local replacement = vim.fn.nr2char(code + delta) vim.api.nvim_set_current_line(line:sub(1, col - 1) .. replacement .. line:sub(col + #char)) end vim.go.operatorfunc = "v:lua.JumpToLastChange" _G.JumpToLastChange = function() vim.cmd.normal({ "`[", bang = true }) end map(all, "g.", "set operatorfunc=v:lua.JumpToLastChangeg@", { silent = true }) map(all, "%", "v") map(all, "\"", "s") map(all, "", "sterm") map(all, "", "sTERM") map(all, "Y", "y$") map("x", "ú", ":FormatLines") map(all, "ú", "lua run_format_code()") map(all, "p", "(SynStack)") map(all, "ff", "Telescope find_files") map(all, "", "Telescope find_files") map(all, "", "Telescope find_files") map(all, "", find_in_dir) map("i", "", "(vsnip-expand)") map(all, "^", "^zH") map(all, "to", "Telescope oldfiles") map(all, "ta", "Telescope autocommands") map(all, "tbu", "Telescope buffers") map(all, "T", "Telescope builtin") map(all, "tcs", "Telescope colorscheme") map(all, "tch", "Telescope command_history") map(all, "tco", "Telescope commands") map(all, "t/", "Telescope current_buffer_fuzzy_find") map(all, "tcbt", "Telescope current_buffer_tags") map(all, "td", "Telescope diagnostics") map(all, "tf", "Telescope find_files") map(all, "tgb", "Telescope git_branches") map(all, "tgc", "Telescope git_commits") map(all, "tgf", "Telescope git_files") map(all, "tgs", "Telescope git_stash") map(all, "tgr", "Telescope grep_string") map(all, "thi", "Telescope highlights") map(all, "tjl", "Telescope jumplist") map(all, "tlg", "Telescope live_grep") map(all, "tll", "Telescope loclist") map(all, "t[d", "Telescope lsp_definitions") map(all, "t[s", "Telescope lsp_document_symbols") map(all, "t[w", "Telescope lsp_dynamic_workspace_symbols") map(all, "t[i", "Telescope lsp_implementations") map(all, "t[r", "Telescope lsp_incoming_calls") map(all, "t[n", "Telescope lsp_outgoing_calls") map(all, "t[e", "Telescope lsp_references") map(all, "t[t", "Telescope lsp_type_definitions") map(all, "t?", "Telescope man_pages") map(all, "t'", "Telescope marks") map(all, "tp", "Telescope pickers") map(all, "tqf", "Telescope quickfix") map(all, "tqh", "Telescope quickfixhistory") map(all, "t\"", "Telescope registers") map(all, "th/", "Telescope search_history") map(all, "tz", "Telescope spell_suggest") map(all, "ty", "Telescope symbols") map(all, "tt", "Telescope tags") map(all, "tst", "Telescope tagstack") map(all, "tsit", "Telescope treesitter") map(all, "tv", "Telescope vim_options") map("n", "n", "set hlsearchn", { silent = true }) map("n", "N", "set hlsearchN", { silent = true }) map(all, "nt", "NvimTreeToggle") map(all, "", [[:e =escape(expand('%:h'), ' \')/]]) map(all, ".", "lua require('windownav').goto_terminal()") map(all, "I", "lua require('windownav').goto_initvim()") map(all, "'", "lua require('windownav').goto_lastwin()") map("n", "", "termstartinsert") map("n", "", "TERMstartinsert") map("n", "", "") map("n", "", "Telescope buffers") map("n", "", "bnext") map("n", "", "bprev") map(all, "", "lua vim.diagnostic.open_float()") map(all, "", "WarpFull") map(all, "", "WarpGrid") map("o", "", "vWarpGrid") map(all, "w", "WarpWords") map("o", "w", "vWarpWords") map(all, "", [[/\%V]]) -- Original mapping (encoded as Ctrl-_) map("n", "œ", "k", { remap = true }) map("n", "ï", "j", { remap = true }) map("o", "œ", "k", { remap = true }) map("o", "ï", "j", { remap = true }) map("o", "aœ", "ak", { remap = true }) map("o", "aï", "aj", { remap = true }) map("o", "iœ", "ik", { remap = true }) map("o", "iï", "ij", { remap = true }) map("x", "œ", "k", { remap = true }) map("x", "ï", "j", { remap = true }) map(all, "", "TSNodeUnderCursor") map(all, "", "TSCaptureUnderCursor") map(all, "Τ", "Inspect") map(all, "g[r", "Telescope lsp_references path_display={\"shorten\"}") map(all, "g[d", "Telescope lsp_definitions path_display={\"shorten\"}") map(all, "g[i", "Telescope lsp_implementations path_display={\"shorten\"}") map(all, "g[td", "Telescope lsp_type_definitions path_display={\"shorten\"}") map(all, "g[ci", "Telescope lsp_incoming_calls path_display={\"shorten\"}") map(all, "g[co", "Telescope lsp_outgoing_calls path_display={\"shorten\"}") map(all, "g[sd", "Telescope lsp_document_symbols path_display={\"shorten\"}") map(all, "g[sw", "Telescope lsp_workspace_symbols path_display={\"shorten\"}") map(all, "g[sdw", "Telescope lsp_dynamic_workspace_symbols path_display={\"shorten\"}") map(all, "[e", "lua vim.diagnostic.jump({count=-1, severity=vim.diagnostic.severity.ERROR})") map(all, "]e", "lua vim.diagnostic.jump({count=1, severity=vim.diagnostic.severity.ERROR})") map(all, "α", function() shift_char(1) end) map(all, "Α", function() shift_char(-1) end) map(all, "€", "viba)") map(all, "", "") map(all, "<2-X2Mouse>", "") map(all, "<3-X2Mouse>", "") map(all, "", "") map(all, "<2-X1Mouse>", "") map(all, "<3-X1Mouse>", "") map(all, "", "") map(all, "", "Telescope tags") map(all, "gh", "HopCamelCase")