From a7b411e639eaaf6ec1f651292a884f15f3703a97 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 2 Nov 2021 17:39:52 +0100 Subject: vim: update init.lua --- .vim/init.lua | 79 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 22 deletions(-) (limited to '.vim/init.lua') diff --git a/.vim/init.lua b/.vim/init.lua index f7e5363..a3d7487 100644 --- a/.vim/init.lua +++ b/.vim/init.lua @@ -16,43 +16,67 @@ opt.backspace = 'indent,eol,start' opt.clipboard:prepend { 'unnamedplus' } opt.cmdheight = 1 opt.colorcolumn = {80} -- depends on 'textwidth' -opt.complete = '.,w,b,u' -opt.completeopt = 'menuone,noselect' +-- opt.complete = '.,w,b,u' +opt.completeopt = {'menu','menuone','noinsert'} opt.concealcursor = '' opt.conceallevel = 2 opt.cursorline = true opt.expandtab = true opt.exrc = true opt.fillchars = 'fold:─' -opt.foldenable = false -opt.foldlevel = 0 +opt.foldenable = true +-- opt.foldlevel = 0 +opt.foldlevelstart = 1 opt.hidden = true +opt.hlsearch = false +opt.ignorecase = true opt.inccommand = 'split' opt.incsearch = true opt.laststatus = 2 opt.lazyredraw = true opt.list = true -opt.listchars:append { trail = '¬', tab = '> ' } +opt.listchars:append { trail = '¬', tab = '> ' } -- space/lead = '⋅' } opt.mouse = 'a' opt.number = true +opt.pumheight = 0 -- use available screenspace +opt.redrawtime = 1500 opt.ruler = true opt.scrolloff = 3 opt.shiftround = true opt.shortmess:append { c = true } +opt.breakindent = true +opt.breakindentopt = { shift = 2 } opt.showbreak = '↪ ' opt.showcmd = false opt.showmode = true -opt.signcolumn = 'auto:1' +opt.showmatch = true +opt.signcolumn = 'auto' opt.smartcase = true opt.spell = false opt.spelloptions = 'camel' opt.statusline = '%!luaeval("statusline()")' opt.termguicolors = true opt.textwidth = 0 +opt.timeoutlen = 400 opt.title = true +opt.ttimeoutlen = 10 opt.undolevels = 1000 -opt.updatetime = 300 +opt.updatetime = 200 opt.wrap = true + +-- configure :grep to use ripgrep if it's available +if vim.fn.executable('rg') then + vim.opt.grepprg = 'rg --vimgrep --smart-case --hidden' + vim.opt.grepformat = '%f:%l:%c:%m' +end + +-- persistent undo +local undodir = vim.fn.stdpath('cache') .. '/undodir_' .. vim.env.USER +if vim.fn.isdirectory(undodir) == 0 then + vim.fn.mkdir(undodir, 'p', '0700') +end +vim.g.undodir = undodir +vim.opt.undofile = true -- }}} -- COLORS -- {{{ @@ -68,7 +92,14 @@ local tnoremap = require('astronauta.keymap').tnoremap nnoremap { 'Q', function() cmd [[ quitall ]] end, silent = false } nnoremap { 'gb', function() cmd [[ bnext ]] end } nnoremap { 'gB', function() cmd [[ bprevious ]] end } -nnoremap { '', function() cmd [[ silent! normal za ]] end } +nnoremap { '', function() cmd [[ exe 'normal zA' | IndentBlanklineRefresh ]] end } + +-- nnoremap { '{', [[ {zz ]] } +-- nnoremap { '}', [[ }zz ]] } +vim.cmd [[nnoremap c "_c]] +vim.cmd [[nnoremap C "_C]] +vim.cmd [[vnoremap c "_c]] +vim.cmd [[vnoremap C "_C]] tnoremap { '', [[ ]] } tnoremap { 'qq', [[ :bdelete! ]] } @@ -86,20 +117,30 @@ nnoremap { 'gs', function() misc.word_under_cursor(function(s) vim.fn.feedkeys( -- AUTO GROUPS -- {{{ augroup { - yank_highlight = {{'TextYankPost', '*', [[ silent! lua require("vim.highlight").on_yank() ]]}}, + yank_highlight = { + {'TextYankPost', '*', [[ silent! lua require("vim.highlight").on_yank() ]]} + }, obvious_active_win = { - {'WinEnter', '*', 'set cul'}, - {'WinLeave', '*', 'set nocul'} + {'WinEnter', '*', [[ set cul ]]}, + {'WinLeave', '*', [[ set nocul ]]} }, - c_makeprg = {{'BufRead', '*.c', [[ set makeprg=ninja\ -C\ build ]]}}, - open_qf = {{'QuickFixCmdPost', '*', [[ :clist ]]}}, - packer_auto_compile = {{'BufWritePost', 'plugins.lua', [[ PackerCompile ]]}}, + c_makeprg = { + {'VimEnter', '*.c', [[ setlocal makeprg=ninja\ -C\ build ]]} + }, + open_qf = { + {'QuickFixCmdPost', '*', [[ :clist ]]} + }, + -- packer_auto_compile = {{'BufWritePost', 'plugins.lua', [[ PackerCompile ]]}}, commentstring = { {'FileType', 'i3config', [[ setlocal commentstring=#\ %s ]]}, {'FileType', 'jsonc', [[ setlocal commentstring=//\ %s ]]}, }, - foldenable = { - {'VimEnter', '.vim/*', [[setlocal foldenable]]}, + folds = { + {'VimEnter', '.vim/*', [[ setlocal foldenable ]]}, + {'FileType', 'json,jsonc,yaml,toml', [[ setlocal nofoldenable ]]}, + }, + help_quit = { + {'FileType', 'help', [[ nnoremap q bdel ]]} } } -- }}} @@ -178,9 +219,3 @@ local local_vimrc = vim.fn.getcwd()..'/.nvimrc' if vim.loop.fs_stat(local_vimrc) then cmd('source ' .. local_vimrc) end - --- configure :grep to use ripgrep if it's available -if vim.fn.executable('rg') then - vim.opt.grepprg = 'rg --vimgrep --smart-case --hidden' - vim.opt.grepformat = '%f:%l:%c:%m' -end -- cgit 1.4.1