makefile - Vim: Restart Syntax Highlighting from Arbitrary Line -
i have discovered interesting edge-case in vim syntax highlighting. consider next snippet company makefile:
ldscript := $(subst ",,$(config_sys_ldscript))
the above line removes double quotes given ldscript
. nil syntactically wrong; create runs expected , without issue.
the problem
since above line contains 1 double quote, highlighting rules mistakenly think rest of body of makefile quoted text , colors such. simple makefiles, inconvenience; 1kloc+ makefiles, becomes real hassle (especially since preprocessing near top of file).
the question
is there way either disable syntax highlighting based on lines match given regular look (eg. subst[ \t]*['"],.*
) or similar? failing that, there way restart vim's highlighting @ arbitrary line while preserving highlights above?
if @ possible, avoid edits makefile script shared across number of departments.
i willing write / modify vimscript accomplish this, have not done before (to reasonable degree). tips, pointers or other helpful hints much appreciated.
what have tried
:syntax sync minlines=1 :syntax sync fromstart :syntax sync clear
none of above seems have effect on highlighting when run in editor. looking through vim help docs, seems :syn-sync-fourth
may able after, uncertain how function in inverse manner (eg. disable highlighting rather apply it).
i think best can add together additional syntax rule (in ~/.vim/after/syntax/make.vim
) match offending construct. seems work:
syn match makeignore /subst[ \t]*['"],,/ containedin=makeident
the containedin=
necessary because it's used in $(...)
construct.
vim makefile syntax-highlighting
No comments:
Post a Comment