From 33fe27fd3dfbe21cf1ca9b4ab2b9c960e0ef9dd4 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 20 Aug 2023 23:38:05 +0300 Subject: nvim: nvim-ufo, bunch of fixes --- .config/nvim/lua/core/keymaps.lua | 19 ++++---- .config/nvim/lua/core/options.lua | 97 +++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 57 deletions(-) (limited to '.config/nvim/lua/core') 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" edit!' map("n", "Q", "gq", "format lines") -- set formatprg to sentences, for prose --- TODO: can we do this with vim.o.formatprg? -map("n", "fp", "set formatprg=~/.local/bin/sentences", "switch to sentences view", { silent = false }) +map("n", "fp", ":set formatprg=~/.local/bin/sentences", "switch to sentences formatprg", { silent = false }) -- replace all is aliased to S. -map("n", "S", ":s//g", "replace all", { silent = false }) -map("v", "S", ":s//g", "replace all selection", { silent = false }) +map("n", "S", ":%s//g", "replace all", { silent = false }) +map("v", "S", ":s//g", "replace all", { silent = false }) -- jump to buffer map("n", "b", "ls:b", "jump to buffer") @@ -42,16 +41,16 @@ map("n", "cd", "lcd %:p:h:pwd", "cd to current buffer's pwd -- call CreatePaper on word below cursor map("n", "np", 'gewi[[/papers/Ea]]bb:call CreatePaper(expand(""))', - "vimwiki new paper on word under cursor") + "vimwiki: new paper on word under cursor") -- link paper -map("n", "lp", "gewi[[/papers/Ea]]", "vimwiki link wrap word under cursor") +map("n", "lp", "gewi[[/papers/Ea]]", "vimwiki: link wrap word under cursor") -- call CreateReference on word below cursor -map("n", "nr", 'call CreateReference(expand(""))', "vimwiki new reference word under cursor") +map("n", "nr", 'call CreateReference(expand(""))', "vimwiki: new reference word under cursor") -- create a new note -map("n", "nn", "call CreateNote()", "vimwiki new note for slipbox") +map("n", "nn", "call CreateNote()", "vimwiki: new note for slipbox") -- :%% to get current file path map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) @@ -67,6 +66,10 @@ map('v', 'Y', 'myY`y') -- ` is more useful than ' map('n', "'", '`') +-- keep cursor in the middle while doing search +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + -- switch between light and dark modes map("n", "ut", function() 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 @@ local opts = { - -- this might not be needed anymore - termguicolors = true, + -- this might not be needed anymore + termguicolors = true, - -- copy indent on a new line - autoindent = true, + -- copy indent on a new line + autoindent = true, - -- :h tabstop, 2. point - -- use appropriate number of spaces to insert a - expandtab = true, - shiftwidth = 4, - softtabstop = 4, - tabstop = 8, + -- :h tabstop, 2. point + -- use appropriate number of spaces to insert a + expandtab = true, + shiftwidth = 4, + softtabstop = 4, + tabstop = 8, - -- use english for spellchecking - spelllang = "en_gb", + -- use english for spellchecking + spelllang = "en_gb", - -- tab completion, zsh style - wildmode = "longest:full,full", + -- tab completion, zsh style + wildmode = "longest:full,full", - -- put one space for join (not two) - joinspaces = false, + -- put one space for join (not two) + joinspaces = false, - -- keep n lines above/below cursor while scrolling - scrolloff = 4, + -- keep n lines above/below cursor while scrolling + scrolloff = 4, - -- line numbers - number = true, + -- line numbers + number = true, - -- manual folding - foldmethod = "marker", + -- manual folding + foldcolumn = "0", + foldlevel = 99, + foldlevelstart = 99, + foldenable = true, - -- set the terminal title - title = true, + -- set the terminal title + title = true, - -- wrap using 'breakat' character - linebreak = true, + -- wrap using 'breakat' character + linebreak = true, - -- new split panes will split to below and right - splitbelow = true, - splitright = true, + -- new split panes will split to below and right + splitbelow = true, + splitright = true, - -- use relative line numbers - relativenumber = true, + -- use relative line numbers + relativenumber = true, - -- we are already using a cursorline, don't clobber linter messages - showmode = false, + -- we are already using a cursorline, don't clobber linter messages + showmode = false, - -- jump to the matching bracket briefly - showmatch = true, + -- jump to the matching bracket briefly + showmatch = true, - -- persistent undo - undofile = true, + -- persistent undo + undofile = true, - -- lower case searches ignore case, upper case searches do not - ignorecase = true, - smartcase = true, + -- lower case searches ignore case, upper case searches do not + ignorecase = true, + smartcase = true, - -- https://stackoverflow.com/a/3445040/ - -- switch case labels - cinoptions = "l1", + -- https://stackoverflow.com/a/3445040/ + -- switch case labels + cinoptions = "l1", } for opt, val in pairs(opts) do - vim.o[opt] = val + vim.o[opt] = val end --- set other options --- local colorscheme = require("helpers.colorscheme") --- vim.cmd.colorscheme(colorscheme) - -- interact with system clipboard vim.opt.clipboard:append('unnamedplus') @@ -90,7 +89,7 @@ vim.opt.diffopt = { -- menu: use a popup menu to show the possible completions -- preview: show extra information -vim.opt.completeopt = {"menu", "menuone", "noselect"} +vim.opt.completeopt = { "menu", "menuone", "noselect" } if vim.fn.executable("rg") then vim.o.grepprg = "rg --vimgrep --no-heading --smart-case" -- cgit v1.2.3-70-g09d2