[misc] vim: Hygenic text width highlights
This lets Factor's overly long line highlighting avoid bleeding over into documentation source buffers, or buffers of other non-Factor file types entirely. Also, by taking `:2match` instead of `:match`, clobbering of most user matches (or vice versa) can be avoided. Unfortunately, the highlighting effects all windows in a multi-buffer split setup, but since we can't reasonably make this a `:syntax match` group, it'll have to do. (And this behavior isn't new.)master
parent
35681032d9
commit
710b54869a
|
@ -1,2 +1,3 @@
|
|||
*.factor text eol=lf
|
||||
*.html text eol=lf
|
||||
misc/vim/ftplugin/factor.vim linguist-generated
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
autocmd BufRead,BufNewFile *.factor,{,.}factor*-rc set filetype=factor
|
||||
" autocmd BufRead,BufNewFile *.factor setf factor " upstreamed
|
||||
autocmd BufRead,BufNewFile {,.}factor*-rc setf factor
|
||||
autocmd BufRead,BufNewFile *-docs.factor set ft=factor.factor-docs
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: Factor (documentation)
|
||||
" Maintainer: Tim Allen <screwtape@froup.com>
|
||||
" Last Change: 2020 May 29
|
||||
|
||||
" Documentation lines can be any length of characters.
|
||||
setlocal textwidth=0
|
||||
augroup factorTextWidth
|
||||
au!
|
||||
augroup END
|
|
@ -15,14 +15,13 @@ let b:did_ftplugin = 1
|
|||
" Tabs are not allowed in Factor source files; use four spaces instead.
|
||||
setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
" Try to limit lines to 64 characters, except for documentation, which can be
|
||||
" any length.
|
||||
if expand("%:t") !~ "-docs\.factor$"
|
||||
setlocal textwidth=64
|
||||
|
||||
" Mark anything in column 64 or beyond as a syntax error.
|
||||
match Error /\%>63v.\+/
|
||||
endif
|
||||
" Try to limit lines to 64 characters.
|
||||
setlocal textwidth=64
|
||||
augroup factorTextWidth
|
||||
au!
|
||||
au BufEnter <buffer> 2match Error /\%>64v.\+/
|
||||
au BufLeave <buffer> 2match none
|
||||
augroup END
|
||||
|
||||
" Teach Vim what comments look like.
|
||||
setlocal comments+=b:!,b:#!
|
||||
|
|
Loading…
Reference in New Issue