diff options
Diffstat (limited to '.config/nvim/lua/core')
-rw-r--r-- | .config/nvim/lua/core/keymaps.lua | 19 | ||||
-rw-r--r-- | .config/nvim/lua/core/options.lua | 97 |
2 files changed, 59 insertions, 57 deletions
diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index b63156d..95e5fcd 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua | |||
@@ -12,12 +12,11 @@ map("c", "w!!", 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!<CR>' | |||
12 | map("n", "Q", "gq", "format lines") | 12 | map("n", "Q", "gq", "format lines") |
13 | 13 | ||
14 | -- set formatprg to sentences, for prose | 14 | -- set formatprg to sentences, for prose |
15 | -- TODO: can we do this with vim.o.formatprg? | 15 | map("n", "<Leader>fp", ":set formatprg=~/.local/bin/sentences<CR>", "switch to sentences formatprg", { silent = false }) |
16 | map("n", "<Leader>fp", "<cmd>set formatprg=~/.local/bin/sentences<CR>", "switch to sentences view", { silent = false }) | ||
17 | 16 | ||
18 | -- replace all is aliased to S. | 17 | -- replace all is aliased to S. |
19 | map("n", "S", ":s//g<Left><Left>", "replace all", { silent = false }) | 18 | map("n", "<leader>S", ":%s//g<Left><Left>", "replace all", { silent = false }) |
20 | map("v", "S", ":s//g<Left><Left>", "replace all selection", { silent = false }) | 19 | map("v", "<leader>S", ":s//g<Left><Left>", "replace all", { silent = false }) |
21 | 20 | ||
22 | -- jump to buffer | 21 | -- jump to buffer |
23 | map("n", "<Leader>b", "<cmd>ls<cr>:b<space>", "jump to buffer") | 22 | map("n", "<Leader>b", "<cmd>ls<cr>:b<space>", "jump to buffer") |
@@ -42,16 +41,16 @@ map("n", "<Leader>cd", "<cmd>lcd %:p:h<CR>:pwd<CR>", "cd to current buffer's pwd | |||
42 | 41 | ||
43 | -- call CreatePaper on word below cursor | 42 | -- call CreatePaper on word below cursor |
44 | map("n", "<leader>np", 'gewi[[/papers/<ESC>Ea]]<ESC>bb:call CreatePaper(expand("<cword>"))<CR>', | 43 | map("n", "<leader>np", 'gewi[[/papers/<ESC>Ea]]<ESC>bb:call CreatePaper(expand("<cword>"))<CR>', |
45 | "vimwiki new paper on word under cursor") | 44 | "vimwiki: new paper on word under cursor") |
46 | 45 | ||
47 | -- link paper | 46 | -- link paper |
48 | map("n", "<leader>lp", "gewi[[/papers/<ESC>Ea]]<ESC>", "vimwiki link wrap word under cursor") | 47 | map("n", "<leader>lp", "gewi[[/papers/<ESC>Ea]]<ESC>", "vimwiki: link wrap word under cursor") |
49 | 48 | ||
50 | -- call CreateReference on word below cursor | 49 | -- call CreateReference on word below cursor |
51 | map("n", "<leader>nr", '<cmd>call CreateReference(expand("<cword>"))<CR>', "vimwiki new reference word under cursor") | 50 | map("n", "<leader>nr", '<cmd>call CreateReference(expand("<cword>"))<CR>', "vimwiki: new reference word under cursor") |
52 | 51 | ||
53 | -- create a new note | 52 | -- create a new note |
54 | map("n", "<leader>nn", "<cmd>call CreateNote()<CR>", "vimwiki new note for slipbox") | 53 | map("n", "<leader>nn", "<cmd>call CreateNote()<CR>", "vimwiki: new note for slipbox") |
55 | 54 | ||
56 | -- :%% to get current file path | 55 | -- :%% to get current file path |
57 | map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) | 56 | map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) |
@@ -67,6 +66,10 @@ map('v', 'Y', 'myY`y') | |||
67 | -- ` is more useful than ' | 66 | -- ` is more useful than ' |
68 | map('n', "'", '`') | 67 | map('n', "'", '`') |
69 | 68 | ||
69 | -- keep cursor in the middle while doing search | ||
70 | map("n", "n", "nzzzv") | ||
71 | map("n", "N", "Nzzzv") | ||
72 | |||
70 | -- switch between light and dark modes | 73 | -- switch between light and dark modes |
71 | map("n", "<leader>ut", function() | 74 | map("n", "<leader>ut", function() |
72 | if vim.o.background == "dark" then | 75 | if vim.o.background == "dark" then |
diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua index 3299e83..1a45b8f 100644 --- a/.config/nvim/lua/core/options.lua +++ b/.config/nvim/lua/core/options.lua | |||
@@ -1,75 +1,74 @@ | |||
1 | local opts = { | 1 | local opts = { |
2 | -- this might not be needed anymore | 2 | -- this might not be needed anymore |
3 | termguicolors = true, | 3 | termguicolors = true, |
4 | 4 | ||
5 | -- copy indent on a new line | 5 | -- copy indent on a new line |
6 | autoindent = true, | 6 | autoindent = true, |
7 | 7 | ||
8 | -- :h tabstop, 2. point | 8 | -- :h tabstop, 2. point |
9 | -- use appropriate number of spaces to insert a <Tab> | 9 | -- use appropriate number of spaces to insert a <Tab> |
10 | expandtab = true, | 10 | expandtab = true, |
11 | shiftwidth = 4, | 11 | shiftwidth = 4, |
12 | softtabstop = 4, | 12 | softtabstop = 4, |
13 | tabstop = 8, | 13 | tabstop = 8, |
14 | 14 | ||
15 | -- use english for spellchecking | 15 | -- use english for spellchecking |
16 | spelllang = "en_gb", | 16 | spelllang = "en_gb", |
17 | 17 | ||
18 | -- tab completion, zsh style | 18 | -- tab completion, zsh style |
19 | wildmode = "longest:full,full", | 19 | wildmode = "longest:full,full", |
20 | 20 | ||
21 | -- put one space for join (not two) | 21 | -- put one space for join (not two) |
22 | joinspaces = false, | 22 | joinspaces = false, |
23 | 23 | ||
24 | -- keep n lines above/below cursor while scrolling | 24 | -- keep n lines above/below cursor while scrolling |
25 | scrolloff = 4, | 25 | scrolloff = 4, |
26 | 26 | ||
27 | -- line numbers | 27 | -- line numbers |
28 | number = true, | 28 | number = true, |
29 | 29 | ||
30 | -- manual folding | 30 | -- manual folding |
31 | foldmethod = "marker", | 31 | foldcolumn = "0", |
32 | foldlevel = 99, | ||
33 | foldlevelstart = 99, | ||
34 | foldenable = true, | ||
32 | 35 | ||
33 | -- set the terminal title | 36 | -- set the terminal title |
34 | title = true, | 37 | title = true, |
35 | 38 | ||
36 | -- wrap using 'breakat' character | 39 | -- wrap using 'breakat' character |
37 | linebreak = true, | 40 | linebreak = true, |
38 | 41 | ||
39 | -- new split panes will split to below and right | 42 | -- new split panes will split to below and right |
40 | splitbelow = true, | 43 | splitbelow = true, |
41 | splitright = true, | 44 | splitright = true, |
42 | 45 | ||
43 | -- use relative line numbers | 46 | -- use relative line numbers |
44 | relativenumber = true, | 47 | relativenumber = true, |
45 | 48 | ||
46 | -- we are already using a cursorline, don't clobber linter messages | 49 | -- we are already using a cursorline, don't clobber linter messages |
47 | showmode = false, | 50 | showmode = false, |
48 | 51 | ||
49 | -- jump to the matching bracket briefly | 52 | -- jump to the matching bracket briefly |
50 | showmatch = true, | 53 | showmatch = true, |
51 | 54 | ||
52 | -- persistent undo | 55 | -- persistent undo |
53 | undofile = true, | 56 | undofile = true, |
54 | 57 | ||
55 | -- lower case searches ignore case, upper case searches do not | 58 | -- lower case searches ignore case, upper case searches do not |
56 | ignorecase = true, | 59 | ignorecase = true, |
57 | smartcase = true, | 60 | smartcase = true, |
58 | 61 | ||
59 | -- https://stackoverflow.com/a/3445040/ | 62 | -- https://stackoverflow.com/a/3445040/ |
60 | -- switch case labels | 63 | -- switch case labels |
61 | cinoptions = "l1", | 64 | cinoptions = "l1", |
62 | 65 | ||
63 | } | 66 | } |
64 | 67 | ||
65 | for opt, val in pairs(opts) do | 68 | for opt, val in pairs(opts) do |
66 | vim.o[opt] = val | 69 | vim.o[opt] = val |
67 | end | 70 | end |
68 | 71 | ||
69 | -- set other options | ||
70 | -- local colorscheme = require("helpers.colorscheme") | ||
71 | -- vim.cmd.colorscheme(colorscheme) | ||
72 | |||
73 | -- interact with system clipboard | 72 | -- interact with system clipboard |
74 | vim.opt.clipboard:append('unnamedplus') | 73 | vim.opt.clipboard:append('unnamedplus') |
75 | 74 | ||
@@ -90,7 +89,7 @@ vim.opt.diffopt = { | |||
90 | 89 | ||
91 | -- menu: use a popup menu to show the possible completions | 90 | -- menu: use a popup menu to show the possible completions |
92 | -- preview: show extra information | 91 | -- preview: show extra information |
93 | vim.opt.completeopt = {"menu", "menuone", "noselect"} | 92 | vim.opt.completeopt = { "menu", "menuone", "noselect" } |
94 | 93 | ||
95 | if vim.fn.executable("rg") then | 94 | if vim.fn.executable("rg") then |
96 | vim.o.grepprg = "rg --vimgrep --no-heading --smart-case" | 95 | vim.o.grepprg = "rg --vimgrep --no-heading --smart-case" |