VIM: colour column on textwidth or if not set col 80

This had to be done in a FileType * autocmd so that it is done once file
type has been determined and textwidth is set, as suggested by tae on
discord

7630218973
This commit is contained in:
Jonathan Hodgson 2020-10-06 14:28:50 +01:00
parent 9479b9574e
commit 9ba7608e66
2 changed files with 13 additions and 0 deletions

View file

@ -10,3 +10,11 @@ function! mine#functions#text() abort
inoremap <buffer> ; ;<C-g>u
inoremap <buffer> ? ?<C-g>u
endfunction
function! mine#functions#colorcols() abort
if &textwidth > 0
setlocal colorcolumn=+0
else
setlocal colorcolumn=80,100
endif
endfunction

View file

@ -43,3 +43,8 @@ let g:netrw_browsex_viewer = "opout"
set formatoptions+=r
" Automatically insert comment leader after hitting o or O
set formatoptions+=o
augroup colorcols
autocmd!
autocmd FileType,VimEnter,BufEnter * call mine#functions#colorcols()
augroup end