-- ┌────────────────────────┐ -- │ ▗ │ -- │▛▚▀▖▝▀▖▛▀▖▛▀▖▄ ▛▀▖▞▀▌▞▀▘│ -- │▌▐ ▌▞▀▌▙▄▘▙▄▘▐ ▌ ▌▚▄▌▝▀▖│ -- │▘▝ ▘▝▀▘▌ ▌ ▀▘▘ ▘▗▄▘▀▀ │ -- └────────────────────────┘ -- 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', ':cd %: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()') -- plug mappings {{{1 -- -- 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)') -- insert mode completion plugmap('i', '', '(fzf-complete-word)') plugmap('i', '', '(fzf-complete-path)') plugmap('i', '', '(fzf-complete-line)') -- 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') -- 1}}} --