diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-09-11 21:11:53 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-09-11 21:11:53 +0200 |
| commit | a9347a8d6783b360d0e4481151944b0f961404d9 (patch) | |
| tree | b61a5e6beb4d150449ecf004a7e4a6099f4917dc /.config/nvim/autoload/utils.vim | |
| parent | fd1646bb0d8bca44f263717ec63268947af1386c (diff) | |
| parent | 38ec7c480730e3f83322fa34a6a4ff700ca503d9 (diff) | |
| download | dotfiles-a9347a8d6783b360d0e4481151944b0f961404d9.tar.gz dotfiles-a9347a8d6783b360d0e4481151944b0f961404d9.zip | |
Merge commit '9489548bca74468976436df44134e4aeb40e8548'
Diffstat (limited to '.config/nvim/autoload/utils.vim')
| -rw-r--r-- | .config/nvim/autoload/utils.vim | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/.config/nvim/autoload/utils.vim b/.config/nvim/autoload/utils.vim index d244e90..f11a769 100644 --- a/.config/nvim/autoload/utils.vim +++ b/.config/nvim/autoload/utils.vim @@ -57,7 +57,7 @@ endfunction " Toggle statusline let s:hidden_all = 0 -function! ToggleHiddenAll() +function! utils#ToggleHiddenAll() if s:hidden_all == 0 let s:hidden_all = 1 set noshowmode @@ -148,3 +148,64 @@ endfunction "------------------------------------------------- + +" Disable annoying auto line break +fu! utils#DisableBr() + set wrap + set linebreak + set nolist " list disables linebreak + set textwidth=0 + set wrapmargin=0 + set formatoptions-=t +endfu + +" Disable line breaks for all file types +autocmd! BufNewFile,BufRead *.* call utils#DisableBr() + + +"------------------------------------------------- + +" Annoying timestamp issue on write (The file has been changed since reading it...) +"function! utils#ProcessFileChangedShell() +" if v:fcs_reason == 'mode' || v:fcs_reason == 'time' +" let v:fcs_choice = '' +" else +" let v:fcs_choice = 'ask' +" endif +"endfunction +"autocmd FileChangedShell <buffer> call utils#ProcessFileChangedShell() +" +"let lastline = line('$') +"let bufcontents = getline(1, lastline) +"edit! +"call setline(1, bufcontents) +"if line('$') > lastline +" execute lastline+1.',$:d _' +"endif + +" Annoying timestamp issue on write (The file has been changed since reading it...) +function! utils#ProcessFileChangedShell() + if v:fcs_reason == 'mode' || v:fcs_reason == 'time' + let v:fcs_choice = '' + else + let v:fcs_choice = 'ask' + endif +endfunction + +" Triggered when the file is changed externally +autocmd FileChangedShell <buffer> call utils#ProcessFileChangedShell() + +" Triggered before writing the buffer to the file +autocmd BufWritePre <buffer> call utils#BeforeWrite() + +function! utils#BeforeWrite() + let lastline = line('$') + let bufcontents = getline(1, lastline) + edit! + call setline(1, bufcontents) + if line('$') > lastline + execute lastline+1.',$:d _' + endif +endfunction + +"------------------------------------------------- |
