Kamil Kisiel wrote:
I would like to define keywords for syntax highlighting that are
specific to a particular project. For example, when using some
third-party API there are often frequently used keywords that I'd like
to highlight when using that API. What's the best way to set this up
with Vim, and to have the settings load automatically whenever I edit
files from that project?
Since you are specifying practically nothing, I shall assume that the
files in question are of filetype foo, of filename *.foo, and that the
files "from that project" are distinguished by being anywhere in
directory ~/bar or its subdirectories to any depth.
I suggest the following (untested):
create ~/.vim/after/syntax/foo.vim (on Unix) or
~/vimfiles/after/syntax/foo.vim (on Windows) (and create any needed
directories), as follows (or similar):
" supplementary syntax for foo-type files of project bar
if expand('%:p') !~ '^' . fnamemodify(expand('~/bar'),':p')
" current file is not of this project --
" nothing to do
finish
endif
" define additional keywords
sy keyword MyKeywords blah blahblah foobarbaz
" use «:hi default» to avoid conflict with a possible colorscheme
" which we might write at any future time
hi default MyKeywords ctermbg=cyan ctermfg=white guibg=#99FFFF
Best regards,
Tony.