├── og-mode.gif ├── plugin └── opengrok.vim ├── syntax └── opengrok.vim ├── README.md ├── doc └── opengrok.txt └── autoload └── opengrok.vim /og-mode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asenac/vim-opengrok/HEAD/og-mode.gif -------------------------------------------------------------------------------- /plugin/opengrok.vim: -------------------------------------------------------------------------------- 1 | if exists('loaded_opengrok') || &compatible 2 | finish 3 | endif 4 | let loaded_opengrok = 1 5 | 6 | " Line continuation used here 7 | let s:cpo_save = &cpo 8 | set cpo&vim 9 | 10 | command! -nargs=? -complete=customlist,opengrok#complete_search_mode 11 | \ OgSearch call opengrok#search_command(, input('Text: ', expand(""))) 12 | command! -nargs=? -complete=customlist,opengrok#complete_search_mode 13 | \ OgSearchCWord call opengrok#search_command(, expand("")) 14 | command! -nargs=1 OgSearchFile call opengrok#search_command('p', ) 15 | command! -nargs=1 -complete=dir OgIndex call opengrok#index_dir() 16 | command! -nargs=0 OgReindex call opengrok#reindex() 17 | command! -nargs=? OgMode call opengrok#og_mode() 18 | 19 | " restore 'cpo' 20 | let &cpo = s:cpo_save 21 | unlet s:cpo_save 22 | -------------------------------------------------------------------------------- /syntax/opengrok.vim: -------------------------------------------------------------------------------- 1 | if exists("b:current_syntax") 2 | finish 3 | endif 4 | 5 | syn match ogmComment "^\".*" 6 | syn match ogmPath contained '^\f\+' 7 | syn match ogmInfo contained '|\(\d\+ col \d\+\)\?| ' 8 | 9 | let s:opengrok_use_embedded_syntax = 10 | \ get(g:, "opengrok_use_embedded_syntax", 0) 11 | 12 | if s:opengrok_use_embedded_syntax 13 | syn match ogmLoc '^\f\+|\(\d\+ col \d\+\)\?| ' contains=ogmPath,ogmInfo 14 | 15 | let embedded_syntax = [ 16 | \ ["cpp", "\\.[ch]\\(pp\\|xx\\)\\?"], 17 | \ ["java", "\\.java"], 18 | \ ["javascript", "\\.js"], 19 | \ ["python", "\\.py"], 20 | \ ["perl", "\\.pl"], 21 | \ ["sh", "\\.sh"], 22 | \ ["cmake", "\\(\\.cmake\\|CMakeLists.txt\\)"], 23 | \ ["make", "[Mm]akefile"], 24 | \ ["ant", "build.xml"], 25 | \] 26 | 27 | for [s, r] in embedded_syntax 28 | exec "syn include @".s." syntax/".s.".vim" 29 | unlet b:current_syntax 30 | exe "syntax region ogm".s." keepend " 31 | \."start=+^\\f*".r."|\\(\\d\\+ col \\d\\+\\)| + " 32 | \."end=+$+ contains=ogmLoc,@".s 33 | endfor 34 | else 35 | syn match ogmAmp contained "&" conceal cchar=& 36 | syn match ogmGt contained ">" conceal cchar=> 37 | syn match ogmLt contained "<" conceal cchar=< 38 | 39 | syn match ogmMatch contained "[^<]\+" 40 | syn region ogmBoldMatch contained concealends matchgroup=ogmBm start="" end="" contains=ogmMatch 41 | syn match ogmLoc '^\f\+|\(\d\+ col \d\+\)\?| .*$' contains=ogmPath,ogmInfo,ogmBoldMatch,ogmAmp,ogmGt,ogmLt 42 | 43 | hi def link ogmMatch Special 44 | endif 45 | 46 | hi def link ogmComment Comment 47 | hi def link ogmPath Identifier 48 | hi def link ogmInfo Comment 49 | 50 | let b:current_syntax = "opengrok" 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vim-opengrok: opengrok interface for vim 2 | ======================================== 3 | 4 | Inspired by [youngker/eopengrok.el](https://github.com/youngker/eopengrok.el) 5 | 6 | ![vim-opengrok screenshot](https://raw.github.com/asenac/vim-opengrok/master/og-mode.gif) 7 | 8 | Installation 9 | ------------ 10 | 11 | Plugin 'asenac/vim-opengrok' 12 | 13 | Requeriments 14 | ------------ 15 | 16 | - Java 1.7 17 | 18 | - Exuberant ctags 19 | [http://ctags.sourceforge.net](http://ctags.sourceforge.net) 20 | 21 | - Opengrok 22 | [https://github.com/OpenGrok/OpenGrok/releases](https://github.com/OpenGrok/OpenGrok/releases) 23 | 24 | Note: vim-opengrok uses opengrok's command line tools but it does not require to 25 | have opengrok's web application deployed. 26 | 27 | Configuration 28 | ------------- 29 | 30 | Add the following lines to your vimrc using the appropriate routes: 31 | 32 | let g:opengrok_jar = '/path/to/opengrok/lib/opengrok.jar' 33 | let g:opengrok_ctags = '/path/to/ctags' 34 | 35 | vim-opengrok can use either a per-project index, created in a directory called 36 | .opengrok within the root directory of the project by using :OgIndex 37 | command, or an external index by defining g:opengrok\_config\_file variable 38 | pointing to the configuration.xml file. For example, for using the same index 39 | for both opengrok's web application and vim-opengrok, you might want to add the 40 | following to your vimrc file: 41 | 42 | let g:opengrok_config_file = '/var/opengrok/etc/configuration.xml' 43 | 44 | Note: vim-opengrok will fallback on g:opengrok\_config\_file variable if no 45 | index directory is found in the directory tree of the current working directory. 46 | 47 | Commands 48 | -------- 49 | 50 | :OgIndex /path/to/index 51 | 52 | Creates an index for the directory specified. 53 | 54 | :OgReIndex 55 | 56 | Updates the index that contains the current directory. 57 | 58 | :OgSearch [f|d|r|p] 59 | 60 | Searches in the index and displays the results in Vim's location list. A prompt 61 | is displayed to introduce the text to search. Supported queries: 62 | 63 | - d - Symbol Definitions 64 | - r - Symbol References 65 | - p - Path 66 | - f - Full text 67 | 68 | 69 | :OgSearchCWord 70 | 71 | Searches word under the cursor and displays the results in Vim's location list. 72 | 73 | :OgMode 74 | 75 | Interactive queries displaying the results in a special buffer (see screenhost 76 | above). 77 | 78 | Limitations 79 | ----------- 80 | 81 | Currently vim-opengrok displays only the first chunk of results returned by opengrok. 82 | -------------------------------------------------------------------------------- /doc/opengrok.txt: -------------------------------------------------------------------------------- 1 | *opengrok.txt* vim-opengrok: opengrok interface for vim 2 | 3 | ============================================================================== 4 | CONTENTS *opengrok-contents* 5 | 6 | 1. Introduction............................|opengrok-introduction| 7 | 2. Configuration...........................|opengrok-configuration| 8 | 3. Commands................................|opengrok-commands| 9 | 10 | ============================================================================== 11 | INTRODUCTION *opengrok-introduction* 12 | 13 | |vim-opengrok| allows you to navigate through your project by querying an index 14 | created with Opengrok. However, it does not require to have an Opengrok 15 | instance deployed running in a Tomcat server. It can use either an externally 16 | created index, for example, created by a cron job, or an internally managed 17 | index created and updated by using |:OgIndex| and |:OgReindex| commands 18 | respectively. 19 | 20 | |vim-opengrok| provides two different ways of making queries. |:OgSearch|, 21 | |:OgSearchCWord| and |:OgSearchFile| display the results in Vim's location 22 | list. |:OgMode| opens an special buffer with some shortcuts defined and allows 23 | you to keep the result of several queries in the same buffer. 24 | 25 | Another difference between |:OgMode| buffer and Vim's location list is that in 26 | the former the search term appears highlighted in the results. 27 | 28 | ============================================================================== 29 | CONFIGURATION *opengrok-configuration* 30 | 31 | Once you have installed |vim-opengrok| using your favorite package manager, it 32 | requires you to add at least one line to your vimrc file to specify the 33 | location of Opengrok's Jar file by defining |g:opengrok_jar| global variable 34 | as follows: 35 | 36 | let g:opengrok_jar = '/path/to/opengrok/lib/opengrok.jar' 37 | 38 | As stated in the introduction, |vim-opengrok| can use both internal and 39 | external indexes. Internal indexes, index created and updated by using 40 | |:OgIndex| and |:OgReindex| commands respectively, require you to define 41 | |g:opengrok_ctags| in your vimrc pointing to the location of the Exuberant 42 | Ctags exectuable as follows: 43 | 44 | let g:opengrok_ctags = '/path/to/ctags' 45 | 46 | For using an externally managed index you need to speficy the location of its 47 | configuration file with |g:opengrok_config_file|. For example, if you have 48 | an Opengrok instance running in a Tomcat server, with a crob job configured 49 | to update the index, and you want to make |vim-opengrok| use the same index as 50 | Opengrok's web application, you can do it by adding the following line to your 51 | vimrc file: 52 | 53 | let g:opengrok_config_file = '/var/opengrok/etc/configuration.xml' 54 | 55 | Note: change the path above if you have installed opengrok on a different 56 | location. 57 | 58 | ============================================================================== 59 | COMMANDS *opengrok-commands* 60 | 61 | :OgSearch {querytype} *:OgSearch* 62 | Displays a prompt to introduce the text that will be searched and displays 63 | the results in Vim's location list. 64 | 65 | :OgSearchCWord {querytype} *:OgSearchCWord* 66 | Searches the word under the cursor and displays the results in Vim's 67 | location list. 68 | 69 | :OgSearchFile {file} *:OgSearchFile* 70 | Searches a file named {file} in the index. 71 | 72 | :OgMode *:OgMode* 73 | Opens a special buffer to make queries by using the shortcuts defined. Use 74 | '?' to display the help text. 75 | 76 | :OgIndex {directory} *:OgIndex* 77 | Uses Opengrok's command line tool to index the content of {directory}. The 78 | index is created under a directory called .opengrok within {directory}. 79 | Use |:OgReindex| to update it. 80 | 81 | :OgReIndex *:OgReIndex* 82 | Updates an index created with |:OgIndex|. 83 | 84 | *opengrok-query-types* 85 | In the commands that take a {querytype}, this can be one of: 86 | 87 | Query Type Purpose~ 88 | fulltext For full text search 89 | definition For definition search 90 | reference For symbol references search 91 | path For file path search 92 | 93 | vim:ft=help 94 | -------------------------------------------------------------------------------- /autoload/opengrok.vim: -------------------------------------------------------------------------------- 1 | if exists('g:autoloaded_opengrok') || &compatible 2 | finish 3 | endif 4 | let g:autoloaded_opengrok = 1 5 | 6 | " Internal options 7 | let s:opengrok_index_dir = '.opengrok' 8 | let s:opengrok_cfg = '.opengrok/configuration.xml' 9 | let s:opengrok_indexer_class = 'org.opensolaris.opengrok.index.Indexer' 10 | let s:opengrok_search_class = 'org.opensolaris.opengrok.search.Search' 11 | let s:opengrok_allowed_opts = [ "d", "r", "p", "h", "f", "t"] 12 | let s:opengrok_latest_version = 13 | \ 'http://java.net/projects/opengrok/downloads/download/opengrok-0.12.1.tar.gz' 14 | let s:opengrok_ignored_dir = [ 15 | \ "CVS", ".hg", ".bzr", ".svn", "build", 16 | \ "*.o", "*.jar", "*.so", "*.a", "*.jar", "*.class", 17 | \ ".opengrok" ] 18 | let s:opengrok_ctags = 19 | \ fnamemodify(get(g:, "opengrok_ctags", "/usr/local/bin/ctags"), ":p") 20 | let s:opengrok_java = get(g:, "opengrok_java", "java") 21 | let s:opengrok_use_embedded_syntax = 22 | \ get(g:, "opengrok_use_embedded_syntax", 0) 23 | 24 | " Configuration options 25 | if !exists('g:opengrok_default_options') 26 | let g:opengrok_default_options = '-Xmx2048m' 27 | endif 28 | 29 | function! s:check_opengrok_jar() 30 | if !exists('g:opengrok_jar') 31 | call s:show_error("g:opengrok_jar is not defined!") 32 | return 0 33 | elseif !filereadable(fnamemodify(g:opengrok_jar, ':p')) 34 | call s:show_error(g:opengrok_jar . " does not exist!") 35 | return 0 36 | endif 37 | return 1 38 | endfunction 39 | 40 | function! s:show_error(msg) 41 | echohl ErrorMsg 42 | echomsg "[vim-opengrok] " . a:msg 43 | echohl None 44 | endfunction 45 | 46 | function! s:find_index_root_dir() 47 | let dir = expand('%:p:h') 48 | while !filereadable(dir . '/' . s:opengrok_cfg) 49 | let ndir = fnamemodify(dir, ':h') 50 | if ndir == dir 51 | return '' 52 | endif 53 | let dir = ndir 54 | endwhile 55 | return dir 56 | endfunction 57 | 58 | function! opengrok#exec(class, params) abort 59 | let cmd = s:opengrok_java . 60 | \ " " . g:opengrok_default_options . 61 | \ " -cp " . g:opengrok_jar . 62 | \ " " . a:class 63 | for param in a:params 64 | let cmd .= " " . param 65 | endfor 66 | "echomsg cmd 67 | " Note: As opengrok does not have a non-interactive mode 68 | " we will display only the first page of results 69 | return systemlist(cmd, "n") 70 | endfunction 71 | 72 | function! opengrok#search(type, pattern) abort 73 | let config_file = s:get_config_file_or_fail() 74 | if empty(config_file) 75 | return [] 76 | endif 77 | let params = ["-R " . config_file, 78 | \ a:type, shellescape(a:pattern)] 79 | return opengrok#exec(s:opengrok_search_class, params) 80 | endfunction 81 | 82 | function! opengrok#search_and_populate_loclist(type, pattern) abort 83 | let lines = opengrok#search(a:type, a:pattern) 84 | if len(lines) == 1 85 | call s:show_error(lines[0]) 86 | else 87 | let locations = [] 88 | for line in lines 89 | let groups = matchlist(line, '\([^:]\+\):\(\d\+\)\? \[\(.*\)\]$') 90 | if empty(groups) 91 | continue 92 | endif 93 | let [path, lnum, text] = groups[1:3] 94 | 95 | let entry = {} 96 | let entry.filename = fnamemodify(path, ':.') 97 | let entry.filepath = path 98 | let entry.lnum = lnum 99 | let entry.text = s:remove_html(text) 100 | let entry.col = s:get_match_column(text) 101 | 102 | call add(locations, entry) 103 | endfor 104 | 105 | call setloclist(winnr(), locations) 106 | if len(locations) > 0 107 | lopen 108 | endif 109 | endif 110 | endfunction 111 | 112 | function! opengrok#search_command(type, pattern) abort 113 | if !s:check_opengrok_jar() 114 | return 115 | endif 116 | let type = a:type 117 | if empty(type) 118 | let type = "f" 119 | elseif len(type) > 1 120 | let type = type[0] 121 | endif 122 | if index(s:opengrok_allowed_opts, type) == -1 123 | call s:show_error("Invalid mode '" . type . 124 | \ "'. Use one of the following: " . 125 | \ join(s:opengrok_allowed_opts, ', ')) 126 | return 127 | endif 128 | call opengrok#search_and_populate_loclist("-" . type, a:pattern) 129 | endfunction 130 | 131 | function! opengrok#index_dir(dir) 132 | if !s:check_opengrok_jar() 133 | return 134 | endif 135 | let dir = fnamemodify(a:dir, ':p') 136 | let params = [ 137 | \ "-q", 138 | \ "-c", 139 | \ shellescape(s:opengrok_ctags), 140 | \ "-W", 141 | \ shellescape(dir . '/' . s:opengrok_cfg), 142 | \ "-d", 143 | \ shellescape(dir . '/' . s:opengrok_index_dir), 144 | \ "-s", dir, 145 | \ "-C", "-S", "-H" 146 | \] 147 | for ignored in s:opengrok_ignored_dir 148 | call extend(params, ["-i", shellescape(ignored)]) 149 | endfor 150 | echomsg "Indexing " . dir 151 | let output = opengrok#exec(s:opengrok_indexer_class, params) 152 | if len(output) 153 | echomsg join(output, "\n") 154 | else 155 | echomsg "Index complete" 156 | endif 157 | endfunction 158 | 159 | function! opengrok#reindex() 160 | if !s:check_opengrok_jar() || !s:check_indexed() 161 | return 162 | endif 163 | let root = s:find_index_root_dir() 164 | call opengrok#index_dir(root) 165 | endfunction 166 | 167 | function! s:remove_html(text) 168 | let text = a:text 169 | let text = substitute(text, "", "", "g") 170 | let text = substitute(text, "", "", "g") 171 | let text = substitute(text, ">", ">", "g") 172 | let text = substitute(text, "<", "<", "g") 173 | let text = substitute(text, "&", "\\&", "g") 174 | return text 175 | endfunction 176 | 177 | function! s:get_match_column(text) 178 | let col = 1 179 | let idx = stridx(a:text, "") 180 | if idx > -1 181 | let text = strpart(a:text, 0, idx) 182 | let text = s:remove_html(text) 183 | " col is 1-index 184 | let col += strlen(text) 185 | endif 186 | return col 187 | endfunction 188 | 189 | function! opengrok#complete_search_mode(arg, line, pos) 190 | return ["fulltext", "definition", "reference", "path"] 191 | endfunction 192 | 193 | " 194 | " opengrok-mode 195 | " 196 | let s:og_mode_cached_results = [] 197 | 198 | function! opengrok#og_mode_search(type) abort 199 | if !s:check_opengrok_jar() || empty(s:get_config_file_or_fail()) 200 | return 201 | endif 202 | let modes = { 203 | \ 'f' : 'Full text', 204 | \ 'd' : 'Definition', 205 | \ 'r' : 'Symbol', 206 | \ 'p' : 'Path', 207 | \ } 208 | let text = get(modes, a:type) 209 | let pattern = input(text . ": ") 210 | if empty(pattern) 211 | call s:show_error("Command cancelled") 212 | return 213 | endif 214 | let results = opengrok#search("-" . a:type, pattern) 215 | if empty(results) 216 | return 217 | endif 218 | let lastline = line('$') 219 | setlocal modifiable 220 | let to_append = [] 221 | for line in results 222 | let groups = matchlist(line, '\([^:]\+\):\(\d\+\)\? \[\(.*\)\]$') 223 | if len(groups) != 0 224 | let path = fnamemodify(groups[1], ":~:.") 225 | let lnum = groups[2] 226 | let line = path . '|' 227 | if lnum 228 | let col = s:get_match_column(groups[3]) 229 | let line .= lnum . ' col ' . col 230 | endif 231 | let line .= '| ' 232 | if s:opengrok_use_embedded_syntax 233 | let line .= s:remove_html(groups[3]) 234 | else 235 | let line .= groups[3] 236 | endif 237 | else 238 | " Display as a commented line 239 | let line = '" ' . line 240 | endif 241 | call add(to_append, line) 242 | endfor 243 | let s:og_mode_cached_results += to_append 244 | call append(line('$'), to_append) 245 | call cursor(lastline + 1, 0) 246 | exec "normal! z\" 247 | setlocal nomodifiable 248 | endfunction 249 | 250 | function! opengrok#og_mode_jump(mode) abort 251 | let line = getline('.') 252 | let groups = matchlist(line, '\([^:]\+\)|\(\(\d\+\) col \(\d\+\)\)\?| \(.*\)$') 253 | if empty(groups) 254 | return 255 | endif 256 | let [path, _, lnum, col] = groups[1:4] 257 | if a:mode == 'n' 258 | " open in a new window 259 | exe "new " . path 260 | elseif a:mode == 'o' 261 | " open in another window 262 | if winnr('$') == 1 263 | exe "new " . path 264 | else 265 | " the path might be relative to the current directory 266 | let cwd = getcwd() 267 | exe "wincmd p" 268 | exec "cd " . cwd 269 | exe "edit " . path 270 | endif 271 | else 272 | " open in a current window 273 | exe "edit " . path 274 | endif 275 | call cursor(lnum, col) 276 | endfunction 277 | 278 | let s:og_mode_help_text = [ 279 | \ '" f: full text, d: definition, r: symbol, p: path', 280 | \ '" c: clear, ?: help', 281 | \ '" h: open in new window, t: open in this window', 282 | \ '" ,o: open in another window', 283 | \ '', 284 | \ ] 285 | 286 | function! s:help() abort 287 | let lastline = line('$') 288 | call append(lastline, s:og_mode_help_text) 289 | let config_file = s:get_config_file_or_fail() 290 | if empty(config_file) 291 | let config_file = "No configuration file found!" 292 | endif 293 | let headers = [ 294 | \ '" Opengrok Mode', 295 | \ '" Configuration file: ' . config_file, 296 | \ '" Working directory: ' . getcwd(), 297 | \ ] 298 | call append(lastline, headers) 299 | call cursor(lastline + 1, 0) 300 | exec "normal! z\" 301 | endfunction 302 | 303 | function! opengrok#og_mode_help() abort 304 | setlocal modifiable 305 | call s:help() 306 | setlocal nomodifiable 307 | endfunction 308 | 309 | function! opengrok#og_mode_clear() abort 310 | setlocal modifiable 311 | let s:og_mode_cached_results = [] 312 | silent normal! ggVGG"_d 313 | call s:help() 314 | exe "1d" 315 | setlocal nomodifiable 316 | endfunction 317 | 318 | function! s:set_mappings() abort 319 | nnoremap f 320 | \ :call opengrok#og_mode_search('f') 321 | nnoremap d 322 | \ :call opengrok#og_mode_search('d') 323 | nnoremap r 324 | \ :call opengrok#og_mode_search('r') 325 | nnoremap p 326 | \ :call opengrok#og_mode_search('p') 327 | nnoremap c 328 | \ :call opengrok#og_mode_clear() 329 | nnoremap ? 330 | \ :call opengrok#og_mode_help() 331 | nnoremap h 332 | \ :call opengrok#og_mode_jump('h') 333 | nnoremap o 334 | \ :call opengrok#og_mode_jump('o') 335 | 336 | " default action 337 | nnoremap 338 | \ :call opengrok#og_mode_jump('o') 339 | nnoremap <2-LeftMouse> 340 | \ :call opengrok#og_mode_jump('o') 341 | endfunction 342 | 343 | function! s:check_indexed() 344 | let root = s:find_index_root_dir() 345 | if empty(root) 346 | call s:show_error("Current directory not indexed. " 347 | \ . "Use :OgIndex command to create the index in " 348 | \ . "the root directory of your project") 349 | return 0 350 | endif 351 | return 1 352 | endfunction 353 | 354 | function! s:get_config_file_or_fail() 355 | let config_file = get(g:, "opengrok_config_file", '') 356 | let root = s:find_index_root_dir() 357 | if len(root) > 0 358 | let config_file = root . "/" . s:opengrok_cfg 359 | endif 360 | if empty(config_file) 361 | call s:show_error("No configuration file found. " 362 | \ . "Use :OgIndex command to create the index in " 363 | \ . "the root directory of your project " 364 | \ . "or define g:opengrok_config_file in your " 365 | \ . ".vimrc file.") 366 | return '' 367 | endif 368 | if !filereadable(fnamemodify(config_file, ':p')) 369 | call s:show_error(config_file . " is not readable") 370 | return '' 371 | endif 372 | return config_file 373 | endfunction 374 | 375 | let s:og_mode_buf_name = '[OpenGrok]' 376 | 377 | function s:get_buf_name() 378 | let name = s:og_mode_buf_name 379 | if !has("win32") 380 | " On non-Windows boxes, escape the name so that is shows up correctly. 381 | let name = escape(name, "[]") 382 | endif 383 | return name 384 | endfunction 385 | 386 | function s:buf_enter() 387 | set filetype=opengrok 388 | if line('$') == 1 && col('$') == 1 389 | setlocal modifiable 390 | call s:help() 391 | exe "1d" 392 | 393 | let lastline = line('$') 394 | call append(line('$'), s:og_mode_cached_results) 395 | call cursor(lastline + 1, 0) 396 | setlocal nomodifiable 397 | endif 398 | endfunction 399 | 400 | function! opengrok#og_mode(height) 401 | if &insertmode || !s:check_opengrok_jar() 402 | return 403 | endif 404 | 405 | let l:name = s:get_buf_name() 406 | 407 | " re-use existing window 408 | let l:wnr = bufwinnr(l:name) 409 | if l:wnr != -1 410 | exe l:wnr . "wincmd w" 411 | elseif l:wnr != winnr() 412 | let l:bn = bufnr(l:name) 413 | if l:bn == -1 414 | execute "silent keepjumps hide keepa bo new" . l:name 415 | setlocal 416 | \ buftype=nofile 417 | \ nocursorcolumn 418 | \ noswapfile 419 | \ nowrap 420 | 421 | call s:set_mappings() 422 | call s:buf_enter() 423 | setlocal nomodifiable nomodified 424 | else 425 | execute "silent keepjumps keepa bo sb" . l:bn 426 | endif 427 | endif 428 | 429 | if !empty(a:height) 430 | exe "res " . a:height 431 | endif 432 | endfunction 433 | 434 | aug OpengrokAug 435 | au! 436 | exe "au BufEnter " . s:get_buf_name() . " call s:buf_enter()" 437 | aug END 438 | 439 | --------------------------------------------------------------------------------