# HG changeset patch # User zegervdv # Date 1664956349 -7200 # Node ID 989cedcc0a38eb8270f4370d1b83b96d96637361 # Parent 424764c7f51a1bfb7eb709b9ccc419e8f1ef2ee8 chore: remove config.vim diff -r 424764c7f51a -r 989cedcc0a38 .chezmoiremove --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.chezmoiremove Wed Oct 05 09:52:29 2022 +0200 @@ -0,0 +1,1 @@ +~/.config/nvim/plugin/config.vim diff -r 424764c7f51a -r 989cedcc0a38 .chezmoitemplates/config.vim --- a/.chezmoitemplates/config.vim Wed Oct 05 09:19:12 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -" vim:fdm=marker:ts=2:sw=2 - -let s:darwin = has('mac') -let s:windows = has('win32') - - -" Mappings - - - -" if has('nvim') -" tnoremap h -" tnoremap j -" tnoremap k -" tnoremap l -" augroup enter_term -" au! -" autocmd TermOpen * startinsert! -" autocmd BufEnter * if &buftype ==# 'terminal' | :startinsert! | endif -" autocmd BufLeave * if &buftype ==# 'terminal' | :stopinsert! | endif -" augroup END -" let $GIT_EDITOR = 'nvr -cc split --remote-wait' -" endif - -" - -" Functions -" When editing a file, always jump to the last known cursor position. -" Don't do it for commit messages, when the position is invalid, or when -" inside an event handler (happens when dropping a file on gvim). -autocmd BufReadPost * - \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | - \ endif - - -" Detect Filetype from content if file has no extension -augroup newFileDetection - au! - autocmd CursorMovedI * call CheckFileType() -augroup END - -function! CheckFileType() - if exists("b:countCheck") == 0 - let b:countCheck = 0 - endif - let b:countCheck += 1 - if &filetype == "" && b:countCheck > 20 && b:countCheck < 200 - filetype detect - " Delete the function if no filetype can be established, or the type has - " been found - elseif b:countCheck >= 200 || &filetype != "" - autocmd! newFileDetection - endif -endfunction -" - -" Make list-like commands more intuitive -" Copied from https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86 -function! CCR() - let cmdline = getcmdline() - if cmdline =~ '\v\C^(ls|files|buffers)' - " like :ls but prompts for a buffer command - return "\:b" - elseif cmdline =~ '\v\C/(#|nu|num|numb|numbe|number)$' - " like :g//# but prompts for a command - return "\:" - elseif cmdline =~ '\v\C^(dli|il)' - " like :dlist or :ilist but prompts for a count for :djump or :ijump - return "\:" . cmdline[0] . "j " . split(cmdline, " ")[1] . "\\" - elseif cmdline =~ '\v\C^(cli|lli)' - " like :clist or :llist but prompts for an error/location number - return "\:sil " . repeat(cmdline[0], 2) . "\" - elseif cmdline =~ '\C^old' - " like :oldfiles but prompts for an old file to edit - set nomore - return "\:sil se more|e #<" - elseif cmdline =~ '\C^changes' - " like :changes but prompts for a change to jump to - set nomore - return "\:sil se more|norm! g;\" - elseif cmdline =~ '\C^ju' - " like :jumps but prompts for a position to jump to - set nomore - return "\:sil se more|norm! \\" - elseif cmdline =~ '\C^marks' - " like :marks but prompts for a mark to jump to - return "\:norm! `" - elseif cmdline =~ '\C^undol' - " like :undolist but prompts for a change to undo - return "\:u " - else - return "\" - endif -endfunction -" cnoremap CCR() -" - -" Filetype specific settings -" Text -augroup ft_text - au! - " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb - au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0 -augroup END -augroup ft_report - au! - au BufNewFile,BufRead,BufEnter *.rpt setlocal nowrap - au BufNewFile,BufRead,BufEnter *.rpt call ColorRpt() - au BufNewFile,BufRead,BufEnter *.log call ColorRpt() -augroup END - -function! ColorRpt() - " Color numbers based on length - syn match String "\v<\d{1,3}>" - syn match Statement "\v<\d{4,6}>" - syn match Function "\v<\d{7,9}>" - - syn match Number "\v0+" - " Color errors - syn match Error "\v^ERROR:.*$" -endfunction -" - -" Plugin settings - -" -" Vinegar/NetRW -autocmd FileType netrw setl bufhidden=delete diff -r 424764c7f51a -r 989cedcc0a38 .chezmoitemplates/init.lua --- a/.chezmoitemplates/init.lua Wed Oct 05 09:19:12 2022 +0200 +++ b/.chezmoitemplates/init.lua Wed Oct 05 09:52:29 2022 +0200 @@ -984,6 +984,16 @@ if vim.o.diff then vim.cmd.diffupdate() end end +-- Open file at last position +au.BufReadPost = function() + if vim.bo.filetype ~= 'gitcommit' and vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then + vim.cmd.normal { 'g`"', bang = true } + end +end + +-- Remove netrw buffers +au.FileType = { 'netrw', 'setlocal bufhidden=delete' } + -- Terminal au.group('enter_term', { { 'TermOpen', '*', 'startinsert!' }, @@ -1003,6 +1013,22 @@ }, }) +-- Color number categories in reports and logs +au({ 'BufNewFile', 'BufRead', 'BufEnter' }, { + '*.rpt,*.log', + function() + vim.cmd.syntax { 'match', 'String', [["\v<\d{1,3}>"]] } + vim.cmd.syntax { 'match', 'Statement', [["\v<\d{4,6}>"]] } + vim.cmd.syntax { 'match', 'Function', [["\v<\d{7,9}>"]] } + + vim.cmd.syntax { 'match', 'Number', [["\v<0+>"]] } + + vim.cmd.syntax { 'match', 'Error', [["\v\c^error:"]] } + + vim.wo.wrap = false + end, +}) + -- Apply changes in chezmoi managed files au.group('chezmoi', { { 'BufWritePost', os.getenv 'HOME' .. '/.local/share/chezmoi/*', 'silent !chezmoi apply --source-path %' }, diff -r 424764c7f51a -r 989cedcc0a38 dot_config/nvim/plugin/config.vim.tmpl --- a/dot_config/nvim/plugin/config.vim.tmpl Wed Oct 05 09:19:12 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -{{- template "config.vim" -}}