diff options
author | Yigit Sever | 2021-11-02 15:25:21 +0300 |
---|---|---|
committer | Yigit Sever | 2021-11-02 15:25:21 +0300 |
commit | 81764d44f86917a38744f22a8c494be3589ae995 (patch) | |
tree | 7cd87770e2e15036fa49aa2ca473dfa06e074c99 | |
parent | 0ee0b219d4f7bd235043d262e41d517f3c5a507e (diff) | |
download | dotfiles-81764d44f86917a38744f22a8c494be3589ae995.tar.gz dotfiles-81764d44f86917a38744f22a8c494be3589ae995.tar.bz2 dotfiles-81764d44f86917a38744f22a8c494be3589ae995.zip |
nvim: mapping fixes
-rw-r--r-- | .config/nvim/lua/mappings.lua | 22 | ||||
-rw-r--r-- | .config/nvim/lua/settings.lua | 2 |
2 files changed, 17 insertions, 7 deletions
diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index df7e3d3..ad40879 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua | |||
@@ -39,16 +39,17 @@ map('n', '*', ':keepjumps normal! mi*`i<CR>') | |||
39 | map('n', '#', ':keepjumps normal! mi#`i<CR> ') | 39 | map('n', '#', ':keepjumps normal! mi#`i<CR> ') |
40 | 40 | ||
41 | -- save file as sudo on files that require root permission | 41 | -- save file as sudo on files that require root permission |
42 | map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!<CR>') | 42 | map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!<CR>', { silent = false }) |
43 | 43 | ||
44 | -- replace ex mode with gq (format lines) | 44 | -- replace ex mode with gq (format lines) |
45 | map('n', 'Q', 'gq') | 45 | map('n', 'Q', 'gq') |
46 | 46 | ||
47 | -- set formatprg to sentences, for prose | 47 | -- set formatprg to sentences, for prose |
48 | map('n', '<Leader>fp', ":set formatprg=~/.local/bin/sentences<CR>") | 48 | map('n', '<Leader>fp', ":set formatprg=~/.local/bin/sentences<CR>", { silent = false }) |
49 | 49 | ||
50 | -- replace all is aliased to S. | 50 | -- replace all is aliased to S. |
51 | map('n', 'S', ':%s//g<Left><Left>') | 51 | map('n', 'S', ':%s//g<Left><Left>', { silent = false }) |
52 | map('v', 'S', ':s//g<Left><Left>', { silent = false }) | ||
52 | 53 | ||
53 | -- if you like "Y" to work from the cursor to the end of line (which is more | 54 | -- if you like "Y" to work from the cursor to the end of line (which is more |
54 | -- logical, but not Vi-compatible) | 55 | -- logical, but not Vi-compatible) |
@@ -58,8 +59,8 @@ map('n', 'Y', 'y$', { noremap = false }) | |||
58 | map('n', '<Leader>b', ':ls<cr>:b<space>') | 59 | map('n', '<Leader>b', ':ls<cr>:b<space>') |
59 | 60 | ||
60 | -- up and down are more logical with g.. | 61 | -- up and down are more logical with g.. |
61 | map('n', 'k', 'gk') | 62 | map('n', 'k', '(v:count == 0 ? "gk" : "k")', { expr = true }) |
62 | map('n', 'j', 'gj') | 63 | map('n', 'j', '(v:count == 0 ? "gj" : "j")', { expr = true }) |
63 | map('i', '<Up>', '<Esc>gka') | 64 | map('i', '<Up>', '<Esc>gka') |
64 | map('i', '<Down>', '<Esc>gja') | 65 | map('i', '<Down>', '<Esc>gja') |
65 | 66 | ||
@@ -92,7 +93,16 @@ map('n', '<leader>nr', ':call CreateReference(expand("<cword>"))<CR>') | |||
92 | -- create a new note | 93 | -- create a new note |
93 | map('n', '<leader>nn', ':call CreateNote()<CR>') | 94 | map('n', '<leader>nn', ':call CreateNote()<CR>') |
94 | 95 | ||
95 | vim.cmd("cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'") | 96 | -- :%% to get current file path |
97 | map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", { expr = true, silent = false }) | ||
98 | |||
99 | -- reselect visual selection after indent | ||
100 | map('v', '>', '>gv') | ||
101 | map('v', '<', '<gv') | ||
102 | |||
103 | -- keep cursor position after visual yank | ||
104 | map('v', 'y', 'myy`y') | ||
105 | map('v', 'Y', 'myY`y') | ||
96 | 106 | ||
97 | -- plug mappings {{{ -- | 107 | -- plug mappings {{{ -- |
98 | 108 | ||
diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 34e68b2..895d6d9 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua | |||
@@ -35,7 +35,7 @@ bo.spelllang = "en_gb" | |||
35 | wo.spell = false | 35 | wo.spell = false |
36 | 36 | ||
37 | -- tab completion, zsh style | 37 | -- tab completion, zsh style |
38 | o.wildmode = "full" | 38 | o.wildmode = "longest:full,full" |
39 | opt.wildignore = { | 39 | opt.wildignore = { |
40 | '*.o', '*.obj', '*.class', '*.aux', '*.lof', '*.log', '*.lot', '*.fls', | 40 | '*.o', '*.obj', '*.class', '*.aux', '*.lof', '*.log', '*.lot', '*.fls', |
41 | '*.toc', '*.fmt', '*.fot', '*.cb', '*.cb2', '.*.lb', '.dvi', '*.xdv', | 41 | '*.toc', '*.fmt', '*.fot', '*.cb', '*.cb2', '.*.lb', '.dvi', '*.xdv', |