gutentags.vim (4468B)
1 " gutentags.vim - Automatic ctags management for Vim 2 " Maintainer: Ludovic Chabant <http://ludovic.chabant.com> 3 " Version: 2.0.0 4 5 " Globals {{{ 6 7 if (&cp || get(g:, 'gutentags_dont_load', 0)) 8 finish 9 endif 10 11 if v:version < 704 12 echoerr "gutentags: this plugin requires vim >= 7.4." 13 finish 14 endif 15 16 if !(has('job') || (has('nvim') && exists('*jobwait'))) 17 echoerr "gutentags: this plugin requires the job API from Vim8 or Neovim." 18 finish 19 endif 20 21 let g:gutentags_debug = get(g:, 'gutentags_debug', 0) 22 23 if (exists('g:loaded_gutentags') && !g:gutentags_debug) 24 finish 25 endif 26 if (exists('g:loaded_gutentags') && g:gutentags_debug) 27 echom "Reloaded gutentags." 28 endif 29 let g:loaded_gutentags = 1 30 31 let g:gutentags_trace = get(g:, 'gutentags_trace', 0) 32 let g:gutentags_fake = get(g:, 'gutentags_fake', 0) 33 let g:gutentags_background_update = get(g:, 'gutentags_background_update', 1) 34 let g:gutentags_pause_after_update = get(g:, 'gutentags_pause_after_update', 0) 35 let g:gutentags_enabled = get(g:, 'gutentags_enabled', 1) 36 let g:gutentags_modules = get(g:, 'gutentags_modules', ['ctags']) 37 38 let g:gutentags_init_user_func = get(g:, 'gutentags_init_user_func', 39 \get(g:, 'gutentags_enabled_user_func', '')) 40 41 let g:gutentags_add_ctrlp_root_markers = get(g:, 'gutentags_add_ctrlp_root_markers', 1) 42 let g:gutentags_add_default_project_roots = get(g:, 'gutentags_add_default_project_roots', 1) 43 let g:gutentags_project_root = get(g:, 'gutentags_project_root', []) 44 if g:gutentags_add_default_project_roots 45 let g:gutentags_project_root += ['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout'] 46 endif 47 48 let g:gutentags_project_root_finder = get(g:, 'gutentags_project_root_finder', '') 49 50 let g:gutentags_project_info = get(g:, 'gutentags_project_info', []) 51 call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'}) 52 call add(g:gutentags_project_info, {'type': 'ruby', 'file': 'Gemfile'}) 53 54 let g:gutentags_exclude_project_root = get(g:, 'gutentags_exclude_project_root', 55 \['/usr/local', '/opt/homebrew', '/home/linuxbrew/.linuxbrew']) 56 57 let g:gutentags_exclude_filetypes = get(g:, 'gutentags_exclude_filetypes', []) 58 let g:gutentags_resolve_symlinks = get(g:, 'gutentags_resolve_symlinks', 0) 59 let g:gutentags_generate_on_new = get(g:, 'gutentags_generate_on_new', 1) 60 let g:gutentags_generate_on_missing = get(g:, 'gutentags_generate_on_missing', 1) 61 let g:gutentags_generate_on_write = get(g:, 'gutentags_generate_on_write', 1) 62 let g:gutentags_generate_on_empty_buffer = get(g:, 'gutentags_generate_on_empty_buffer', 0) 63 let g:gutentags_file_list_command = get(g:, 'gutentags_file_list_command', '') 64 65 let g:gutentags_use_jobs = get(g:, 'gutentags_use_jobs', has('job')) 66 67 if !exists('g:gutentags_cache_dir') 68 let g:gutentags_cache_dir = '' 69 elseif !empty(g:gutentags_cache_dir) 70 " Make sure we get an absolute/resolved path (e.g. expanding `~/`), and 71 " strip any trailing slash. 72 let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':p') 73 let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':s?[/\\]$??') 74 endif 75 76 let g:gutentags_define_advanced_commands = get(g:, 'gutentags_define_advanced_commands', 0) 77 78 if g:gutentags_cache_dir != '' && !isdirectory(g:gutentags_cache_dir) 79 call mkdir(g:gutentags_cache_dir, 'p') 80 endif 81 82 if has('win32') 83 let g:gutentags_plat_dir = expand('<sfile>:h:h:p') . "\\plat\\win32\\" 84 let g:gutentags_res_dir = expand('<sfile>:h:h:p') . "\\res\\" 85 let g:gutentags_script_ext = '.cmd' 86 else 87 let g:gutentags_plat_dir = expand('<sfile>:h:h:p') . '/plat/unix/' 88 let g:gutentags_res_dir = expand('<sfile>:h:h:p') . '/res/' 89 let g:gutentags_script_ext = '.sh' 90 endif 91 92 let g:__gutentags_vim_is_leaving = 0 93 94 " }}} 95 96 " Gutentags Setup {{{ 97 98 augroup gutentags_detect 99 autocmd! 100 autocmd BufNewFile,BufReadPost * call gutentags#setup_gutentags() 101 autocmd VimEnter * if expand('<amatch>')==''|call gutentags#setup_gutentags()|endif 102 autocmd VimLeavePre * call gutentags#on_vim_leave_pre() 103 autocmd VimLeave * call gutentags#on_vim_leave() 104 augroup end 105 106 " }}} 107 108 " Toggles and Miscellaneous Commands {{{ 109 110 if g:gutentags_define_advanced_commands 111 command! GutentagsToggleEnabled :let g:gutentags_enabled=!g:gutentags_enabled 112 command! GutentagsToggleTrace :call gutentags#toggletrace() 113 endif 114 115 if g:gutentags_debug 116 command! GutentagsToggleFake :call gutentags#fake() 117 endif 118 119 " }}} 120