Hello,

Kamil Kisiel <[EMAIL PROTECTED]> 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?


On sourceforge, there are two plugins (both named local_vimrc) that load
vimrc-like files which are specific to hierarchies of directories -- I'm
maintaining one of them.

This solution is a little bit less coupled than the second one Tony gave you.
Understand that you can rename your project directories, copy/share definitions
between several projects, ...
However, the definitions are not specific to a particular filetype. I.e. in
order to have your new syntax highlightings only in C++ files, but not in
Makefiles, you will have to guard the definitions according to the filetype of
the current buffer.

Regarding the syntax resets and colorscheme changes, it should be possible to
define to local vimrc like this (not tested):

" ------------------ >% -----------------
" File: $HOME/projects/foo/_vimrc_local.vim
"
" Global definitions, loaded every time

.... global variables, some resets, ...

" Buffer definitions, loaded once per buffer
if exists('b:loaded_project_foo_local_vimrc') | finish | endif
let b:loaded_project_foo_local_vimrc = 1

... buffer- -local_variables, -mappings, -abbreviations, -commands

" Global definitions, loaded once
if exists('g:loaded_project_foo_local_vimrc') | finish | endif
let g:loaded_project_foo_local_vimrc = 1

augroup FooSyntax
  au!
  au ColorScheme * call s:ResetSyntax() " not sure about this one
  au Syntax      * call s:ResetSyntax()
augroup END

function! s:ResetSyntax()
  if &ft =~ 'cpp\|^c$'
    syn ....
    hl ....
  endif
endfunction

... other functions defintions
" ------------------ >% -----------------

NB: the lastest version of the local_vimrc plugin I'm maintaining can be found
there:
http://hermitte.free.fr/vim/ressources/vimfiles/plugin/local_vimrc.vim

The plugin Project can also help you solve your problem.

HTH,

--
Luc Hermitte

Reply via email to