summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/mappings.lua
diff options
context:
space:
mode:
authorYigit Sever2021-10-08 00:09:37 +0300
committerYigit Sever2021-10-08 00:09:37 +0300
commita8903ac96dd7cd0e1af968d729e557d579f26124 (patch)
treeafe2c89a0fbc1b0bfe79dd1b9ea9d7050f83fc08 /.config/nvim/lua/mappings.lua
parent82bc7c109cd3890b3494d88f7ead43c3aa3e7860 (diff)
downloaddotfiles-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.lua131
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
15local 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)
19end
20
21-- local map = vim.api.nvim_set_keymap
22local cmd = vim.cmd
23local M = {}
24
25-- brute force deasciify everything
26map('n', '<Leader>tc', 'TurkishDeasciifyForce()', {expr = true})
27map('x', '<Leader>tc', 'TurkishDeasciifyForce()', {expr = true})
28map('n', '<Leader>tctc', "TurkishDeasciifyForce() .. '_'", {expr = true})
29
30-- use turkish-mode to selectively deasciify
31map('n', '<Leader>tr', 'TurkishDeasciify()', {expr = true})
32map('x', '<Leader>tr', 'TurkishDeasciify()', {expr = true})
33map('n', '<Leader>trtr', "TurkishDeasciify() .. '_'", {expr = true})
34
35-- ascii everything
36map('n', '<Leader>rt', 'TurkishAsciify()', {expr = true})
37map('x', '<Leader>rt', 'TurkishAsciify()', {expr = true})
38map('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
42map('n', '*', ':keepjumps normal! mi*`i<CR>')
43map('n', '#', ':keepjumps normal! mi#`i<CR> ')
44
45-- Save file as sudo on files that require root permission
46map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!')
47
48-- replace ex mode with gq (format lines)
49map('n', 'Q', 'gq')
50
51-- set formatprg to sentences, for prose
52map('n', '<Leader>fp', ":set formatprg=~/.local/bin/sentences<CR>")
53
54-- Replace all is aliased to S.
55map('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)
59map('n', 'Y', 'y$')
60
61-- jump to buffer
62map('n', '<Leader>b', ':ls<cr>:b<space>')
63
64-- Up and down are more logical with g..
65map('n', 'k', 'gk')
66map('n', 'j', 'gj')
67map('i', '<Up>', '<Esc>gka')
68map('i', '<Down>', '<Esc>gja')
69
70-- Disable highlight when <leader><cr> is pressed
71map('n', '<Leader><Cr>', ':noh<Cr>')
72-- Space used to toggle folds, now it's x (because x is d)
73map('n', '<Space>', '"_x')
74
75-- separate cut and delete
76map('n', 'x', 'd')
77map('x', 'x', 'd')
78map('n', 'xx', 'dd')
79map('n', 'X', 'D')
80
81-- change into pwd of current directory
82map('n', '<Leader>cd', ':cd %:p:h<CR>:pwd<CR>')
83
84-- press \g and start writing prose
85map('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/
91local 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)
95end
96
97-- sneak using grave, s is for sandwich
98plugmap('n', '`', '<Plug>Sneak_s')
99plugmap('n', '`', '<Plug>Sneak_s')
100plugmap('n', '<Leader>`', '<Plug>Sneak_S')
101plugmap('n', "'", '`')
102
103-- use the special yoink paste that rotates
104plugmap('n', 'p', '<Plug>(YoinkPaste_p)')
105plugmap('n', 'P', '<Plug>(YoinkPaste_P)')
106
107-- substitute from yank
108plugmap('n', '<Leader>ys', '<plug>(SubversiveSubstitute)')
109plugmap('n', '<Leader>yss', '<plug>(SubversiveSubstituteLine)')
110plugmap('n', '<Leader>yS', '<plug>(SubversiveSubstituteToEndOfLine)')
111
112-- substitute over range
113plugmap('n', '<Leader>s', '<plug>(SubversiveSubstituteRange)')
114plugmap('x', '<Leader>s', '<plug>(SubversiveSubstituteRange)')
115plugmap('n', '<Leader>ss', '<plug>(SubversiveSubstituteWordRange)')
116
117-- subvert over range
118plugmap('n', '<Leader><Leader>s', '<plug>(SubversiveSubvertRange)')
119plugmap('x', '<Leader><Leader>s', '<plug>(SubversiveSubvertRange)')
120plugmap('n', '<Leader><Leader>ss', '<plug>(SubversiveSubvertWordRange)')
121
122-- iterate over yank list
123plugmap('n', '<c-n>', '<Plug>(YoinkPostPasteSwapBack)')
124plugmap('n', '<c-p>', '<Plug>(YoinkPostPasteSwapForward)')
125
126-- insert mode completion
127plugmap('i', '<c-x><c-k>', '<plug>(fzf-complete-word)')
128plugmap('i', '<c-x><c-f>', '<plug>(fzf-complete-path)')
129plugmap('i', '<c-x><c-l>', '<plug>(fzf-complete-line)')
130
131-- 1}}} --