diff options
| author | Yigit Sever | 2021-10-08 00:09:37 +0300 |
|---|---|---|
| committer | Yigit Sever | 2021-10-08 00:09:37 +0300 |
| commit | a8903ac96dd7cd0e1af968d729e557d579f26124 (patch) | |
| tree | afe2c89a0fbc1b0bfe79dd1b9ea9d7050f83fc08 /.config/nvim/lua/mappings.lua | |
| parent | 82bc7c109cd3890b3494d88f7ead43c3aa3e7860 (diff) | |
| download | dotfiles-a8903ac96dd7cd0e1af968d729e557d579f26124.tar.gz dotfiles-a8903ac96dd7cd0e1af968d729e557d579f26124.tar.bz2 dotfiles-a8903ac96dd7cd0e1af968d729e557d579f26124.zip | |
neovim: migrate to init.lua
Diffstat (limited to '.config/nvim/lua/mappings.lua')
| -rw-r--r-- | .config/nvim/lua/mappings.lua | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..fe59a99 --- /dev/null +++ b/.config/nvim/lua/mappings.lua | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | -- ┌──────────────────┐ | ||
| 2 | -- │ ▗ │ | ||
| 3 | -- │▛▀▖▞▀▖▞▀▖▌ ▌▄ ▛▚▀▖│ | ||
| 4 | -- │▌ ▌▛▀ ▌ ▌▐▐ ▐ ▌▐ ▌│ | ||
| 5 | -- │▘ ▘▝▀▘▝▀ ▘ ▀▘▘▝ ▘│ | ||
| 6 | -- └──────────────────┘ | ||
| 7 | -- ┌────────────────────────┐ | ||
| 8 | -- │ ▗ │ | ||
| 9 | -- │▛▚▀▖▝▀▖▛▀▖▛▀▖▄ ▛▀▖▞▀▌▞▀▘│ | ||
| 10 | -- │▌▐ ▌▞▀▌▙▄▘▙▄▘▐ ▌ ▌▚▄▌▝▀▖│ | ||
| 11 | -- │▘▝ ▘▝▀▘▌ ▌ ▀▘▘ ▘▗▄▘▀▀ │ | ||
| 12 | -- └────────────────────────┘ | ||
| 13 | |||
| 14 | -- map helper | ||
| 15 | local function map(mode, lhs, rhs, opts) | ||
| 16 | local options = {noremap = true, silent = true} | ||
| 17 | if opts then options = vim.tbl_extend('force', options, opts) end | ||
| 18 | vim.api.nvim_set_keymap(mode, lhs, rhs, options) | ||
| 19 | end | ||
| 20 | |||
| 21 | -- local map = vim.api.nvim_set_keymap | ||
| 22 | local cmd = vim.cmd | ||
| 23 | local M = {} | ||
| 24 | |||
| 25 | -- brute force deasciify everything | ||
| 26 | map('n', '<Leader>tc', 'TurkishDeasciifyForce()', {expr = true}) | ||
| 27 | map('x', '<Leader>tc', 'TurkishDeasciifyForce()', {expr = true}) | ||
| 28 | map('n', '<Leader>tctc', "TurkishDeasciifyForce() .. '_'", {expr = true}) | ||
| 29 | |||
| 30 | -- use turkish-mode to selectively deasciify | ||
| 31 | map('n', '<Leader>tr', 'TurkishDeasciify()', {expr = true}) | ||
| 32 | map('x', '<Leader>tr', 'TurkishDeasciify()', {expr = true}) | ||
| 33 | map('n', '<Leader>trtr', "TurkishDeasciify() .. '_'", {expr = true}) | ||
| 34 | |||
| 35 | -- ascii everything | ||
| 36 | map('n', '<Leader>rt', 'TurkishAsciify()', {expr = true}) | ||
| 37 | map('x', '<Leader>rt', 'TurkishAsciify()', {expr = true}) | ||
| 38 | map('n', '<Leader>rtrt', "TurkishAsciify() .. '_'", {expr = true}) | ||
| 39 | |||
| 40 | -- https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump | ||
| 41 | -- search & highlight but do not jump | ||
| 42 | map('n', '*', ':keepjumps normal! mi*`i<CR>') | ||
| 43 | map('n', '#', ':keepjumps normal! mi#`i<CR> ') | ||
| 44 | |||
| 45 | -- Save file as sudo on files that require root permission | ||
| 46 | map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!') | ||
| 47 | |||
| 48 | -- replace ex mode with gq (format lines) | ||
| 49 | map('n', 'Q', 'gq') | ||
| 50 | |||
| 51 | -- set formatprg to sentences, for prose | ||
| 52 | map('n', '<Leader>fp', ":set formatprg=~/.local/bin/sentences<CR>") | ||
| 53 | |||
| 54 | -- Replace all is aliased to S. | ||
| 55 | map('n', 'S', ':%s//g<Left><Left>') | ||
| 56 | |||
| 57 | -- If you like "Y" to work from the cursor to the end of line (which is more | ||
| 58 | -- logical, but not Vi-compatible) | ||
| 59 | map('n', 'Y', 'y$') | ||
| 60 | |||
| 61 | -- jump to buffer | ||
| 62 | map('n', '<Leader>b', ':ls<cr>:b<space>') | ||
| 63 | |||
| 64 | -- Up and down are more logical with g.. | ||
| 65 | map('n', 'k', 'gk') | ||
| 66 | map('n', 'j', 'gj') | ||
| 67 | map('i', '<Up>', '<Esc>gka') | ||
| 68 | map('i', '<Down>', '<Esc>gja') | ||
| 69 | |||
| 70 | -- Disable highlight when <leader><cr> is pressed | ||
| 71 | map('n', '<Leader><Cr>', ':noh<Cr>') | ||
| 72 | -- Space used to toggle folds, now it's x (because x is d) | ||
| 73 | map('n', '<Space>', '"_x') | ||
| 74 | |||
| 75 | -- separate cut and delete | ||
| 76 | map('n', 'x', 'd') | ||
| 77 | map('x', 'x', 'd') | ||
| 78 | map('n', 'xx', 'dd') | ||
| 79 | map('n', 'X', 'D') | ||
| 80 | |||
| 81 | -- change into pwd of current directory | ||
| 82 | map('n', '<Leader>cd', ':cd %:p:h<CR>:pwd<CR>') | ||
| 83 | |||
| 84 | -- press \g and start writing prose | ||
| 85 | map('n', '<Leader>g', ':Goyo<CR>') | ||
| 86 | |||
| 87 | -- plug mappings {{{1 -- | ||
| 88 | |||
| 89 | -- <Plug> mappings should not be noremap | ||
| 90 | -- https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/ | ||
| 91 | local function plugmap(mode, lhs, rhs, opts) | ||
| 92 | local options = {noremap = false, silent = true} | ||
| 93 | if opts then options = vim.tbl_extend('force', options, opts) end | ||
| 94 | vim.api.nvim_set_keymap(mode, lhs, rhs, options) | ||
| 95 | end | ||
| 96 | |||
| 97 | -- sneak using grave, s is for sandwich | ||
| 98 | plugmap('n', '`', '<Plug>Sneak_s') | ||
| 99 | plugmap('n', '`', '<Plug>Sneak_s') | ||
| 100 | plugmap('n', '<Leader>`', '<Plug>Sneak_S') | ||
| 101 | plugmap('n', "'", '`') | ||
| 102 | |||
| 103 | -- use the special yoink paste that rotates | ||
| 104 | plugmap('n', 'p', '<Plug>(YoinkPaste_p)') | ||
| 105 | plugmap('n', 'P', '<Plug>(YoinkPaste_P)') | ||
| 106 | |||
| 107 | -- substitute from yank | ||
| 108 | plugmap('n', '<Leader>ys', '<plug>(SubversiveSubstitute)') | ||
| 109 | plugmap('n', '<Leader>yss', '<plug>(SubversiveSubstituteLine)') | ||
| 110 | plugmap('n', '<Leader>yS', '<plug>(SubversiveSubstituteToEndOfLine)') | ||
| 111 | |||
| 112 | -- substitute over range | ||
| 113 | plugmap('n', '<Leader>s', '<plug>(SubversiveSubstituteRange)') | ||
| 114 | plugmap('x', '<Leader>s', '<plug>(SubversiveSubstituteRange)') | ||
| 115 | plugmap('n', '<Leader>ss', '<plug>(SubversiveSubstituteWordRange)') | ||
| 116 | |||
| 117 | -- subvert over range | ||
| 118 | plugmap('n', '<Leader><Leader>s', '<plug>(SubversiveSubvertRange)') | ||
| 119 | plugmap('x', '<Leader><Leader>s', '<plug>(SubversiveSubvertRange)') | ||
| 120 | plugmap('n', '<Leader><Leader>ss', '<plug>(SubversiveSubvertWordRange)') | ||
| 121 | |||
| 122 | -- iterate over yank list | ||
| 123 | plugmap('n', '<c-n>', '<Plug>(YoinkPostPasteSwapBack)') | ||
| 124 | plugmap('n', '<c-p>', '<Plug>(YoinkPostPasteSwapForward)') | ||
| 125 | |||
| 126 | -- insert mode completion | ||
| 127 | plugmap('i', '<c-x><c-k>', '<plug>(fzf-complete-word)') | ||
| 128 | plugmap('i', '<c-x><c-f>', '<plug>(fzf-complete-path)') | ||
| 129 | plugmap('i', '<c-x><c-l>', '<plug>(fzf-complete-line)') | ||
| 130 | |||
| 131 | -- 1}}} -- | ||
