changeset 691:989cedcc0a38

chore: remove config.vim
author zegervdv <zegervdv@me.com>
date Wed, 05 Oct 2022 09:52:29 +0200
parents 424764c7f51a
children 4b289d175d89
files .chezmoiremove .chezmoitemplates/config.vim .chezmoitemplates/init.lua dot_config/nvim/plugin/config.vim.tmpl
diffstat 4 files changed, 27 insertions(+), 130 deletions(-) [+]
line wrap: on
line diff
--- /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
--- 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 <C-h> <C-\><C-n><C-w>h
-"   tnoremap <C-j> <C-\><C-n><C-w>j
-"   tnoremap <C-k> <C-\><C-n><C-w>k
-"   tnoremap <C-l> <C-\><C-n><C-w>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 "\<CR>:b"
-    elseif cmdline =~ '\v\C/(#|nu|num|numb|numbe|number)$'
-        " like :g//# but prompts for a command
-        return "\<CR>:"
-    elseif cmdline =~ '\v\C^(dli|il)'
-        " like :dlist or :ilist but prompts for a count for :djump or :ijump
-        return "\<CR>:" . cmdline[0] . "j  " . split(cmdline, " ")[1] . "\<S-Left>\<Left>"
-    elseif cmdline =~ '\v\C^(cli|lli)'
-        " like :clist or :llist but prompts for an error/location number
-        return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>"
-    elseif cmdline =~ '\C^old'
-        " like :oldfiles but prompts for an old file to edit
-        set nomore
-        return "\<CR>:sil se more|e #<"
-    elseif cmdline =~ '\C^changes'
-        " like :changes but prompts for a change to jump to
-        set nomore
-        return "\<CR>:sil se more|norm! g;\<S-Left>"
-    elseif cmdline =~ '\C^ju'
-        " like :jumps but prompts for a position to jump to
-        set nomore
-        return "\<CR>:sil se more|norm! \<C-o>\<S-Left>"
-    elseif cmdline =~ '\C^marks'
-        " like :marks but prompts for a mark to jump to
-        return "\<CR>:norm! `"
-    elseif cmdline =~ '\C^undol'
-        " like :undolist but prompts for a change to undo
-        return "\<CR>:u "
-    else
-        return "\<CR>"
-    endif
-endfunction
-" cnoremap <expr> <CR> 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
--- 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 %' },
--- 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" -}}