-- ┌────────────────────────┐ -- │ ▗ │ -- │▛▚▀▖▝▀▖▛▀▖▛▀▖▄ ▛▀▖▞▀▌▞▀▘│ -- │▌▐ ▌▞▀▌▙▄▘▙▄▘▐ ▌ ▌▚▄▌▝▀▖│ -- │▘▝ ▘▝▀▘▌ ▌ ▀▘▘ ▘▗▄▘▀▀ │ -- └────────────────────────┘ -- map helper local function map(mode, lhs, rhs, opts) local options = {noremap = true, silent = true} if opts then options = vim.tbl_extend('force', options, opts) end vim.api.nvim_set_keymap(mode, lhs, rhs, options) end -- local map = vim.api.nvim_set_keymap local cmd = vim.cmd local M = {} -- edit vimrc \ev map('n', 'ev', ':tabnew:e ~/.config/nvim/init.lua') -- brute force deasciify everything map('n', 'tc', 'TurkishDeasciifyForce()', {expr = true}) map('x', 'tc', 'TurkishDeasciifyForce()', {expr = true}) map('n', 'tctc', "TurkishDeasciifyForce() .. '_'", {expr = true}) -- use turkish-mode to selectively deasciify map('n', 'tr', 'TurkishDeasciify()', {expr = true}) map('x', 'tr', 'TurkishDeasciify()', {expr = true}) map('n', 'trtr', "TurkishDeasciify() .. '_'", {expr = true}) -- ascii everything map('n', 'rt', 'TurkishAsciify()', {expr = true}) map('x', 'rt', 'TurkishAsciify()', {expr = true}) map('n', 'rtrt', "TurkishAsciify() .. '_'", {expr = true}) -- https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump -- search & highlight but do not jump map('n', '*', ':keepjumps normal! mi*`i') map('n', '#', ':keepjumps normal! mi#`i ') -- save file as sudo on files that require root permission map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" edit!') -- replace ex mode with gq (format lines) map('n', 'Q', 'gq') -- set formatprg to sentences, for prose map('n', 'fp', ":set formatprg=~/.local/bin/sentences") -- replace all is aliased to S. map('n', 'S', ':%s//g') -- if you like "Y" to work from the cursor to the end of line (which is more -- logical, but not Vi-compatible) map('n', 'Y', 'y$') -- jump to buffer map('n', 'b', ':ls:b') -- up and down are more logical with g.. map('n', 'k', 'gk') map('n', 'j', 'gj') map('i', '', 'gka') map('i', '', 'gja') -- disable highlight when is pressed map('n', '', ':noh') -- space used to toggle folds, now it's x (because x is d) map('n', '', '"_x') -- separate cut and delete map('n', 'x', 'd') map('x', 'x', 'd') map('n', 'xx', 'dd') map('n', 'X', 'D') -- change into pwd of current directory map('n', 'cd', ':lcd %:p:h:pwd') -- press \g and start writing prose map('n', 'g', ':Goyo') -- call CreatePaper on word below cursor map('n', 'np', 'gewi[[/papers/Ea]]bb:call CreatePaper(expand(""))') -- link paper map('n', 'lp', 'gewi[[/papers/Ea]]') -- call CreateReference on word below cursor map('n', 'nr', ':call CreateReference(expand(""))') -- create a new note map('n', 'nn', ':call CreateNote()') vim.cmd("cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'") -- plug mappings {{{ -- -- mappings should not be noremap -- https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/ local function plugmap(mode, lhs, rhs, opts) local options = {noremap = false, silent = true} if opts then options = vim.tbl_extend('force', options, opts) end vim.api.nvim_set_keymap(mode, lhs, rhs, options) end -- open the TagBar Plugin plugmap('n', '', ':TagbarToggle') -- sneak using grave, s is for sandwich plugmap('n', '`', 'Sneak_s') plugmap('n', '`', 'Sneak_s') plugmap('n', '`', 'Sneak_S') plugmap('n', "'", '`') -- use the special yoink paste that rotates plugmap('n', 'p', '(YoinkPaste_p)') plugmap('n', 'P', '(YoinkPaste_P)') -- substitute from yank plugmap('n', 'ys', '(SubversiveSubstitute)') plugmap('n', 'yss', '(SubversiveSubstituteLine)') plugmap('n', 'yS', '(SubversiveSubstituteToEndOfLine)') -- substitute over range plugmap('n', 's', '(SubversiveSubstituteRange)') plugmap('x', 's', '(SubversiveSubstituteRange)') plugmap('n', 'ss', '(SubversiveSubstituteWordRange)') -- subvert over range plugmap('n', 's', '(SubversiveSubvertRange)') plugmap('x', 's', '(SubversiveSubvertRange)') plugmap('n', 'ss', '(SubversiveSubvertWordRange)') -- iterate over yank list plugmap('n', '', '(YoinkPostPasteSwapBack)') plugmap('n', '', '(YoinkPostPasteSwapForward)') -- checkmarks on vimwiki plugmap('n', 'v', 'VimwikiToggleListItem') -- add/increase header level plugmap('n', 'a', 'VimwikiAddHeaderLevel') -- vim-test bindings map('n', 't', ':TestNearest') map('n', 't', ':TestFile') map('n', 't', ':TestSuite') map('n', 't', ':TestLast') map('n', 't', ':TestVisit') -- telescope bindings map('n', 'ff', "lua require('telescope.builtin').find_files()") map('n', 'fg', "lua require('telescope.builtin').live_grep()") map('n', 'fb', "lua require('telescope.builtin').buffers()") map('n', 'fh', "lua require('telescope.builtin').help_tags()") -- vista map('n', '', ":Vista focus") map('n', '', ":Vista finder") map('n', 'fh', ':DashboardFindHistory') map('n', 'ff', ':DashboardFindFile') map('n', 'fa', ':DashboardFindWord') map('n', 'fb', ':DashboardJumpMark') map('n', 'cn', ':DashboardNewFile') -- }}} plug mappings --