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.)
*.factor text eol=lf
*.html text eol=lf
+misc/vim/ftplugin/factor.vim linguist-generated
-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
--- /dev/null
+" Vim filetype plugin file\r
+" Language: Factor (documentation)\r
+" Maintainer: Tim Allen <screwtape@froup.com>\r
+" Last Change: 2020 May 29\r
+\r
+" Documentation lines can be any length of characters.\r
+setlocal textwidth=0\r
+augroup factorTextWidth\r
+ au!\r
+augroup END\r
" 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:#!