aboutsummaryrefslogtreecommitdiffstats
path: root/easytags.vim
blob: 31bf9d078d530429ee94897b65198fe2e0de58bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
" Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com>
" Last Change: June 6, 2010
" URL: http://peterodding.com/code/vim/easytags
" Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT
" Version: 1.6

" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip

" Don't source the plug-in when its already been loaded or &compatible is set.
if &cp || exists('g:loaded_easytags')
  finish
endif

" Configuration defaults. {{{1

if !exists('g:easytags_file')
  if has('win32') || has('win64')
    let g:easytags_file = '~/_vimtags'
  else
    let g:easytags_file = '~/.vimtags'
  endif
endif

if !exists('g:easytags_resolve_links')
  let g:easytags_resolve_links = 0
endif

if !exists('g:easytags_always_enabled')
  let g:easytags_always_enabled = 0
endif

if !exists('g:easytags_on_cursorhold')
  let g:easytags_on_cursorhold = 1
endif

" Before sourcing the rest of the plug-in first check that the location of the
" "Exuberant Ctags" program has been configured or that the program exists in
" one of its default locations.

if exists('g:easytags_cmd') && executable(g:easytags_cmd)
  let s:ctags_installed = 1
else
  " On Ubuntu Linux, Exuberant Ctags is installed as `ctags'. On Debian Linux,
  " Exuberant Ctags is installed as `exuberant-ctags'. On Free-BSD, Exuberant
  " Ctags is installed as `exctags'. Finally there is `ctags.exe' on Windows.
  for s:command in ['ctags', 'exuberant-ctags', 'esctags', 'ctags.exe']
    if executable(s:command)
      let g:easytags_cmd = s:command
      let s:ctags_installed = 1
      break
    endif
  endfor
endif

if !exists('s:ctags_installed')
  echomsg "easytags.vim: Exuberant Ctags unavailable! Plug-in not loaded."
  if executable('apt-get')
    echomsg "On Ubuntu & Debian Linux, you can install Exuberant Ctags"
    echomsg "by installing the package named `exuberant-ctags':"
    echomsg "  sudo apt-get install exuberant-ctags"
  else
    echomsg "Please download & install Exuberant Ctags from http://ctags.sf.net"
  endif
  finish
endif

" The :UpdateTags and :HighlightTags commands. {{{1

command! -bar -bang UpdateTags call easytags#update_cmd(<q-bang> == '!')
command! -bar HighlightTags call easytags#highlight_cmd()

" Automatic commands. {{{1

augroup PluginEasyTags
  autocmd!
  if g:easytags_always_enabled
    autocmd BufReadPost,BufWritePost * call easytags#autoload()
  endif
  if g:easytags_on_cursorhold
    autocmd CursorHold,CursorHoldI * call easytags#autoload()
  endif
  autocmd User PublishPre HighlightTags
augroup END

" }}}1

" Make sure the plug-in is only loaded once.
let g:loaded_easytags = 1

" vim: ts=2 sw=2 et