├── autoload ├── ku │ └── ref.vim ├── ref.vim ├── ref │ ├── clojure.vim │ ├── erlang.vim │ ├── man.vim │ ├── perldoc.vim │ ├── phpmanual.vim │ ├── pydoc.vim │ ├── redis.vim │ ├── refe.vim │ ├── rfc.vim │ └── webdict.vim └── unite │ ├── kinds │ └── ref.vim │ └── sources │ └── ref.vim ├── doc ├── ku-ref.txt ├── ref-clojure.jax ├── ref-clojure.txt ├── ref-erlang.jax ├── ref-erlang.txt ├── ref-man.jax ├── ref-man.txt ├── ref-perldoc.jax ├── ref-perldoc.txt ├── ref-phpmanual.jax ├── ref-phpmanual.txt ├── ref-pydoc.jax ├── ref-pydoc.txt ├── ref-refe.jax ├── ref-refe.txt ├── ref-webdict.jax ├── ref-webdict.txt ├── ref.jax ├── ref.txt └── unite-ref.txt └── plugin └── ref.vim /autoload/ku/ref.vim: -------------------------------------------------------------------------------- 1 | " ku source: ref 2 | " Version: 0.2.1 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | function! ku#ref#available_sources() 11 | return map(ref#available_source_names(), '"ref/" . v:val') 12 | endfunction 13 | 14 | function! ku#ref#action_table(ext) 15 | return { 16 | \ 'default': 'ku#ref#open', 17 | \ 'open': 'ku#ref#open', 18 | \ } 19 | endfunction 20 | 21 | function! ku#ref#key_table(ext) 22 | return { 23 | \ "\": 'open', 24 | \ 'o': 'open', 25 | \ } 26 | endfunction 27 | 28 | function! ku#ref#gather_items(ext, pattern) 29 | return map(ref#available_sources(a:ext).complete(a:pattern), 30 | \ '{"word": v:val, "menu": a:ext}') 31 | endfunction 32 | 33 | function! ku#ref#acc_valid_p(ext, item, sep) 34 | let s = ref#available_sources(a:ext) 35 | return has_key(s, 'acc_valid_p') ? s.acc_valid_p(a:item, a:sep) : 0 36 | endfunction 37 | 38 | function! ku#ref#special_char_p(ext, ch) 39 | let s = ref#available_sources(a:ext) 40 | return has_key(s, 'special_char_p') ? s.special_char_p(a:ch) : 0 41 | endfunction 42 | 43 | function! ku#ref#on_before_action(ext, item) 44 | let s = ref#available_sources(a:ext) 45 | return has_key(s, 'on_before_action') ? s.on_before_action(a:item) : a:item 46 | endfunction 47 | 48 | function! ku#ref#on_source_enter(ext) 49 | let s = ref#available_sources(a:ext) 50 | return has_key(s, 'on_source_enter') ? s.on_source_enter() : 0 51 | endfunction 52 | 53 | function! ku#ref#on_source_leave(ext) 54 | let s = ref#available_sources(a:ext) 55 | return has_key(s, 'on_source_leave') ? s.on_source_leave() : 0 56 | endfunction 57 | 58 | function! ku#ref#open(item) 59 | call ref#open(a:item.menu, a:item.word, {'open': ''}) 60 | endfunction 61 | 62 | let &cpo = s:save_cpo 63 | unlet s:save_cpo 64 | -------------------------------------------------------------------------------- /autoload/ref.vim: -------------------------------------------------------------------------------- 1 | " Integrated reference viewer. 2 | " Version: 0.4.3 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | " Options. {{{1 11 | if !exists('g:ref_open') 12 | let g:ref_open = 'split' 13 | endif 14 | 15 | if !exists('g:ref_cache_dir') 16 | let g:ref_cache_dir = expand('~/.cache/vim-ref') 17 | endif 18 | 19 | if !exists('g:ref_use_vimproc') 20 | let g:ref_use_vimproc = globpath(&runtimepath, 'autoload/vimproc.vim') != '' 21 | endif 22 | 23 | let s:is_win = has('win16') || has('win32') || has('win64') 24 | 25 | let s:T = { 26 | \ 'number': type(0), 27 | \ 'string': type(''), 28 | \ 'function': type(function('function')), 29 | \ 'list': type([]), 30 | \ 'dictionary': type({}), 31 | \ 'float': type(0.0), 32 | \ } 33 | 34 | let s:options = ['-open=', '-new', '-nocache', '-noenter', '-updatecache'] 35 | 36 | let s:sources = {} 37 | 38 | let s:prototype = {} " {{{1 39 | function! s:prototype.available() 40 | return 1 41 | endfunction 42 | function! s:prototype.opened(query) 43 | endfunction 44 | function! s:prototype.get_keyword() 45 | return expand('') 46 | endfunction 47 | function! s:prototype.normalize(query) 48 | return a:query 49 | endfunction 50 | function! s:prototype.leave() 51 | endfunction 52 | function! s:prototype.cache(name, ...) 53 | return call('ref#cache', [self.name, a:name] + a:000) 54 | endfunction 55 | 56 | 57 | " API functions. {{{1 58 | 59 | " A function for main command. 60 | function! ref#ref(args) 61 | try 62 | let parsed = s:parse_args(a:args) 63 | return ref#open(parsed.source, parsed.query, parsed.options) 64 | catch /^ref:/ 65 | call s:echoerr(v:exception) 66 | endtry 67 | endfunction 68 | 69 | function! ref#complete(lead, cmd, pos) 70 | let cmd = a:cmd[: a:pos - 1] 71 | try 72 | let parsed = s:parse_args(matchstr(cmd, '^\v.{-}R%[ef]\s+\zs.*$')) 73 | catch 74 | return [] 75 | endtry 76 | try 77 | if has_key(parsed.options, 'nocache') 78 | let s:nocache = 1 79 | endif 80 | if has_key(parsed.options, 'updatecache') 81 | let s:updatecache = 1 82 | endif 83 | if parsed.source == '' || (parsed.query == '' && cmd =~ '\S$') 84 | let lead = matchstr(cmd, '-\w*$') 85 | if lead != '' 86 | return filter(copy(s:options), 'v:val =~ "^" . lead && ' . 87 | \ '!has_key(parsed.options, matchstr(v:val, "\\w\\+"))') 88 | endif 89 | let s = keys(filter(copy(ref#available_sources()), 'v:val.available()')) 90 | return filter(s, 'v:val =~ "^".a:lead') 91 | endif 92 | let source = get(s:sources, parsed.source, s:prototype) 93 | return has_key(source, 'complete') ? source.complete(parsed.query) : [] 94 | finally 95 | unlet! s:nocache s:updatecache 96 | endtry 97 | endfunction 98 | 99 | function! ref#K(mode) 100 | try 101 | call ref#jump(a:mode) 102 | catch /^ref: The source is not registered:/ 103 | if a:mode ==# 'visual' 104 | call feedkeys('gvK', 'n') 105 | else 106 | call feedkeys('K', 'n') 107 | endif 108 | catch /^ref:/ 109 | call s:echoerr(v:exception) 110 | endtry 111 | endfunction 112 | 113 | function! ref#open(source, query, ...) 114 | try 115 | let options = a:0 ? a:1 : {} 116 | if (exists('g:ref_noenter') && g:ref_noenter) || 117 | \ (exists('b:ref_noenter') && b:ref_noenter) 118 | let options.noenter = '1' 119 | endif 120 | if has_key(options, 'nocache') 121 | let s:nocache = 1 122 | endif 123 | if has_key(options, 'updatecache') 124 | let s:updatecache = 1 125 | endif 126 | return s:open(a:source, a:query, options) 127 | finally 128 | unlet! s:nocache s:updatecache 129 | endtry 130 | endfunction 131 | 132 | function! ref#jump(...) 133 | let args = copy(a:000) 134 | let options = {} 135 | 136 | for a in args 137 | if type(a) == s:T.dictionary 138 | call extend(options, a) 139 | endif 140 | unlet a 141 | endfor 142 | call filter(args, 'type(v:val) != s:T.dictionary') 143 | 144 | let sources = 2 <= len(args) ? args[1] : ref#detect() 145 | let mode = get(args, 0, 'normal') 146 | 147 | let last_exception = '' 148 | for source in s:flatten(s:to_list(sources)) 149 | if !has_key(s:sources, source) 150 | throw 'ref: The source is not registered: ' . source 151 | endif 152 | 153 | let [source, query] = s:get_query(mode, source) 154 | if type(query) == s:T.string && query != '' 155 | try 156 | call ref#open(source, query, options) 157 | return 158 | catch /^ref:/ 159 | let last_exception = v:exception 160 | endtry 161 | endif 162 | endfor 163 | 164 | if last_exception != '' 165 | throw last_exception 166 | endif 167 | endfunction 168 | 169 | function! ref#register(source) 170 | if type(a:source) == s:T.list 171 | for source in a:source 172 | call ref#register(source) 173 | endfor 174 | return 175 | elseif type(a:source) != s:T.dictionary 176 | throw 'ref: Invalid source: The source should be a Dictionary.' 177 | endif 178 | let source = extend(copy(s:prototype), a:source) 179 | call s:validate(source, 'name', 'string') 180 | call s:validate(source, 'available', 'function') 181 | call s:validate(source, 'get_body', 'function') 182 | call s:validate(source, 'opened', 'function') 183 | call s:validate(source, 'get_keyword', 'function') 184 | call s:validate(source, 'normalize', 'function') 185 | call s:validate(source, 'leave', 'function') 186 | let s:sources[source.name] = source 187 | endfunction 188 | 189 | function! ref#available_source_names() 190 | return keys(s:sources) 191 | endfunction 192 | 193 | function! ref#available_sources(...) 194 | return !a:0 ? copy(s:sources) : 195 | \ has_key(s:sources, a:1) ? s:sources[a:1] : 0 196 | endfunction 197 | 198 | function! ref#detect() 199 | if exists('b:ref_source') 200 | let Source = b:ref_source 201 | elseif exists('g:ref_detect_filetype[&l:filetype]') 202 | let Source = g:ref_detect_filetype[&l:filetype] 203 | elseif exists('g:ref_detect_filetype._') 204 | let Source = g:ref_detect_filetype._ 205 | else 206 | let Source = '' 207 | endif 208 | 209 | while type(Source) == s:T.function 210 | " For dictionary function. 211 | let dict = exists('g:ref_detect_filetype') ? g:ref_detect_filetype : {} 212 | let s = call(Source, [&l:filetype], dict) 213 | unlet Source 214 | let Source = s 215 | endwhile 216 | 217 | if type(Source) == s:T.string || type(Source) == s:T.list 218 | return Source 219 | endif 220 | return '' 221 | endfunction 222 | 223 | function! ref#register_detection(ft, source, ...) 224 | if !exists('g:ref_detect_filetype') 225 | let g:ref_detect_filetype = {} 226 | endif 227 | let way = a:0 ? a:1 : 'ignore' 228 | if has_key(g:ref_detect_filetype, a:ft) && way !=# 'overwrite' 229 | let val = s:to_list(g:ref_detect_filetype[a:ft]) 230 | let sources = s:to_list(a:source) 231 | if way ==# 'prepend' 232 | let g:ref_detect_filetype[a:ft] = sources + val 233 | elseif way ==# 'append' 234 | let g:ref_detect_filetype[a:ft] = val + sources 235 | endif 236 | else 237 | let g:ref_detect_filetype[a:ft] = a:source 238 | endif 239 | endfunction 240 | 241 | 242 | " Helper functions for source. {{{1 243 | let s:cache = {} 244 | function! ref#cache(source, ...) 245 | if a:0 == 0 246 | let [from, to] = ['%\(\x\x\)', '\=eval("\"\\x".submatch(1)."\"")'] 247 | return g:ref_cache_dir == '' ? [] : 248 | \ map(split(glob(printf('%s/%s/*', g:ref_cache_dir, a:source)), "\n"), 249 | \ 'substitute(fnamemodify(v:val, ":t"), from, to, "g")') 250 | endif 251 | 252 | let name = a:1 253 | if name is '' 254 | throw 'ref: The name for cache is empty.' 255 | endif 256 | let get_only = a:0 == 1 257 | let update = get(a:000, 2, 0) || exists('s:updatecache') 258 | if exists('s:nocache') 259 | if get_only 260 | return 0 261 | endif 262 | return s:gather_cache(name, a:2) 263 | endif 264 | 265 | if update || !exists('s:cache[a:source][name]') 266 | if !has_key(s:cache, a:source) 267 | let s:cache[a:source] = {} 268 | endif 269 | 270 | if g:ref_cache_dir != '' 271 | let file = printf('%s/%s/%s', g:ref_cache_dir, a:source, s:escape(name)) 272 | if filereadable(file) 273 | let s:cache[a:source][name] = readfile(file) 274 | endif 275 | endif 276 | 277 | if update || !has_key(s:cache[a:source], name) 278 | if get_only 279 | return 0 280 | endif 281 | let s:cache[a:source][name] = s:gather_cache(name, a:2) 282 | 283 | if g:ref_cache_dir != '' 284 | let dir = fnamemodify(file, ':h') 285 | if !isdirectory(dir) 286 | call mkdir(dir, 'p') 287 | endif 288 | call writefile(s:cache[a:source][name], file) 289 | endif 290 | endif 291 | endif 292 | 293 | return s:cache[a:source][name] 294 | endfunction 295 | 296 | function! ref#rmcache(...) 297 | if g:ref_cache_dir == '' 298 | return 299 | endif 300 | if !a:0 301 | for source in split(glob(g:ref_cache_dir . '/*'), "\n") 302 | call ref#rmcache(fnamemodify(source, ':t')) 303 | endfor 304 | return 305 | endif 306 | let source = a:1 307 | let names = 2 <= a:0 ? ref#to_list(a:2) : ref#cache(source) 308 | for name in names 309 | call delete(printf('%s/%s/%s', g:ref_cache_dir, source, s:escape(name))) 310 | endfor 311 | 312 | if !has_key(s:cache, source) 313 | return 314 | endif 315 | if a:0 316 | for name in names 317 | if has_key(s:cache[source], name) 318 | call remove(s:cache[source], name) 319 | endif 320 | endfor 321 | else 322 | call remove(s:cache, source) 323 | endif 324 | endfunction 325 | 326 | function! ref#system(args, ...) 327 | let args = ref#to_list(a:args) 328 | if g:ref_use_vimproc 329 | try 330 | let stdout = a:0 ? vimproc#system(args, a:1) : vimproc#system(args) 331 | return { 332 | \ 'result': vimproc#get_last_status(), 333 | \ 'stdout': stdout, 334 | \ 'stderr': vimproc#get_last_errmsg(), 335 | \ } 336 | catch 337 | endtry 338 | endif 339 | 340 | if s:is_win 341 | " Here is a command that want to execute. 342 | " something.bat keyword 343 | " 344 | " The command is actually executed by the following form. 345 | " cmd.exe /c something.bat keyword 346 | " 347 | " Any arguments may include whitespace and some character needs escaping, 348 | " so we need to quote each arguments. 349 | " cmd.exe /c "something.bat" "keyword" 350 | " 351 | " But cmd.exe handles it as one argument like ``something.bat" "keyword''. 352 | " So, we have to quote the command again. 353 | " cmd.exe /c ""something.bat" "keyword"" 354 | " 355 | " Here, cmd.exe behaves strangely. When the command is a .bat file, 356 | " %~dp0 in the file is expanded to the current directory. 357 | " For example 358 | " C:\Program Files\some\example.bat: (in $PATH) 359 | " @echo %~f0 360 | " 361 | " (in cmd.exe) 362 | " C:\>example.bat 363 | " C:\Program Files\some\example.bat 364 | " 365 | " C:\>cmd.exe /c example.bat 366 | " C:\Program Files\some\example.bat 367 | " 368 | " C:\>cmd.exe /c ""example.bat"" 369 | " C:\example.bat 370 | " 371 | " C:\>cmd.exe /c ""C:\Program Files\some\example.bat"" 372 | " C:\Program Files\some\example.bat 373 | " 374 | " By occasion of above, the command should be converted to fullpath. 375 | let args[0] = s:cmdpath(args[0]) 376 | let q = '"' 377 | if exists('+shellxescape') && &shellxquote ==# '(' 378 | let esc_chars = &shellxescape 379 | let save_shellxescape = &shellxescape 380 | let &shellxescape = '' 381 | else 382 | let esc_chars = '"&|<>()@^' 383 | endif 384 | let esc_pat = '[' . escape(esc_chars, '\]') . ']' 385 | let cmd = join(map(args, 386 | \ 'q . substitute(v:val, esc_pat, "^\\0", "g") . q'), 387 | \ ' ') 388 | if !exists('+shellxquote') || &shellxquote ==# '' 389 | let cmd = '( ' . cmd . ' )' 390 | endif 391 | else 392 | let cmd = join(map(args, 'shellescape(v:val)')) 393 | endif 394 | let save_shellredir = &shellredir 395 | let stderr_file = tempname() 396 | let &shellredir = '>%s 2>' . shellescape(stderr_file) . ' ' 397 | let stdout = '' 398 | try 399 | let stdout = a:0 ? system(cmd, a:1) : system(cmd) 400 | finally 401 | if filereadable(stderr_file) 402 | let stderr = join(readfile(stderr_file, 'b'), "\n") 403 | call delete(stderr_file) 404 | else 405 | let stderr = '' 406 | endif 407 | let &shellredir = save_shellredir 408 | if exists('save_shellxescape') 409 | let &shellxescape = save_shellxescape 410 | endif 411 | endtry 412 | 413 | return { 414 | \ 'result': v:shell_error, 415 | \ 'stdout': stdout, 416 | \ 'stderr': stderr 417 | \ } 418 | endfunction 419 | 420 | function! ref#to_list(...) 421 | let list = [] 422 | for a in a:000 423 | let list += type(a) == s:T.string ? split(a) : s:to_list(a) 424 | unlet a 425 | endfor 426 | return list 427 | endfunction 428 | 429 | function! ref#uniq(list) 430 | let d = {} 431 | for i in a:list 432 | let d['_' . i] = 0 433 | endfor 434 | return map(sort(keys(d)), 'v:val[1 :]') 435 | endfunction 436 | 437 | function! ref#get_text_on_cursor(pat) 438 | let line = getline('.') 439 | let pos = col('.') 440 | let s = 0 441 | while s < pos 442 | let [s, e] = [match(line, a:pat, s), matchend(line, a:pat, s)] 443 | if s < 0 444 | break 445 | elseif s < pos && pos <= e 446 | return line[s : e - 1] 447 | endif 448 | let s += 1 449 | endwhile 450 | return '' 451 | endfunction 452 | 453 | 454 | " Misc. {{{1 455 | function! s:initialize_buffer(source) 456 | setlocal nobuflisted 457 | setlocal buftype=nofile noswapfile 458 | setlocal bufhidden=delete 459 | setlocal nonumber 460 | setlocal norelativenumber 461 | 462 | let b:ref_history = [] " stack [source, query, changenr, cursor] 463 | let b:ref_history_pos = -1 " pointer 464 | 465 | nnoremap (ref-forward) 466 | \ :call move_history(v:count1) 467 | nnoremap (ref-back) 468 | \ :call move_history(-v:count1) 469 | 470 | if !exists('g:ref_no_default_key_mappings') 471 | \ || !g:ref_no_default_key_mappings 472 | map (ref-keyword) 473 | map <2-LeftMouse> (ref-keyword) 474 | map (ref-keyword) 475 | 476 | map (ref-back) 477 | map (ref-back) 478 | map (ref-forward) 479 | endif 480 | 481 | setlocal filetype=ref 482 | 483 | command! -bar -buffer RefHistory call s:dump_history() 484 | endfunction 485 | 486 | function! s:parse_args(argline) 487 | let res = {'source': '', 'query': '', 'options': {}} 488 | let rest = a:argline 489 | try 490 | while rest =~ '\S' 491 | let [word, rest] = matchlist(rest, '\v^(-?\w*%(\=\S*)?)\s*(.*)$')[1 : 2] 492 | if word =~# '^-' 493 | let [word, value] = matchlist(word, '\v^-(\w*)%(\=(.*))?$')[1 : 2] 494 | if word != '' 495 | let res.options[word] = value 496 | endif 497 | else 498 | let [res.source, res.query, rest] = [word, rest, ''] 499 | endif 500 | endwhile 501 | catch 502 | throw 'ref: Invalid argument: ' . a:argline 503 | endtry 504 | 505 | return res 506 | endfunction 507 | 508 | function! s:gather_cache(name, gather) 509 | let type = type(a:gather) 510 | let cache = 511 | \ type == s:T.function ? a:gather(a:name) : 512 | \ type == s:T.dictionary && has_key(a:gather, 'call') 513 | \ && type(a:gather.call) == s:T.function ? 514 | \ a:gather.call(a:name) : 515 | \ type == s:T.string ? eval(a:gather) : 516 | \ type == s:T.list ? a:gather : [] 517 | 518 | if type(cache) == s:T.list 519 | return cache 520 | elseif type(cache) == s:T.string 521 | return split(cache, "\n") 522 | endif 523 | throw 'ref: Invalid results of cache: ' . string(cache) 524 | endfunction 525 | 526 | function! s:get_query(mode, source) 527 | let [source, query] = [a:source, ''] 528 | if a:mode ==# 'normal' 529 | try 530 | let pos = getpos('.') 531 | let res = s:sources[source].get_keyword() 532 | catch 533 | let mes = v:exception 534 | if mes =~# '^Vim' 535 | let mes .= "\n" . v:throwpoint 536 | endif 537 | throw printf('ref: %s: %s', source, mes) 538 | finally 539 | call setpos('.', pos) 540 | endtry 541 | if type(res) == s:T.list && len(res) == 2 542 | let [source, query] = res 543 | else 544 | let query = res 545 | endif 546 | 547 | elseif a:mode =~# '^\v%(visual|line|char|block)$' 548 | let vm = { 549 | \ 'visual': visualmode(), 550 | \ 'line': 'V', 551 | \ 'char': 'v', 552 | \ 'block': "\" }[a:mode] 553 | let [sm, em] = a:mode ==# 'visual' ? ['<', '>'] : ['[', ']'] 554 | 555 | let [reg_save, reg_save_type] = [getreg(), getregtype()] 556 | let [pos_c, pos_s, pos_e] = [getpos('.'), getpos("'<"), getpos("'>")] 557 | 558 | execute 'silent normal! `' . sm . vm . '`' . em . 'y' 559 | let query = @" 560 | 561 | " Restore '< '> 562 | call setpos('.', pos_s) 563 | execute 'normal!' vm 564 | call setpos('.', pos_e) 565 | execute 'normal!' vm 566 | call setpos('.', pos_c) 567 | 568 | call setreg(v:register, reg_save, reg_save_type) 569 | endif 570 | return [source, query] 571 | endfunction 572 | 573 | function! s:open(source, query, options) 574 | if !has_key(s:sources, a:source) 575 | throw 'ref: The source is not registered: ' . a:source 576 | endif 577 | let source = s:sources[a:source] 578 | if !source.available() 579 | throw 'ref: This source is unavailable: ' . a:source 580 | endif 581 | 582 | let query = source.normalize(a:query) 583 | try 584 | let res = source.get_body(query) 585 | if type(res) == s:T.dictionary 586 | let dict = res 587 | unlet res 588 | let res = dict.body 589 | if has_key(dict, 'query') 590 | let query = dict.query 591 | endif 592 | endif 593 | catch 594 | let mes = v:exception 595 | if mes =~# '^Vim' 596 | let mes .= "\n" . v:throwpoint 597 | endif 598 | if mes =~# '^ref:' 599 | let mes = matchstr(mes, '^ref:\s*\zs.*') 600 | endif 601 | throw printf('ref: %s: %s', a:source, mes) 602 | endtry 603 | 604 | if type(res) == s:T.list 605 | let newres = join(res, "\n") 606 | unlet! res 607 | let res = newres 608 | endif 609 | if type(res) != s:T.string || res == '' 610 | throw printf('ref: %s: The body is empty. (query=%s)', a:source, query) 611 | endif 612 | 613 | let pos = getpos('.') 614 | 615 | if has_key(a:options, 'noenter') 616 | let w:ref_back = 1 617 | endif 618 | 619 | let bufnr = 0 620 | if !has_key(a:options, 'new') 621 | for i in range(0, winnr('$')) 622 | let n = winbufnr(i) 623 | if getbufvar(n, '&filetype') =~# '^ref-' 624 | if i != 0 625 | execute i 'wincmd w' 626 | endif 627 | let bufnr = n 628 | break 629 | endif 630 | endfor 631 | endif 632 | 633 | if bufnr == 0 634 | silent! execute has_key(a:options, 'open') ? a:options.open : g:ref_open 635 | enew 636 | call s:initialize_buffer(a:source) 637 | else 638 | setlocal modifiable noreadonly 639 | % delete _ 640 | if b:ref_source !=# a:source 641 | syntax clear 642 | call source.leave() 643 | endif 644 | endif 645 | 646 | " FIXME: not cool... 647 | let s:res = res 648 | call s:open_source(a:source, query, 'silent :1 put = s:res | 1 delete _') 649 | unlet! s:res 650 | 651 | if !(0 <= b:ref_history_pos 652 | \ && b:ref_history[b:ref_history_pos][0] ==# a:source 653 | \ && b:ref_history[b:ref_history_pos][1] ==# query) 654 | let b:ref_history_pos += 1 655 | if b:ref_history_pos < len(b:ref_history) 656 | unlet! b:ref_history[b:ref_history_pos :] 657 | endif 658 | if 0 < b:ref_history_pos 659 | let b:ref_history[-1][3] = pos 660 | endif 661 | call add(b:ref_history, [a:source, query, changenr(), []]) 662 | endif 663 | 664 | if has_key(a:options, 'noenter') 665 | for t in range(1, tabpagenr('$')) 666 | for w in range(1, winnr('$')) 667 | if gettabwinvar(t, w, 'ref_back') 668 | execute 'tabnext' t 669 | execute w 'wincmd w' 670 | unlet! w:ref_back 671 | endif 672 | endfor 673 | endfor 674 | endif 675 | endfunction 676 | 677 | " A function for key mapping for K. 678 | function! s:open_source(source, query, open_cmd) 679 | if !exists('b:ref_source') || b:ref_source !=# a:source 680 | let b:ref_source = a:source 681 | execute 'setlocal filetype=ref-' . a:source 682 | endif 683 | 684 | let bufname = printf('[ref-%s:%s]', b:ref_source, 685 | \ substitute(a:query, '[\r\n]', '', 'g')) 686 | if s:is_win 687 | " In Windows, '*' cannot be used for a buffer name. 688 | let bufname = substitute(bufname, '\*', '', 'g') 689 | endif 690 | 691 | setlocal modifiable noreadonly 692 | 693 | silent! file `=bufname` 694 | 695 | execute a:open_cmd 696 | 697 | 1 " Move the cursor to the first line. 698 | 699 | call s:sources[b:ref_source].opened(a:query) 700 | 701 | setlocal nomodifiable readonly 702 | endfunction 703 | 704 | function! s:move_history(n) 705 | let next = b:ref_history_pos + a:n 706 | 707 | if next < 0 708 | let next = 0 709 | elseif len(b:ref_history) <= next 710 | let next = len(b:ref_history) - 1 711 | endif 712 | 713 | if next == b:ref_history_pos 714 | return 715 | endif 716 | let b:ref_history_pos = next 717 | 718 | let [source, query, changenr, pos] = b:ref_history[next] 719 | call s:open_source(source, query, 'silent! undo ' . changenr) 720 | call setpos('.', pos) 721 | endfunction 722 | 723 | function! s:dump_history() 724 | for i in range(len(b:ref_history)) 725 | echo printf('%s%3d %s: %s', i == b:ref_history_pos ? '>' : ' ', i + 1, 726 | \ b:ref_history[i][0], b:ref_history[i][1]) 727 | endfor 728 | let i = input('Enter nr of choice (CR to abort):') 729 | if i =~ '\d\+' 730 | call s:move_history(i - b:ref_history_pos - 1) 731 | endif 732 | endfunction 733 | 734 | function! s:validate(source, key, type) 735 | if !has_key(a:source, a:key) 736 | throw 'ref: Invalid source: Without key ' . string(a:key) 737 | elseif type(a:source[a:key]) != s:T[a:type] 738 | throw 'ref: Invalid source: Key ' . key . ' must be ' . a:type . ', ' . 739 | \ 'but given value is' . string(a:source[a:key]) 740 | endif 741 | endfunction 742 | 743 | function! s:cmdpath(cmd) 744 | " Search the fullpath of command for MS Windows. 745 | let full = glob(a:cmd) 746 | if a:cmd ==? full 747 | " Already fullpath. 748 | return a:cmd 749 | endif 750 | 751 | let extlist = split($PATHEXT, ';') 752 | if a:cmd =~? '\V\%(' . substitute($PATHEXT, ';', '\\|', 'g') . '\)\$' 753 | call insert(extlist, '', 0) 754 | endif 755 | for dir in split($PATH, ';') 756 | for ext in extlist 757 | let full = glob(dir . '\' . a:cmd . ext) 758 | if full != '' 759 | return full 760 | endif 761 | endfor 762 | endfor 763 | return '' 764 | endfunction 765 | 766 | function! s:escape(name) 767 | return substitute(a:name, '[:;*?"<>|/\\%]', 768 | \ '\=printf("%%%02x", char2nr(submatch(0)))', 'g') 769 | endfunction 770 | 771 | function! s:echoerr(msg) 772 | echohl ErrorMsg 773 | for line in split(a:msg, "\n") 774 | echomsg line 775 | endfor 776 | echohl None 777 | endfunction 778 | 779 | function! s:to_list(expr) 780 | return type(a:expr) == s:T.list ? a:expr : [a:expr] 781 | endfunction 782 | 783 | function! s:flatten(list) 784 | let list = [] 785 | for i in a:list 786 | if type(i) == s:T.list 787 | let list += s:flatten(i) 788 | else 789 | call add(list, i) 790 | endif 791 | unlet! i 792 | endfor 793 | return list 794 | endfunction 795 | 796 | 797 | " Register the default sources. {{{1 798 | function! s:register_defaults() 799 | let list = split(globpath(&runtimepath, 'autoload/ref/*.vim'), "\n") 800 | for name in map(list, 'fnamemodify(v:val, ":t:r")') 801 | try 802 | call ref#register(ref#{name}#define()) 803 | catch /:E\%(117\|716\):/ 804 | endtry 805 | endfor 806 | endfunction 807 | 808 | call s:register_defaults() 809 | 810 | 811 | let &cpo = s:save_cpo 812 | unlet s:save_cpo 813 | 814 | " vim: foldmethod=marker 815 | -------------------------------------------------------------------------------- /autoload/ref/clojure.vim: -------------------------------------------------------------------------------- 1 | " A ref source for clojure. 2 | " Version: 0.1.1 3 | " Author: thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | " options. {{{1 11 | if !exists('g:ref_clojure_cmd') " {{{2 12 | let g:ref_clojure_cmd = 13 | \ executable('clj') ? 'clj' : 14 | \ executable('clojure-1.5') ? 'clojure-1.5' : '' 15 | endif 16 | 17 | if !exists('g:ref_clojure_overview') " {{{2 18 | let g:ref_clojure_overview = 0 19 | endif 20 | 21 | " constants. {{{1 22 | let s:is_win = has('win16') || has('win32') || has('win64') 23 | 24 | let s:path_separator = s:is_win ? ';' : ':' 25 | 26 | 27 | let s:source = {'name': 'clojure'} " {{{1 28 | 29 | function! s:source.available() 30 | return len(g:ref_clojure_cmd) 31 | endfunction 32 | 33 | function! s:source.get_body(query) 34 | let query = a:query 35 | let classpath = $CLASSPATH 36 | let $CLASSPATH = s:classpath() 37 | let pre = s:precode() 38 | try 39 | if query =~ '^#".*"$' 40 | let query = query[2 : -2] 41 | else 42 | let res = s:clj(printf('%s(doc %s)', pre, query)) 43 | if res.stderr == '' && res.stdout != '' 44 | let body = res.stdout 45 | let query = matchstr(body, '^-*\n\zs.\{-}\ze\n') 46 | return query != '' ? {'body': body, 'query': query} : body 47 | endif 48 | endif 49 | let res = s:clj(printf('%s(find-doc "%s")', pre, escape(query, '"'))) 50 | if res.stdout != '' 51 | return g:ref_clojure_overview ? s:to_overview(res.stdout) 52 | \ : res.stdout 53 | endif 54 | finally 55 | let $CLASSPATH = classpath 56 | endtry 57 | throw printf('No document found for "%s"', query) 58 | endfunction 59 | 60 | function! s:source.opened(query) 61 | call s:syntax() 62 | endfunction 63 | 64 | function! s:source.get_keyword() 65 | let isk = &l:iskeyword 66 | setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,: 67 | let keyword = expand('') 68 | let &l:iskeyword = isk 69 | if &l:filetype ==# 'ref-clojure' && keyword =~ '.\.$' 70 | " This is maybe a period of the end of sentence. 71 | let keyword = keyword[: -2] 72 | endif 73 | return keyword 74 | endfunction 75 | 76 | 77 | " functions. {{{1 78 | function! s:clj(code) 79 | return ref#system(ref#to_list(g:ref_clojure_cmd, '-'), a:code) 80 | endfunction 81 | 82 | function! s:to_overview(body) 83 | let parts = split(a:body, '-\{25}\n')[1 :] 84 | return map(parts, 'join(split(v:val, "\n")[0 : 1], " ")') 85 | endfunction 86 | 87 | function! s:get_classpath(var) 88 | if !exists(a:var) 89 | return [] 90 | endif 91 | let var = eval(a:var) 92 | return type(var) == type([]) ? var : split(var, s:path_separator) 93 | endfunction 94 | 95 | function! s:classpath() 96 | let cp = s:get_classpath('b:ref_clojure_classpath') + 97 | \ s:get_classpath('g:ref_clojure_classpath') 98 | return join(cp, s:path_separator) 99 | endfunction 100 | 101 | function! s:precode() 102 | let given = get(g:, 'ref_clojure_precode', '') 103 | \ . get(b:, 'ref_clojure_precode', '') 104 | return given ==# '' ? 105 | \ '(ns vim-ref (:use [clojure.repl :only (doc find-doc)]))' : 106 | \ given 107 | endfunction 108 | 109 | function! s:syntax() 110 | if exists('b:current_syntax') && b:current_syntax == 'ref-clojure' 111 | return 112 | endif 113 | 114 | syntax clear 115 | syntax match refClojureDelimiter "^-\{25}\n" nextgroup=refClojureFunc 116 | syntax match refClojureFunc "^.\+$" contained 117 | 118 | highlight default link refClojureDelimiter Delimiter 119 | highlight default link refClojureFunc Function 120 | 121 | let b:current_syntax = 'ref-clojure' 122 | endfunction 123 | 124 | function! ref#clojure#define() 125 | return copy(s:source) 126 | endfunction 127 | 128 | call ref#register_detection('clojure', 'clojure') 129 | 130 | let &cpo = s:save_cpo 131 | unlet s:save_cpo 132 | -------------------------------------------------------------------------------- /autoload/ref/erlang.vim: -------------------------------------------------------------------------------- 1 | " A ref source for Erlang. 2 | " Version: 0.1.2 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | 11 | 12 | " config. {{{1 13 | if !exists('g:ref_erlang_cmd') " {{{2 14 | let g:ref_erlang_cmd = executable('erl') ? 'erl' : '' 15 | endif 16 | 17 | 18 | let s:FUNC_PATTERN = '\%([[:alnum:]_.]\+:\)\?\w\+' 19 | 20 | 21 | let s:source = ref#man#define() " {{{1 22 | 23 | let s:source.name = 'erlang' 24 | 25 | let s:source.man_get_body = s:source.get_body 26 | let s:source.man_opened = s:source.opened 27 | let s:source.man_complete = s:source.complete 28 | 29 | 30 | 31 | function! s:source.get_body(query) 32 | let query = a:query 33 | let module = get(split(query, ':'), 0, '') 34 | try 35 | let body = self.man_get_body(module) 36 | catch /^\@\|$\)' 104 | let lines = filter(split(exports, "\n"), 'v:val =~ pat') 105 | let pat = '^\s*\%([[:alnum:]_.]\+:\)\?\zs\w\+\ze(' 106 | let funcs = ref#uniq(map(lines, 'a:module . ":" . matchstr(v:val, pat)')) 107 | call self.cache(a:module, funcs) 108 | endif 109 | return funcs 110 | endfunction 111 | 112 | function! ref#erlang#define() 113 | return copy(s:source) 114 | endfunction 115 | 116 | call ref#register_detection('erlang', 'erlang') 117 | 118 | let &cpo = s:save_cpo 119 | unlet s:save_cpo 120 | -------------------------------------------------------------------------------- /autoload/ref/man.vim: -------------------------------------------------------------------------------- 1 | " A ref source for manpage. 2 | " Version: 0.4.3 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | scriptencoding utf-8 11 | 12 | " config. {{{1 13 | if !exists('g:ref_man_cmd') " {{{2 14 | " '-Tutf8' option is workaround for multi-byte environment. 15 | " The option might be unnecessary someday. 16 | let g:ref_man_cmd = executable('man') ? 'man -Tutf8' : '' 17 | endif 18 | 19 | if !exists('g:ref_man_lang') " {{{2 20 | let g:ref_man_lang = '' 21 | endif 22 | 23 | 24 | let s:source = {'name': 'man'} " {{{1 25 | 26 | function! s:source.available() 27 | return !empty(self.option('cmd')) 28 | endfunction 29 | 30 | function! s:source.get_body(query) 31 | let [query, sec] = s:parse(a:query) 32 | if sec !~# '\d' && v:count 33 | let sec = v:count 34 | endif 35 | let q = sec =~ '\d' ? [sec, query] : [query] 36 | 37 | let opt_lang = self.option('lang') 38 | if !empty(opt_lang) 39 | let lang = $LANG 40 | let $LANG = opt_lang 41 | endif 42 | try 43 | let use_vimproc = g:ref_use_vimproc 44 | let g:ref_use_vimproc = 0 45 | let res = ref#system(ref#to_list(self.option('cmd')) + q) 46 | finally 47 | if exists('lang') 48 | let $LANG = lang 49 | endif 50 | let g:ref_use_vimproc = use_vimproc 51 | endtry 52 | if !res.result 53 | let body = res.stdout 54 | if &termencoding != '' && &encoding != '' && &termencoding !=# &encoding 55 | let encoded = iconv(body, &termencoding, &encoding) 56 | if encoded != '' 57 | let body = encoded 58 | endif 59 | endif 60 | 61 | let body = substitute(body, '.\b', '', 'g') 62 | let body = substitute(body, '\e\[[0-9;]*m', '', 'g') 63 | let body = substitute(body, '‘', '`', 'g') 64 | let body = substitute(body, '’', "'", 'g') 65 | let body = substitute(body, '[−‐]', '-', 'g') 66 | let body = substitute(body, '·', 'o', 'g') 67 | 68 | return body 69 | endif 70 | let list = self.complete(a:query) 71 | if !empty(list) 72 | return list 73 | endif 74 | throw matchstr(res.stderr, '^\_s*\zs.\{-}\ze\_s*$') 75 | endfunction 76 | 77 | function! s:source.opened(query) 78 | call s:syntax() 79 | endfunction 80 | 81 | function! s:source.get_keyword() 82 | return ref#get_text_on_cursor('[[:alnum:]_.:+-]\+\%((\d)\)\?') 83 | endfunction 84 | 85 | function! s:source.complete(query) 86 | let [query, sec] = s:parse(a:query) 87 | let sec -= 0 " to number 88 | 89 | return filter(copy(self.cache(sec, self)), 90 | \ 'v:val =~# "^\\V" . query') 91 | endfunction 92 | 93 | function! s:source.normalize(query) 94 | let [query, sec] = s:parse(a:query) 95 | return query . (sec == '' ? '' : '(' . sec . ')') 96 | endfunction 97 | 98 | function! s:source.call(name) 99 | let list = [] 100 | if a:name is 0 101 | for n in range(1, 9) 102 | let list += self.cache(n, self) 103 | endfor 104 | 105 | else 106 | let manpath = self.option('manpath') 107 | let pat = '.*/\zs.*\ze\.\d\w*\%(\.\w\+\)\?$' 108 | for path in split(matchstr(manpath, '^.\{-}\ze\_s*$'), ':') 109 | let dir = path . '/man' . a:name 110 | if isdirectory(dir) 111 | let list += map(split(glob(dir . '*/*'), "\n"), 112 | \ 'matchstr(v:val, pat)') 113 | endif 114 | endfor 115 | endif 116 | 117 | return ref#uniq(list) 118 | endfunction 119 | 120 | function! s:source.option(opt) 121 | if a:opt ==# 'manpath' 122 | let manpath = exists('g:ref_man_manpath') ? g:ref_man_manpath : $MANPATH 123 | let manpath = ':' . manpath . ':' 124 | if manpath =~# '::' 125 | let sys_manpath = ref#system('manpath').stdout 126 | let sys_manpath = ':' . substitute(sys_manpath, '\n.*', '', '') . ':' 127 | let manpath = substitute(manpath, '::', '\=sys_manpath', 'g') 128 | let manpath = substitute(manpath, '^:\+\|:\{2,}\|:\+$', '', 'g') 129 | endif 130 | return manpath 131 | endif 132 | return g:ref_man_{a:opt} 133 | endfunction 134 | 135 | function! s:parse(query) 136 | let l = matchlist(a:query, '\([^[:space:]()]\+\)\s*(\(\d\))$') 137 | if !empty(l) 138 | return l[1 : 2] 139 | endif 140 | let l = matchlist(a:query, '\(\d\)\s\+\(\S*\)') 141 | if !empty(l) 142 | return [l[2], l[1]] 143 | endif 144 | return [a:query, ''] 145 | endfunction 146 | 147 | function! s:syntax() 148 | let list = !search('^\s', 'wn') 149 | if exists('b:current_syntax') ? (b:current_syntax ==# 'man' && !list) : list 150 | return 151 | endif 152 | 153 | syntax clear 154 | 155 | if !list 156 | runtime! syntax/man.vim 157 | endif 158 | endfunction 159 | 160 | function! ref#man#define() 161 | return copy(s:source) 162 | endfunction 163 | 164 | call ref#register_detection('c', 'man') 165 | call ref#register_detection('cpp', 'man') 166 | 167 | let &cpo = s:save_cpo 168 | unlet s:save_cpo 169 | -------------------------------------------------------------------------------- /autoload/ref/perldoc.vim: -------------------------------------------------------------------------------- 1 | " A ref source for perldoc. 2 | " Version: 0.3.4 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | " config. {{{1 11 | if !exists('g:ref_perldoc_cmd') " {{{2 12 | let g:ref_perldoc_cmd = executable('perldoc') ? 'perldoc' : '' 13 | endif 14 | 15 | if !exists('g:ref_perldoc_complete_head') " {{{2 16 | let g:ref_perldoc_complete_head = 0 17 | endif 18 | 19 | if !exists('g:ref_perldoc_auto_append_f') " {{{2 20 | let g:ref_perldoc_auto_append_f = 0 21 | endif 22 | 23 | let s:source = {'name': 'perldoc'} " {{{1 24 | 25 | function! s:source.available() 26 | return len(g:ref_perldoc_cmd) 27 | endfunction 28 | 29 | function! s:source.get_body(query) 30 | let q = matchstr(a:query, '\v%(^|\s)\zs[^-]\S*') 31 | 32 | let cand = s:appropriate_list(a:query) 33 | let hit = 0 <= index(cand, q) 34 | if !hit 35 | let list = s:match(cand, q) 36 | if !empty(list) 37 | return list 38 | endif 39 | endif 40 | 41 | let cmdarg = ['-T', '-o', 'text'] 42 | if a:query =~# '-f\>' || 43 | \ (hit && index(s:list('modules') + s:list('basepod'), q) < 0) 44 | let cmdarg += ['-f'] 45 | elseif a:query =~# '-m\>' 46 | let cmdarg += ['-m'] 47 | endif 48 | 49 | let res = ref#system(s:perldoc_cmd() + cmdarg + [q]) 50 | 51 | if res.stdout == '' 52 | throw printf('No documentation found for "%s".', q) 53 | endif 54 | return res.stdout 55 | endfunction 56 | 57 | function! s:source.opened(query) 58 | let b:ref_perldoc_word = matchstr(a:query, '-\@ (ref-source-perldoc-switch) 69 | \ b:ref_perldoc_mode ==# 'module' ? ":\Ref perldoc -m " . 70 | \ b:ref_perldoc_word . "\" : 71 | \ b:ref_perldoc_mode ==# 'source' ? ":\Ref perldoc " . 72 | \ b:ref_perldoc_word . "\" : 73 | \ '' 74 | 75 | silent! nmap s (ref-source-perldoc-switch) 76 | 77 | call s:syntax(mode) 78 | endfunction 79 | 80 | function! s:source.complete(query) 81 | let q = a:query == '' || a:query =~ '\s$' ? '' : split(a:query)[-1] 82 | if q =~ '-' 83 | return ['-f', '-m'] 84 | endif 85 | 86 | let list = s:appropriate_list(a:query) 87 | return g:ref_perldoc_complete_head ? s:head(list, q) : s:match(list, q) 88 | endfunction 89 | 90 | function! s:source.get_keyword() 91 | let isk = &l:iskeyword 92 | setlocal isk& isk+=: 93 | let kwd = expand('') 94 | let &l:iskeyword = isk 95 | return kwd 96 | endfunction 97 | 98 | let s:functions = [] 99 | function! s:source.normalize(query) 100 | let query = a:query 101 | if g:ref_perldoc_auto_append_f && query =~# '^[a-z]\+$' 102 | if empty(s:functions) 103 | let s:functions = s:func_list('') 104 | endif 105 | if index(s:functions, query) !=# -1 106 | " lower case, match function name, assume it to be built-in function 107 | let query = '-f ' . query 108 | endif 109 | endif 110 | return query 111 | endfunction 112 | 113 | function! s:source.leave() 114 | unlet! b:ref_perldoc_mode b:ref_perldoc_word 115 | silent! nunmap (ref-source-perldoc-switch) 116 | " FIXME: The following is not able to customize. 117 | silent! nunmap s 118 | endfunction 119 | 120 | 121 | " functions. {{{1 122 | function! s:syntax(mode) 123 | if exists('b:current_syntax') 124 | \ && ((a:mode ==# 'source' && b:current_syntax ==# 'perl') || 125 | \ (a:mode ==# 'perl' && b:current_syntax ==# 'ref-perldoc-perl') || 126 | \ (a:mode ==# 'module' && b:current_syntax ==# 'ref-perldoc-module') || 127 | \ (a:mode ==# 'func' && b:current_syntax ==# 'ref-perldoc-func')) 128 | return 129 | endif 130 | 131 | syntax clear 132 | unlet! b:current_syntax 133 | 134 | if a:mode ==# 'list' 135 | return 136 | endif 137 | 138 | if a:mode ==# 'source' 139 | runtime! syntax/perl.vim 140 | return 141 | endif 142 | 143 | 144 | syntax include @refPerldocPerl syntax/perl.vim 145 | " if exists('perl_fold'), above set foldmethod=syntax and sometimes too slow. so disable it. 146 | setlocal foldmethod=manual 147 | 148 | " Adjust the end of heredoc. 149 | syntax clear perlHereDoc 150 | " Copy from syntax/perl.vim 151 | syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+\z1$+ contains=@perlInterpDQ 152 | syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+\z1$+ contains=@perlInterpDQ 153 | syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+\z1$+ contains=@perlInterpSQ 154 | syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+$+ contains=@perlInterpDQ,perlNotEmptyLine 155 | syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+$+ contains=@perlInterpSQ,perlNotEmptyLine 156 | 157 | if a:mode ==# 'func' 158 | call s:indent_region('refPerldocRegion', 16, 'contains=@refPerldocPerl') 159 | syntax match refPerldocTitle '^ \{4}\l\+' 160 | else 161 | syntax match refPerldocTitle '^\u.\+$' 162 | 163 | if a:mode ==# 'module' 164 | syntax region refPerldocSynopsis matchgroup=refPerldocTitle start=/^SYNOPSIS/ end=/\n\ze\S/ contains=@refPerldocPerl 165 | endif 166 | 167 | call s:indent_region('refPerldocRegion', 6, 'contains=@refPerldocPerl') 168 | 169 | syntax region refPerldocList start=/^ \{4}\ze\%(\*\|\d\+\.\)/ end=/\n\+\ze \{,3}\S/ contains=refPerldocRegionInList 170 | call s:indent_region('refPerldocRegionInList', 10, 'contains=@refPerldocPerl contained') 171 | 172 | endif 173 | 174 | 175 | syntax match refPerldocString /"\_.\{-}"/ 176 | 177 | highlight default link refPerldocTitle Title 178 | highlight default link refPerldocString Constant 179 | 180 | let b:current_syntax = 'ref-perldoc-' . a:mode 181 | endfunction 182 | 183 | function! s:indent_region(name, indent, option) 184 | execute 'syntax region' a:name 185 | \ 'start=/^ \{' . a:indent . '}\ze\S/' 186 | \ 'end=/\n\+\ze \{,' . (a:indent - 1) . '}\S/' a:option 187 | endfunction 188 | 189 | function! s:appropriate_list(query) 190 | return a:query =~# '-f\>' ? s:list('func'): 191 | \ a:query =~# '-m\>' ? s:list('modules'): 192 | \ s:list('modules') + s:list('basepod') 193 | endfunction 194 | 195 | function! s:match(list, str) 196 | let matched = filter(copy(a:list), 'v:val =~? "^\\V" . a:str') 197 | if empty(matched) 198 | let matched = filter(copy(a:list), 'v:val =~? "\\V" . a:str') 199 | endif 200 | return matched 201 | endfunction 202 | 203 | function! s:head(list, query) 204 | let pat = '^\V' . a:query . '\w\*\v(::)?\zs.*$' 205 | return ref#uniq(map(filter(copy(a:list), 'v:val =~# pat'), 206 | \ 'substitute(v:val, pat, "", "")')) 207 | endfunction 208 | 209 | function! s:list(name) 210 | return ref#cache('perldoc', a:name, s:func(a:name . '_list')) 211 | endfunction 212 | 213 | function! s:basepod_list(name) 214 | let basepods = [] 215 | let base = ref#system(s:perl_cmd() + ['-MConfig', '-e', 216 | \ 'print $Config{installprivlib}']).stdout 217 | for dir in ['pod', 'pods'] 218 | if filereadable(printf('%s/%s/perl.pod', base, dir)) 219 | let base .= '/' . dir 220 | break 221 | endif 222 | endfor 223 | 224 | if isdirectory(base) 225 | let basepods = map(split(glob(base . '/*.pod'), "\n"), 226 | \ 'fnamemodify(v:val, ":t:r")') 227 | endif 228 | 229 | return basepods 230 | endfunction 231 | 232 | function! s:modules_list(name) 233 | let inc = ref#system(s:perl_cmd() + ['-e', 'print join('';'', @INC)']).stdout 234 | let sep = '[/\\]' 235 | let files = {} 236 | let modules = [] 237 | for i in split(inc, ';') 238 | let f = split(glob(i . '/**/*.pm', 0), "\n") 239 | \ + split(glob(i . '/**/*.pod', 0), "\n") 240 | call filter(f, '!has_key(files, v:val)') 241 | for file in f 242 | let files[file] = 1 243 | endfor 244 | let l = len(i) + 1 245 | let modules += map(f, 246 | \ 'substitute(fnamemodify(v:val, ":r")[l :], sep, "::", "g")') 247 | endfor 248 | 249 | return ref#uniq(modules) 250 | endfunction 251 | 252 | function! s:func_list(name) 253 | let doc = ref#system(s:perldoc_cmd() + ['-u', 'perlfunc']).stdout 254 | let i = 0 255 | let funcs = [] 256 | while 1 257 | let n = match(doc, 'item \l\+', i) 258 | if n < 0 259 | break 260 | endif 261 | call add(funcs, matchstr(doc, 'item \zs\l\+', i)) 262 | let i = n + 1 263 | endwhile 264 | return ref#uniq(funcs) 265 | endfunction 266 | 267 | function! s:func(name) 268 | return function(matchstr(expand(''), '\d\+_\zefunc$') . a:name) 269 | endfunction 270 | 271 | function! s:perl_cmd() 272 | if filereadable('cpanfile.snapshot') && executable('carton') 273 | return ['carton', 'exec', '--', 'perl'] 274 | else 275 | return ['perl'] 276 | endif 277 | endfunction 278 | 279 | function! s:perldoc_cmd() 280 | if filereadable('cpanfile.snapshot') && executable('carton') 281 | return ['carton', 'exec', '--', 'perldoc'] 282 | else 283 | return type(g:ref_perldoc_cmd) == type('') ? 284 | \ split(g:ref_perldoc_cmd, '\s\+') : g:ref_perldoc_cmd 285 | endif 286 | endfunction 287 | 288 | function! ref#perldoc#define() 289 | return s:source 290 | endfunction 291 | 292 | call ref#register_detection('perl', 'perldoc') 293 | 294 | let &cpo = s:save_cpo 295 | unlet s:save_cpo 296 | -------------------------------------------------------------------------------- /autoload/ref/phpmanual.vim: -------------------------------------------------------------------------------- 1 | " A ref source for php manual. 2 | " Version: 0.3.1 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | " config. {{{1 11 | if !exists('g:ref_phpmanual_path') " {{{2 12 | let g:ref_phpmanual_path = '' 13 | endif 14 | 15 | if !exists('g:ref_phpmanual_cmd') " {{{2 16 | let g:ref_phpmanual_cmd = 17 | \ executable('elinks') ? 'elinks -dump -no-numbering -no-references %s' : 18 | \ executable('w3m') ? 'w3m -dump %s' : 19 | \ executable('links') ? 'links -dump %s' : 20 | \ executable('lynx') ? 'lynx -dump -nonumbers %s' : 21 | \ '' 22 | endif 23 | 24 | 25 | let s:source = {'name': 'phpmanual'} " {{{1 26 | 27 | function! s:source.available() 28 | return isdirectory(g:ref_phpmanual_path) && 29 | \ len(g:ref_phpmanual_cmd) 30 | endfunction 31 | 32 | function! s:source.get_body(query) 33 | let name = substitute(tolower(a:query), '_', '-', 'g') 34 | let pre = g:ref_phpmanual_path . '/' 35 | 36 | if name =~ '::' 37 | let file = pre . substitute(name, '::', '.', 'g') . '.html' 38 | if filereadable(file) 39 | return s:execute(file) 40 | endif 41 | let name = substitute(name, '::', '-', 'g') 42 | endif 43 | 44 | for section in ['function.', 'ref.', 'class.', ''] 45 | let file = pre . section . name . '.html' 46 | if filereadable(file) 47 | return s:execute(file) 48 | endif 49 | endfor 50 | 51 | if name == '' 52 | return s:cache('function') + s:cache('ref') + s:cache('class') 53 | endif 54 | 55 | for pat in ['%s.*', '*.%s.*', 'function.*%s*.html'] 56 | let file = glob(pre . printf(pat, name)) 57 | if file != '' 58 | let files = split(file, "\n") 59 | if len(files) == 1 60 | return s:execute(files[0]) 61 | endif 62 | return substitute(join( 63 | \ map(files, 'matchstr(v:val, ".*[/\\\\]\\zs\\S*\\ze\\.html$")'), 64 | \ "\n"), '-', '_', 'g') 65 | endif 66 | endfor 67 | 68 | throw 'no match: ' . a:query 69 | endfunction 70 | 71 | function! s:source.opened(query) 72 | call s:syntax() 73 | endfunction 74 | 75 | function! s:source.complete(query) 76 | let name = substitute(tolower(a:query), '::', '_', 'g') 77 | let pre = g:ref_phpmanual_path . '/' 78 | 79 | for kind in ['function', 'ref', 'class'] 80 | let list = filter(copy(s:cache(kind)), 'v:val =~# name') 81 | if list != [] 82 | return list 83 | endif 84 | endfor 85 | return [] 86 | endfunction 87 | 88 | function! s:source.get_keyword() 89 | let isk = &l:isk 90 | setlocal isk& isk+=- isk+=. isk+=: 91 | let kwd = expand('') 92 | let &l:isk = isk 93 | return kwd 94 | endfunction 95 | 96 | 97 | " functions. {{{1 98 | function! s:syntax() 99 | if exists('b:current_syntax') && b:current_syntax == 'ref-phpmanual' 100 | return 101 | endif 102 | 103 | syntax clear 104 | 105 | unlet! b:current_syntax 106 | syntax include @refPhpmanualPHP syntax/php.vim 107 | syntax match refPhpmanualFunc '\h\w*\ze()' 108 | 109 | syn region phpRegion matchgroup=Delimiter start="" contains=@phpClTop 110 | 111 | highlight default link refPhpmanualFunc phpFunctions 112 | 113 | let b:current_syntax = 'ref-phpmanual' 114 | endfunction 115 | 116 | function! s:execute(file) 117 | if type(g:ref_phpmanual_cmd) == type('') 118 | let cmd = split(g:ref_phpmanual_cmd, '\s\+') 119 | elseif type(g:ref_phpmanual_cmd) == type([]) 120 | let cmd = copy(g:ref_phpmanual_cmd) 121 | else 122 | return '' 123 | endif 124 | 125 | let file = escape(a:file, '\') 126 | let res = ref#system(map(cmd, 'substitute(v:val, "%s", file, "g")')).stdout 127 | if &termencoding != '' && &termencoding !=# &encoding 128 | let converted = iconv(res, &termencoding, &encoding) 129 | if converted != '' 130 | let res = converted 131 | endif 132 | endif 133 | return res 134 | endfunction 135 | 136 | function! s:gather_func(name) 137 | let list = glob(g:ref_phpmanual_path . '/' . a:name . '.*.html') 138 | let pat = a:name . '\.\zs.*\ze\.html$' 139 | return map(split(list, "\n"), 140 | \ 'substitute(matchstr(v:val, pat), "-", "_", "g")') 141 | endfunction 142 | 143 | function! s:func(name) 144 | return function(matchstr(expand(''), '\d\+_\zefunc$') . a:name) 145 | endfunction 146 | 147 | function! s:cache(kind) 148 | return ref#cache('phpmanual', a:kind, s:func('gather_func')) 149 | endfunction 150 | 151 | function! ref#phpmanual#define() 152 | return s:source 153 | endfunction 154 | 155 | call ref#register_detection('php', 'phpmanual') 156 | 157 | let &cpo = s:save_cpo 158 | unlet s:save_cpo 159 | -------------------------------------------------------------------------------- /autoload/ref/pydoc.vim: -------------------------------------------------------------------------------- 1 | " A ref source for pydoc. 2 | " Version: 0.4.2 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | " options. {{{1 11 | if !exists('g:ref_pydoc_cmd') " {{{2 12 | let g:ref_pydoc_cmd = executable('python') ? 'python -m pydoc' : '' 13 | endif 14 | 15 | if !exists('g:ref_pydoc_complete_head') " {{{2 16 | let g:ref_pydoc_complete_head = 0 17 | endif 18 | 19 | 20 | let s:source = {'name': 'pydoc'} " {{{1 21 | 22 | function! s:source.available() 23 | return !empty(g:ref_pydoc_cmd) 24 | endfunction 25 | 26 | function! s:source.get_body(query) 27 | if a:query != '' 28 | let content = ref#system(ref#to_list(g:ref_pydoc_cmd, a:query)).stdout 29 | if content !~# '^no Python documentation found' 30 | return content 31 | endif 32 | endif 33 | 34 | let list = self.complete(a:query) 35 | if list == [] 36 | throw split(content, "\n")[0] 37 | endif 38 | if len(list) == 1 39 | return ref#system(ref#to_list(g:ref_pydoc_cmd, list)).stdout 40 | endif 41 | return list 42 | endfunction 43 | 44 | function! s:source.opened(query) 45 | call s:syntax(s:get_info()[0]) 46 | endfunction 47 | 48 | function! s:source.complete(query) 49 | let cmd = ref#to_list(g:ref_pydoc_cmd, '-k .') 50 | let mapexpr = 'matchstr(v:val, "^[[:alnum:]._]*")' 51 | let all_list = self.cache('list', 52 | \ printf('map(split(ref#system(%s).stdout, "\n"), %s)', 53 | \ string(cmd), string(mapexpr))) 54 | 55 | if g:ref_pydoc_complete_head 56 | let q = a:query == '' || a:query =~ '\s$' ? '' : split(a:query)[-1] 57 | let all_list = s:head(all_list, q) 58 | endif 59 | 60 | let list = filter(copy(all_list), 'v:val =~# "^\\V" . a:query') 61 | if !empty(list) 62 | return list 63 | endif 64 | return filter(copy(all_list), 'v:val =~# "\\V" . a:query') 65 | endfunction 66 | 67 | function! s:source.get_keyword() 68 | if &l:filetype ==# 'ref-pydoc' 69 | let [type, name, scope] = s:get_info() 70 | 71 | if type ==# 'package' || type ==# 'module' 72 | let line = getline('.') 73 | 74 | let secline = search('^\u[A-Z ]*\u$', 'bnW') 75 | let section = secline == 0 ? '' : getline(secline) 76 | 77 | if section ==# 'PACKAGE CONTENTS' 78 | let package = matchstr(line, '^\s*\zs\S\+') 79 | if package != '' 80 | return name . '.' . package 81 | endif 82 | endif 83 | 84 | if section ==# 'CLASSES' 85 | let class = matchstr(line, '^\s*class \zs\k\+') 86 | if class != '' 87 | return printf('%s.%s', name, class) 88 | endif 89 | 90 | let class = matchstr(line, '^\s*\zs[[:alnum:].]\+') 91 | if class != '' 92 | if type ==# 'package' 93 | return class 94 | endif 95 | return printf('%s.%s', name, class) 96 | endif 97 | 98 | let class = matchstr(line, '^\s*\zs\k\+\ze = class') 99 | if class != '' 100 | return printf('%s.%s', name, class) 101 | endif 102 | 103 | let method = matchstr(line, '^ | \zs\k\+\ze(.*)$') 104 | if method != '' 105 | call search('^ \%(class \k\+\|\k\+\ze = class\)', 'beW') 106 | return printf('%s.%s.%s', name, expand(''), method) 107 | endif 108 | endif 109 | 110 | let func = matchstr(line, '^ \zs\k\+\ze(.*)$') 111 | if func != '' 112 | return name . '.' . func 113 | endif 114 | 115 | elseif type ==# 'class' 116 | let m = matchstr(getline('.'), '^ | \zs\k\+\ze(.*)$') 117 | if m != '' 118 | return printf('%s.%s.%s', scope, name, m) 119 | endif 120 | 121 | endif 122 | 123 | if type !=# 'list' 124 | " xxx.yy*y.zzzClass -> xxx.yyy (* means cursor) 125 | let line = getline('.') 126 | let [pre, post] = [line[: col('.') - 2], line[col('.') - 1 :]] 127 | let kwd = matchstr(pre, '\v%(\k|\.)*$') . matchstr(post, '^\k*') 128 | if kwd != '' 129 | return kwd 130 | endif 131 | endif 132 | else 133 | " In Python code. 134 | let module = s:ExpandModulePath() 135 | if module != '' 136 | return module 137 | endif 138 | endif 139 | 140 | return ref#get_text_on_cursor('[[:alnum:].]\+') 141 | endfunction 142 | 143 | 144 | " functions {{{1 145 | 146 | " Get informations of current document. 147 | " [type, name, scope] 148 | " type: 149 | " - package 150 | " - module 151 | " - class 152 | " - method 153 | " - function 154 | " - list (matched list) 155 | " name: 156 | " package name, module name, class name, method name, or function name. 157 | " scope: 158 | " Scope. 159 | function! s:get_info() 160 | let isk = &l:isk 161 | setlocal isk& isk+=. 162 | 163 | let list = matchlist(getline(1), 164 | \ '\v^Help on %(built-in )?(%(\w|-)+)%( (\k+))?%( in %(\w+ )?(\k+))?:') 165 | 166 | let &l:isk = isk 167 | if list == [] 168 | return ['list', '', ''] 169 | endif 170 | return list[1 : 3] 171 | endfunction 172 | 173 | function! s:syntax(type) 174 | if a:type ==# 'list' 175 | syntax clear 176 | return 177 | elseif exists('b:current_syntax') && b:current_syntax ==# 'ref-pydoc' 178 | return 179 | endif 180 | 181 | syntax clear 182 | 183 | 184 | syntax match refPydocHeader '^[[:upper:][:space:]]\+$' 185 | syntax match refPydocClass '^ class\>' nextgroup=refPydocClassName skipwhite 186 | syntax match refPydocClassName '\k\+' contained 187 | syntax match refPydocMethod '\k\+\ze(' 188 | syntax match refPydocVertical '^\s\+|' 189 | syntax match refPydocHorizon '--------------------------------------------*' 190 | 191 | highlight default link refPydocHeader Type 192 | highlight default link refPydocClass Statement 193 | highlight default link refPydocClassName Identifier 194 | highlight default link refPydocMethod Function 195 | highlight default link refPydocVertical PreProc 196 | highlight default link refPydocHorizon PreProc 197 | 198 | let b:current_syntax = 'ref-pydoc' 199 | endfunction 200 | 201 | function! s:head(list, query) 202 | let pat = '^\V' . a:query . '\v\w*(\.)?\zs.*$' 203 | return ref#uniq(map(filter(copy(a:list), 'v:val =~# pat'), 204 | \ 'substitute(v:val, pat, "", "")')) 205 | endfunction 206 | 207 | function! s:ExpandModulePath() 208 | " Extract the 'word' at the cursor, expanding leftwards across identifiers 209 | " and the . operator, and rightwards across the identifier only. 210 | " 211 | " For example: 212 | " import xml.dom.minidom 213 | " ^ ! 214 | " 215 | " With the cursor at ^ this returns 'xml'; at ! it returns 'xml.dom'. 216 | " 217 | " Source: https://github.com/fs111/pydoc.vim/blob/master/ftplugin/python_pydoc.vim 218 | let l:line = getline(".") 219 | let l:pre = l:line[:col(".") - 1] 220 | let l:suf = l:line[col("."):] 221 | return matchstr(pre, "[A-Za-z0-9_.]*$") . matchstr(suf, "^[A-Za-z0-9_]*") 222 | endfunction 223 | 224 | function! ref#pydoc#define() 225 | return copy(s:source) 226 | endfunction 227 | 228 | call ref#register_detection('python', 'pydoc') 229 | 230 | let &cpo = s:save_cpo 231 | unlet s:save_cpo 232 | -------------------------------------------------------------------------------- /autoload/ref/redis.vim: -------------------------------------------------------------------------------- 1 | " A ref source for redis. 2 | " Version: 0.0.1 3 | " Author : walf443 4 | " : thinca 5 | " License: Creative Commons Attribution 2.1 Japan License 6 | " 7 | 8 | " this code is based from autoload/ref/rfc.vim 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | " options. {{{1 13 | if !exists('g:ref_redis_start_linenumber') " {{{2 14 | let g:ref_redis_start_linenumber = 5 15 | endif 16 | 17 | if !exists('g:ref_redis_cmd') " {{{2 18 | let g:ref_redis_cmd = 19 | \ executable('elinks') ? 'elinks -dump -no-numbering -no-references %s' : 20 | \ executable('w3m') ? 'w3m -dump %s' : 21 | \ executable('links') ? 'links -dump %s' : 22 | \ executable('lynx') ? 'lynx -dump -nonumbers %s' : 23 | \ len(globpath(&rtp, 'autoload/wwwrenderer.vim')) > 0 24 | \ ? '=wwwrenderer#render("%s")' : 25 | \ '' 26 | endif 27 | 28 | if !exists('g:ref_redis_encoding') " {{{2 29 | let g:ref_redis_encoding = &termencoding 30 | endif 31 | 32 | if !exists('g:ref_redis_use_cache') " {{{2 33 | let g:ref_redis_use_cache = 0 34 | endif 35 | 36 | let s:source = {'name': 'redis'} " {{{1 37 | 38 | function! s:source.available() 39 | return !empty(g:ref_redis_cmd) 40 | endfunction 41 | 42 | function! s:source.get_keyword() 43 | let isk = &l:iskeyword 44 | setlocal isk& isk+=- 45 | let kwd = expand('') 46 | let &l:iskeyword = isk 47 | return kwd 48 | endfunction 49 | 50 | function! s:source.complete(query) 51 | let q = a:query == '' || a:query =~ '\s$' ? '' : split(a:query)[-1] 52 | 53 | let list = s:list() 54 | let q = toupper(q) 55 | return s:head(list, q) 56 | endfunction 57 | 58 | function! s:source.get_body(query) 59 | if type(g:ref_redis_cmd) == type('') 60 | let cmd = split(g:ref_redis_cmd, '\s\+') 61 | elseif type(g:ref_redis_cmd) == type([]) 62 | let cmd = copy(g:ref_redis_cmd) 63 | else 64 | return '' 65 | endif 66 | 67 | let str = toupper(a:query) 68 | let cand = s:list() 69 | let hit = 0 <= index(cand, str) 70 | if !hit 71 | let list = s:match(cand, str) 72 | if !empty(list) 73 | return list 74 | endif 75 | throw printf('No documentation found for "%s".', str) 76 | endif 77 | 78 | let url = 'http://redis.io/commands/' . str 79 | call map(cmd, 'substitute(v:val, "%s", url, "g")') 80 | if len(cmd) > 0 && cmd[0] =~ '^=' 81 | let res = eval(join(cmd, ' ')[1:]) 82 | elseif len(cmd) > 0 && cmd[0] =~ '^:' 83 | redir => res 84 | silent! exe join(cmd, ' ')[1:] 85 | redir END 86 | elseif g:ref_redis_use_cache 87 | let expr = 'ref#system(' . string(cmd) . ').stdout' 88 | let res = join(ref#cache('redis', str, expr), "\n") 89 | else 90 | let res = ref#system(cmd).stdout 91 | endif 92 | " let res = substitute(res, 'Related commands\r\n\r\n.*\r\n\r\n\r\n', '\r\n', '') 93 | 94 | " delete related commands 95 | let res = substitute(res, 'Related commands\n\n.*\n\n\s*Available', ' Available', '') 96 | return s:iconv(res, g:ref_redis_encoding, &encoding) 97 | endfunction 98 | 99 | function! s:source.opened(query) 100 | let cand = s:list() 101 | let hit = 0 <= index(cand, a:query) 102 | if hit 103 | execute "normal! ".g:ref_redis_start_linenumber."z\" 104 | call s:syntax(a:query) 105 | endif 106 | endfunction 107 | 108 | function! s:source.normalize(query) 109 | return substitute(substitute(a:query, '\_s\+', ' ', 'g'), '^ \| $', '', 'g') 110 | endfunction 111 | 112 | 113 | " misc. {{{1 114 | function! s:syntax(query) 115 | if ( exists('b:current_syntax') && ( b:current_syntax ==# 'ref-redis' ) ) 116 | return 117 | endif 118 | 119 | syntax clear 120 | unlet! b:current_syntax 121 | let commands = map(copy(s:list()), 'substitute(v:val, "-", " ", "")') 122 | syntax case match 123 | for keyword in commands 124 | execute 'syntax match refRedisCommand "\<'.keyword.'\>"' 125 | endfor 126 | highlight default link refRedisCommand Special 127 | 128 | let b:current_syntax = 'ref-redis' 129 | endfunction 130 | 131 | " iconv() wrapper for safety. 132 | function! s:iconv(expr, from, to) 133 | if a:from == '' || a:to == '' || a:from ==# a:to 134 | return a:expr 135 | endif 136 | let result = iconv(a:expr, a:from, a:to) 137 | return result != '' ? result : a:expr 138 | endfunction 139 | 140 | function! s:list() 141 | return ref#cache('redis', 'command_list', s:func('redis_command_list')) 142 | endfunction 143 | 144 | function! s:head(list, query) 145 | let pat = '^\V' . a:query . '\S\*\v\zs.*$' 146 | return ref#uniq(map(filter(copy(a:list), 'v:val =~# pat'), 147 | \ 'substitute(v:val, pat, "", "")')) 148 | endfunction 149 | 150 | function! s:match(list, str) 151 | let matched = filter(copy(a:list), 'v:val =~? "^\\V" . a:str') 152 | if empty(matched) 153 | let matched = filter(copy(a:list), 'v:val =~? "\\V" . a:str') 154 | endif 155 | return matched 156 | endfunction 157 | 158 | function! s:func(name) 159 | return function(matchstr(expand(''), '\d\+_\zefunc$') . a:name) 160 | endfunction 161 | 162 | function! s:redis_command_list(dummy) 163 | let commands = [] 164 | if type(g:ref_redis_cmd) == type('') 165 | let cmd = split(g:ref_redis_cmd, '\s\+') 166 | elseif type(g:ref_redis_cmd) == type([]) 167 | let cmd = copy(g:ref_redis_cmd) 168 | else 169 | return '' 170 | endif 171 | let url = 'http://redis.io/commands' 172 | call map(cmd, 'substitute(v:val, "%s", url, "g")') 173 | 174 | let res = ref#system(cmd).stdout 175 | for line in split(res, "\n") 176 | let matches = matchlist(line, '\(\u\+\s\%(\u\{2,}\s\)\?\)') 177 | if !empty(matches) && len(matches) > 1 178 | let result = toupper(substitute( 179 | \ substitute(matches[1], '\s$', '', ''), '\s', '-', '')) 180 | call add(commands, result) 181 | endif 182 | endfor 183 | 184 | return commands 185 | endfunction 186 | 187 | function! ref#redis#define() 188 | return s:source 189 | endfunction 190 | 191 | let &cpo = s:save_cpo 192 | unlet s:save_cpo 193 | -------------------------------------------------------------------------------- /autoload/ref/refe.vim: -------------------------------------------------------------------------------- 1 | " A ref source for ReFe. 2 | " Version: 0.4.0 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | " options. {{{1 11 | if !exists('g:ref_refe_cmd') " {{{2 12 | let g:ref_refe_cmd = executable('refe') ? 'refe' : '' 13 | endif 14 | let s:cmd = g:ref_refe_cmd 15 | 16 | if !exists('g:ref_refe_encoding') " {{{2 17 | let g:ref_refe_encoding = &termencoding 18 | endif 19 | 20 | if !exists('g:ref_refe_rsense_cmd') " {{{2 21 | let g:ref_refe_rsense_cmd = '' 22 | endif 23 | 24 | 25 | let s:source = {'name': 'refe'} " {{{1 26 | 27 | function! s:source.available() 28 | return !empty(g:ref_refe_cmd) 29 | endfunction 30 | 31 | function! s:source.get_body(query) 32 | let res = s:refe(a:query) 33 | if res.stderr != '' 34 | throw matchstr(res.stderr, '^.\{-}\ze\n') 35 | endif 36 | 37 | let content = res.stdout 38 | if s:refe_version() == 2 39 | " is class or module? 40 | let class = matchstr(content, '^\v%(require\s+\S+\n\n)?%(class|module) \zs%(\w|\:)+') 41 | if class != '' 42 | for [type, sep] in [['Singleton', '.'], ['Instance', '#']] 43 | let refe_result = s:refe(class . sep) 44 | if refe_result.result != 0 " Members not found 45 | let members = '' 46 | else 47 | let members = refe_result.stdout 48 | let members = substitute(members, '\V' . class . sep, '', 'g') 49 | endif 50 | let content .= "\n\n---- " . type . " methods ----\n" . members 51 | endfor 52 | endif 53 | endif 54 | 55 | if exists('g:ref_refe_encoding') && 56 | \ !empty(g:ref_refe_encoding) && g:ref_refe_encoding != &encoding 57 | let converted = iconv(content, g:ref_refe_encoding, &encoding) 58 | if converted != '' 59 | let content = converted 60 | endif 61 | endif 62 | 63 | return content 64 | endfunction 65 | 66 | function! s:source.opened(query) 67 | let [type, _] = s:detect_type() 68 | let ver = s:refe_version() 69 | 70 | if type ==# 'list' 71 | silent! %s/ /\r/ge 72 | silent! global/^\s*$/delete _ 73 | endif 74 | 75 | if type ==# 'class' && ver == 1 76 | silent! %s/[^[:return:]]\n\zs\ze----/\r/ge 77 | endif 78 | call s:syntax(type) 79 | 1 80 | endfunction 81 | 82 | function! s:source.complete(query) 83 | let option = s:refe_version() == 2 ? ['-l'] : ['-l', '-s'] 84 | return split(s:refe(option + ref#to_list(a:query)).stdout, "\n") 85 | endfunction 86 | 87 | function! s:source.special_char_p(ch) 88 | return a:ch == '#' 89 | endfunction 90 | 91 | function! s:source.get_keyword() 92 | let id = '\v\w+[!?]?' 93 | let pos = getpos('.')[1:] 94 | 95 | if &l:filetype ==# 'ref-refe' 96 | let [type, name] = s:detect_type() 97 | 98 | if type ==# 'list' 99 | return getline(pos[0]) 100 | endif 101 | 102 | if type ==# 'class' 103 | if getline('.') =~ '^----' 104 | return '' 105 | endif 106 | let section = search('^---- \w* methods', 'bnW') 107 | if section != 0 108 | let sep = matchstr(getline(section), '^---- \zs\w*\ze methods') 109 | let sep = {'Singleton' : '.', 'Instance' : '#'}[sep] 110 | return name . sep . expand('') 111 | endif 112 | endif 113 | 114 | if s:refe_version() == 2 115 | let kwd = ref#get_text_on_cursor('\[\[\zs.\{-}\ze\]\]') 116 | 117 | if kwd != '' 118 | if kwd =~# '^man:' 119 | return ['man', matchstr(kwd, '^man:\zs.*$')] 120 | endif 121 | return matchstr(kwd, '^\%(\w:\)\?\zs.*$') 122 | endif 123 | endif 124 | 125 | else 126 | " Literals 127 | let syn = synIDattr(synID(line('.'), col('.'), 1), 'name') 128 | if syn ==# 'rubyStringEscape' 129 | let syn = synIDattr(synstack(line('.'), col('.'))[0], 'name') 130 | endif 131 | for s in ['String', 'Regexp', 'Symbol', 'Integer', 'Float'] 132 | if syn =~# '^ruby' . s 133 | return s 134 | endif 135 | endfor 136 | 137 | " RSense 138 | if !empty(g:ref_refe_rsense_cmd) 139 | let use_temp = &l:modified || !filereadable(expand('%')) 140 | if use_temp 141 | let file = tempname() 142 | call writefile(getline(1, '$'), file) 143 | else 144 | let file = expand('%:p') 145 | endif 146 | 147 | let pos = getpos('.') 148 | let ve = &virtualedit 149 | set virtualedit+=onemore 150 | try 151 | let is_call = 0 152 | if search('\.\_s*\w*\%#[[:alnum:]_!?]', 'cbW') " Is method call? 153 | let is_call = 1 154 | else 155 | call search('\>', 'cW') " Move to the end of keyword. 156 | endif 157 | 158 | " To use the column of character base. 159 | let col = len(substitute(getline('.')[: col('.') - 2], '.', '.', 'g')) 160 | let res = ref#system(ref#to_list(g:ref_refe_rsense_cmd) + 161 | \ ['type-inference', '--file=' . file, 162 | \ printf('--location=%s:%s', line('.'), col)]) 163 | let type = matchstr(res.stdout, '^type: \zs\S\+\ze\n') 164 | let is_class = type =~ '^<.\+>$' 165 | if is_class 166 | let type = matchstr(type, '^<\zs.\+\ze>$') 167 | endif 168 | 169 | if type != '' 170 | if is_call 171 | call setpos('.', pos) 172 | let type .= (is_class ? '.' : '#') . ref#get_text_on_cursor(id) 173 | endif 174 | 175 | return type 176 | endif 177 | 178 | finally 179 | if use_temp 180 | call delete(file) 181 | endif 182 | let &virtualedit = ve 183 | call setpos('.', pos) 184 | endtry 185 | endif 186 | endif 187 | 188 | let class = '\v\u\w*%(::\u\w*)*' 189 | let kwd = ref#get_text_on_cursor(class) 190 | if kwd != '' 191 | return kwd 192 | endif 193 | return ref#get_text_on_cursor(class . '%([#.]' . id . ')?|' . id) 194 | endfunction 195 | 196 | 197 | " functions. {{{1 198 | " Detect the reference type from content. 199 | " - ['list', ''] (Matched list) 200 | " - ['class', class_name] (Summary of class) 201 | " - ['method', class_and_method_name] (Detail of method) 202 | function! s:detect_type() 203 | let [l1, l2, l3] = [getline(1), getline(2), getline(3)] 204 | if s:refe_version() == 1 205 | let m = matchstr(l1, '^==== \zs\S\+\ze ====$') 206 | if m != '' 207 | return ['class', m] 208 | endif 209 | 210 | " include man.* 211 | if l2 =~ '^\%(---\|:\|=\)' 212 | return ['method', l1] 213 | endif 214 | 215 | else 216 | let require = l1 =~# '^require' 217 | let m = matchstr(require ? l3 : l1, '^\%(class\|module\|object\) \zs\S\+') 218 | if m != '' 219 | return ['class', m] 220 | endif 221 | 222 | " include builtin variable. 223 | let m = matchstr(require ? l3 : l2, '^--- \zs\S\+') 224 | if m != '' 225 | return ['method', m] 226 | endif 227 | endif 228 | return ['list', ''] 229 | endfunction 230 | 231 | function! s:syntax(type) 232 | if exists('b:current_syntax') && b:current_syntax == 'ref-refe-' . a:type 233 | return 234 | endif 235 | 236 | syntax clear 237 | 238 | syntax include @refRefeRuby syntax/ruby.vim 239 | 240 | if a:type ==# 'list' 241 | syntax match refRefeClassOrMethod '^.*$' contains=@refRefeClassSepMethod 242 | elseif a:type ==# 'class' 243 | syntax region refRefeMethods start="^---- \w* methods .*----$" end="^$" fold contains=refRefeMethod,refRefeMethodHeader 244 | syntax match refRefeMethod '\S\+' contained 245 | syntax region refRefeMethodHeader matchgroup=refRefeLine start="^----" end="----$" keepend oneline contained 246 | endif 247 | 248 | syntax match refRefeClassAndMethod '\v%(\u\w*%(::|\.|#))+\h\w*[?!=~]?' contains=@refRefeClassSepMethod 249 | syntax cluster refRefeClassSepMethod contains=refRefeCommonClass,refRefeCommonMethod,refRefeCommonSep 250 | 251 | syntax match refRefeCommonSep '::\|#' contained nextgroup=refRefeCommonClass,refRefeCommonMethod 252 | syntax match refRefeCommonClass '\u\w*' contained nextgroup=refRefeCommonSep 253 | syntax match refRefeCommonMethod '[[:lower:]_]\w*[?!=~]\?' contained 254 | 255 | 256 | highlight default link refRefeMethodHeader rubyClass 257 | highlight default link refRefeMethod rubyFunction 258 | highlight default link refRefeLine rubyOperator 259 | 260 | highlight default link refRefeCommonSep rubyOperator 261 | highlight default link refRefeCommonClass rubyClass 262 | highlight default link refRefeCommonMethod rubyFunction 263 | 264 | 265 | call s:syntax_refe{s:refe_version()}(a:type) 266 | 267 | let b:current_syntax = 'ref-refe-' . a:type 268 | endfunction 269 | 270 | function! s:syntax_refe1(type) 271 | if a:type ==# 'list' 272 | syntax match refRefeClassOrMethod '^.*$' contains=@refRefeClassSepMethod 273 | elseif a:type ==# 'class' 274 | syntax region refRefeRubyCodeBlock start="^ " end="$" contains=@refRefeRuby 275 | syntax region refRefeClass matchgroup=refRefeLine start="^====" end="====$" keepend oneline 276 | elseif a:type ==# 'method' 277 | syntax region refRefeRubyCodeBlock start="^ " end="$" contains=@refRefeRuby 278 | syntax match refRefeClassOrMethod '\%1l.*$' contains=@refRefeClassSepMethod 279 | syntax region refRefeRubyCodeInline matchgroup=refRefeLine start="^---" end="$" contains=@refRefeRuby oneline 280 | endif 281 | 282 | highlight default link refRefeClass rubyClass 283 | endfunction 284 | 285 | function! s:syntax_refe2(type) 286 | " Copy from syntax/ruby.vim 287 | syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@ 4 | " ref-alc Author : soh335 5 | " : thinca 6 | " License: Creative Commons Attribution 2.1 Japan License 7 | " 8 | 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | " options. {{{1 13 | if !exists('g:ref_rfc_start_linenumber') " {{{2 14 | let g:ref_rfc_start_linenumber = 33 15 | endif 16 | 17 | if !exists('g:ref_rfc_cmd') " {{{2 18 | let g:ref_rfc_cmd = 19 | \ executable('elinks') ? 'elinks -dump -no-numbering -no-references %s' : 20 | \ executable('w3m') ? 'w3m -dump %s' : 21 | \ executable('links') ? 'links -dump %s' : 22 | \ executable('lynx') ? 'lynx -dump -nonumbers %s' : 23 | \ len(globpath(&rtp, 'autoload/wwwrenderer.vim')) > 0 24 | \ ? '=wwwrenderer#render("%s")' : 25 | \ '' 26 | endif 27 | 28 | if !exists('g:ref_rfc_encoding') " {{{2 29 | let g:ref_rfc_encoding = &termencoding 30 | endif 31 | 32 | if !exists('g:ref_rfc_use_cache') " {{{2 33 | let g:ref_rfc_use_cache = 0 34 | endif 35 | 36 | 37 | 38 | let s:source = {'name': 'rfc'} " {{{1 39 | 40 | function! s:source.available() 41 | return !empty(g:ref_rfc_cmd) 42 | endfunction 43 | 44 | function! s:source.get_body(query) 45 | if type(g:ref_rfc_cmd) == type('') 46 | let cmd = split(g:ref_rfc_cmd, '\s\+') 47 | elseif type(g:ref_rfc_cmd) == type([]) 48 | let cmd = copy(g:ref_rfc_cmd) 49 | else 50 | return '' 51 | endif 52 | 53 | let str = tolower(a:query) 54 | if str !~? '^rfc' 55 | let str = 'rfc' . str 56 | endif 57 | if str !~? '^rfc\d\+$' 58 | return '' 59 | endif 60 | 61 | let url = 'http://tools.ietf.org/html/' . str 62 | call map(cmd, 'substitute(v:val, "%s", url, "g")') 63 | if len(cmd) > 0 && cmd[0] =~ '^=' 64 | let res = eval(join(cmd, ' ')[1:]) 65 | elseif len(cmd) > 0 && cmd[0] =~ '^:' 66 | redir => res 67 | silent! exe join(cmd, ' ')[1:] 68 | redir END 69 | elseif g:ref_rfc_use_cache 70 | let expr = 'ref#system(' . string(cmd) . ').stdout' 71 | let res = join(ref#cache('rfc', str, expr), "\n") 72 | else 73 | let res = ref#system(cmd).stdout 74 | endif 75 | return s:iconv(res, g:ref_rfc_encoding, &encoding) 76 | endfunction 77 | 78 | function! s:source.opened(query) 79 | execute "normal! ".g:ref_rfc_start_linenumber."z\" 80 | call s:syntax(a:query) 81 | endfunction 82 | 83 | function! s:source.normalize(query) 84 | return substitute(substitute(a:query, '\_s\+', ' ', 'g'), '^ \| $', '', 'g') 85 | endfunction 86 | 87 | 88 | " misc. {{{1 89 | function! s:syntax(query) 90 | syntax clear 91 | let str = escape(substitute(a:query, '\s\+', '\\_s\\+', 'g'), '"') 92 | if str =~# '^[[:print:][:space:]]\+$' 93 | let str = '\<' . str . '\>' 94 | endif 95 | execute 'syntax match refRfcKeyword "\c'.str.'"' 96 | highlight default link refRfcKeyword Special 97 | endfunction 98 | 99 | " iconv() wrapper for safety. 100 | function! s:iconv(expr, from, to) 101 | if a:from == '' || a:to == '' || a:from ==# a:to 102 | return a:expr 103 | endif 104 | let result = iconv(a:expr, a:from, a:to) 105 | return result != '' ? result : a:expr 106 | endfunction 107 | 108 | function! ref#rfc#define() 109 | return s:source 110 | endfunction 111 | 112 | let &cpo = s:save_cpo 113 | unlet s:save_cpo 114 | -------------------------------------------------------------------------------- /autoload/ref/webdict.vim: -------------------------------------------------------------------------------- 1 | " A ref source for web dictionary. 2 | " Version: 1.0 3 | " Author : thinca 4 | " License: zlib License 5 | 6 | let s:save_cpo = &cpo 7 | set cpo&vim 8 | 9 | " options. {{{1 10 | 11 | if !exists('g:ref_source_webdict_cmd') 12 | let g:ref_source_webdict_cmd = 13 | \ executable('elinks') ? 'elinks -dump -no-numbering -no-references %s' : 14 | \ executable('w3m') ? 'w3m -dump %s' : 15 | \ executable('links') ? 'links -dump %s' : 16 | \ executable('lynx') ? 'lynx -dump -nonumbers %s' : 17 | \ len(globpath(&rtp, 'autoload/wwwrenderer.vim')) > 0 18 | \ ? '=wwwrenderer#render("%s")' : 19 | \ '' 20 | endif 21 | 22 | if !exists('g:ref_source_webdict_sites') 23 | let g:ref_source_webdict_sites = {} 24 | endif 25 | 26 | if !exists('g:ref_source_webdict_encoding') 27 | let g:ref_source_webdict_encoding = &termencoding 28 | endif 29 | 30 | if !exists('g:ref_source_webdict_use_cache') 31 | let g:ref_source_webdict_use_cache = 0 32 | endif 33 | 34 | let s:site_base = { 35 | \ 'url': '', 36 | \ 'keyword_encoding': 'utf-8', 37 | \ } 38 | function! s:site_base.filter(output) 39 | return a:output 40 | endfunction 41 | 42 | 43 | 44 | let s:source = {'name': 'webdict'} " {{{1 45 | 46 | function! s:source.available() 47 | return !empty(g:ref_source_webdict_cmd) 48 | endfunction 49 | 50 | function! s:source.get_body(query) 51 | let cmd = s:get_cmd() 52 | if empty(cmd) 53 | throw 'Wrong g:ref_source_webdict_cmd.' 54 | endif 55 | 56 | let [name, site, keyword] = s:get_site_and_keyword_from_query(a:query) 57 | if empty(site) 58 | throw '"' . name . '" does not exist in g:ref_source_webdict_sites.' 59 | endif 60 | if empty(site.url) 61 | throw '"url" is empty: ' . name 62 | endif 63 | if stridx(site.url, '%s') < 0 64 | throw 'Wrong url: ' . site.url 65 | endif 66 | 67 | let query = name . ' ' . keyword 68 | let keyword = s:iconv(keyword, &encoding, site.keyword_encoding) 69 | let arg = '' 70 | for i in range(strlen(keyword)) 71 | let c = keyword[i] 72 | let arg .= c =~ '\w' ? c : printf('%%%02X', char2nr(c)) 73 | endfor 74 | 75 | let url = printf(site.url, arg) 76 | call map(cmd, 'substitute(v:val, "%s", url, "g")') 77 | if len(cmd) > 0 && cmd[0] =~ '^=' 78 | let res = eval(join(cmd, ' ')[1:]) 79 | elseif len(cmd) > 0 && cmd[0] =~ '^:' 80 | redir => res 81 | silent! exe join(cmd, ' ')[1:] 82 | redir END 83 | elseif get(site, 'cache', g:ref_source_webdict_use_cache) 84 | let expr = 'ref#system(' . string(cmd) . ').stdout' 85 | let res = join(ref#cache('webdict', query, expr), "\n") 86 | else 87 | let res = ref#system(cmd).stdout 88 | endif 89 | let encoding = get(site, 'output_encoding', g:ref_source_webdict_encoding) 90 | return { 91 | \ 'body': site.filter(s:iconv(res, encoding, &encoding)), 92 | \ 'query': query, 93 | \ } 94 | endfunction 95 | 96 | function! s:source.opened(query) 97 | let [name, site, keyword] = s:get_site_and_keyword_from_query(a:query) 98 | if has_key(site, 'line') 99 | execute site.line 100 | execute "normal! z\" 101 | endif 102 | call s:syntax(keyword) 103 | let b:ref_source_webdict_site = name 104 | endfunction 105 | 106 | function! s:source.get_keyword() 107 | let name = get(b:, 'ref_source_webdict_site', 108 | \ get(g:ref_source_webdict_sites, 'default', '')) 109 | return name . ' ' . expand('') 110 | endfunction 111 | 112 | function! s:source.complete(query) 113 | if a:query =~# '^\s*\S*$' 114 | let name = '^\V' . escape(matchstr(a:query, '^\s*\zs\S*\ze$'), '\') 115 | return filter(keys(g:ref_source_webdict_sites), 116 | \ 'v:val =~# name && v:val !=# "default"') 117 | endif 118 | return '' 119 | endfunction 120 | 121 | function! s:source.normalize(query) 122 | return substitute(substitute(a:query, '\_s\+', ' ', 'g'), '^ \| $', '', 'g') 123 | endfunction 124 | 125 | 126 | " misc. {{{1 127 | function! s:syntax(query) 128 | syntax clear 129 | let str = escape(substitute(a:query, '\s\+', '\\_s\\+', 'g'), '"') 130 | if str =~# '^[[:print:][:space:]]\+$' 131 | let str = '\<' . str . '\>' 132 | endif 133 | execute 'syntax match refWebdictKeyword "\c'.str.'"' 134 | highlight default link refWebdictKeyword Special 135 | endfunction 136 | 137 | function! s:get_cmd() 138 | if type(g:ref_source_webdict_cmd) == type('') 139 | return split(g:ref_source_webdict_cmd, '\s\+') 140 | elseif type(g:ref_source_webdict_cmd) == type([]) 141 | return copy(g:ref_source_webdict_cmd) 142 | endif 143 | return [] 144 | endfunction 145 | 146 | function! s:get_site(name) 147 | let site = get(g:ref_source_webdict_sites, a:name, 0) 148 | if type(site) == type('') 149 | if a:name ==# 'default' 150 | return s:get_site(site) 151 | endif 152 | return extend(copy(s:site_base), {'url': site}) 153 | elseif type(site) == type({}) 154 | return extend(copy(s:site_base), site) 155 | endif 156 | return {} 157 | endfunction 158 | 159 | function! s:get_site_and_keyword_from_query(query) 160 | let [name, keyword] = matchlist(a:query, '^\(\S*\)\s*\(.*\)$')[1 : 2] 161 | let site = s:get_site(name) 162 | if !empty(site) 163 | return [name, site, keyword] 164 | endif 165 | let keyword = a:query 166 | if exists('b:ref_source_webdict_site') 167 | let name = b:ref_source_webdict_site 168 | let site = s:get_site(name) 169 | if !empty(site) 170 | return [name, site, keyword] 171 | endif 172 | endif 173 | let default = get(g:ref_source_webdict_sites, 'default', '') 174 | if default !=# '' 175 | let name = default 176 | let site = s:get_site(name) 177 | endif 178 | return [name, site, keyword] 179 | endfunction 180 | 181 | function! s:iconv(expr, from, to) 182 | if a:from == '' || a:to == '' || a:from ==# a:to 183 | return a:expr 184 | endif 185 | let result = iconv(a:expr, a:from, a:to) 186 | return result != '' ? result : a:expr 187 | endfunction 188 | 189 | function! ref#webdict#define() 190 | return s:source 191 | endfunction 192 | 193 | let &cpo = s:save_cpo 194 | unlet s:save_cpo 195 | -------------------------------------------------------------------------------- /autoload/unite/kinds/ref.vim: -------------------------------------------------------------------------------- 1 | " unite kind: ref 2 | " Version: 0.1.1 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | let s:kind = { 11 | \ 'name' : 'ref', 12 | \ 'default_action' : 'open', 13 | \ 'action_table': {}, 14 | \ 'parents': ['openable'], 15 | \ } 16 | 17 | let s:kind.action_table.open = { 18 | \ 'is_selectable' : 1, 19 | \ } 20 | 21 | function! s:kind.action_table.open.func(candidates) 22 | for c in a:candidates 23 | call ref#open(c.action__ref_source.name, c.word, {'new': 1, 'open': 'edit'}) 24 | endfor 25 | endfunction 26 | 27 | function! unite#kinds#ref#define() 28 | return s:kind 29 | endfunction 30 | 31 | let &cpo = s:save_cpo 32 | unlet s:save_cpo 33 | -------------------------------------------------------------------------------- /autoload/unite/sources/ref.vim: -------------------------------------------------------------------------------- 1 | " unite source: ref 2 | " Version: 0.1.1 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | let s:source = { 11 | \ 'max_candidates': 30, 12 | \ 'is_volatile' : 1, 13 | \ } 14 | 15 | function! s:source.gather_candidates(args, context) 16 | return map(self.source__ref_source.complete(a:context.input), '{ 17 | \ "word" : v:val, 18 | \ "kind" : "ref", 19 | \ "source" : self.name, 20 | \ "action__ref_source" : self.source__ref_source, 21 | \ }') 22 | endfunction 23 | 24 | function! s:define(ref_source) 25 | let source = copy(s:source) 26 | let name = substitute(tolower(a:ref_source.name), '[^a-z0-9_/]', '_', 'g') 27 | let source.name = 'ref/' . name 28 | let source.description = 'candidates from ref-' . a:ref_source.name 29 | let source.source__ref_source = a:ref_source 30 | if has_key(a:ref_source, 'unite') && type(a:ref_source.unite) == type({}) 31 | let source.source__original = copy(source) 32 | call extend(source, a:ref_source.unite) 33 | endif 34 | return source 35 | endfunction 36 | 37 | function! unite#sources#ref#define() 38 | return map(filter(values(ref#available_sources()), 39 | \ 'v:val.available() && has_key(v:val, "complete")'), 40 | \ 's:define(v:val)') 41 | endfunction 42 | 43 | let &cpo = s:save_cpo 44 | unlet s:save_cpo 45 | -------------------------------------------------------------------------------- /doc/ku-ref.txt: -------------------------------------------------------------------------------- 1 | *ku-ref.txt* ku source: ref 2 | 3 | Version: 0.2.1 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ku-ref-contents* 10 | 11 | INTRODUCTION |ku-ref-introduction| 12 | ACTION TABLE |ku-ref-action-table| 13 | KEY TABLE |ku-ref-key-table| 14 | FOR REF SOURCES |ku-ref-for-ref-sources| 15 | CHANGELOG |ku-ref-changelog| 16 | 17 | 18 | ============================================================================== 19 | INTRODUCTION *ku-ref-introduction* 20 | 21 | *ku-ref* is a source for |ku| to treat the completion list of |ref.vim|. 22 | 23 | - There is a heavy possibility according to |ref-sources|. 24 | 25 | 26 | Requirements: 27 | - Vim 7.2 or later 28 | - |ku| 0.2.0 or later (vimscript#2337) 29 | - |ref.vim| 0.3.3 or later 30 | 31 | 32 | ============================================================================== 33 | ACTION TABLE *ku-ref-action-table* 34 | 35 | default *ku-ref-action-default* 36 | Same as |ku-ref-action-open|. 37 | 38 | open *ku-ref-action-open* 39 | Open the |ref-viewer|. At this time, |g:ref_open| 40 | assumes it is empty and is treated. 41 | 42 | 43 | ============================================================================== 44 | KEY TABLE *ku-ref-key-table* 45 | 46 | Key Action ~ 47 | -------- -------- 48 | o open |ku-ref-action-open| 49 | open |ku-ref-action-open| 50 | 51 | 52 | ============================================================================== 53 | FOR REF SOURCES *ku-ref-for-ref-sources* 54 | 55 | The following functions are called like a wrapper if defined in source. 56 | However, {ext} is omitted. 57 | 58 | function ku function ~ 59 | -------------- ----------------- 60 | acc_valid_p({item}, {sep}) |ku#{source}#acc_valid_p()| 61 | special_char_p({char}) |ku#{source}#special_char_p()| 62 | on_before_action({item}) |ku#{source}#on_before_action()| 63 | on_source_enter() |ku#{source}#on_source_enter()| 64 | on_source_leave() |ku#{source}#on_source_leave()| 65 | 66 | 67 | ============================================================================== 68 | CHANGELOG *ku-ref-changelog* 69 | 70 | 0.2.1 2010-05-18 71 | - Updated for |ref.vim| 0.3.3. 72 | 73 | 0.2.0 2010-04-07 74 | - Updated for |ref.vim| 0.3.0. 75 | 76 | 0.1.0 2009-08-20 77 | - Initial version. 78 | 79 | 80 | ============================================================================== 81 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 82 | -------------------------------------------------------------------------------- /doc/ref-clojure.jax: -------------------------------------------------------------------------------- 1 | *ref-clojure.txt* clojure 用の ref ソース。 2 | 3 | Version: 0.1.1 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-clojure-contents* 10 | 11 | 概要 |ref-clojure-introduction| 12 | カスタマイズ |ref-clojure-customizing| 13 | 更新履歴 |ref-clojure-changelog| 14 | 15 | 16 | ============================================================================== 17 | 概要 *ref-clojure-introduction* 18 | 19 | *ref-clojure* は clojure 用の |ref.vim| のソースです。 20 | 21 | 要件: 22 | - |ref.vim| 0.4.1 以降 23 | - clojure 24 | 25 | 26 | 27 | ============================================================================== 28 | 引数 *ref-clojure-arguments* 29 | 30 | このソースは以下の形式の引数を受け付けます。 31 | 32 | 関数名 function-name 33 | 通常の文字列は関数名として検索されます。見付からなかっ 34 | た場合は検索文字列として扱い検索を行います。 35 | 36 | 検索文字列 #"pattern" 37 | (find-doc) で検索を行います。 38 | 39 | 40 | 41 | ============================================================================== 42 | カスタマイズ *ref-clojure-customizing* 43 | 44 | g:ref_clojure_cmd *g:ref_clojure_cmd* 45 | clojure のコマンドを指定します。コマンドとその引数を含 46 | む|List| も指定できます。 47 | デフォルト値は以下の物でコマンドが実行可能なものです。 48 | 実行可能なものがない場合は "" です。 49 | - 'clj' 50 | - 'clojure-1.5' 51 | 設定例: > 52 | ['java', '-cp', 'clojure.jar' 'clojure.main'] 53 | 54 | g:ref_clojure_classpath *g:ref_clojure_classpath* 55 | b:ref_clojure_classpath *b:ref_clojure_classpath* 56 | $CLASSPATH を文字列かリストで指定します。 57 | |b:ref_clojure_classpath| は |g:ref_clojure_classpath| 58 | の値の前に追加されます。 59 | 60 | g:ref_clojure_precode *g:ref_clojure_precode* 61 | b:ref_clojure_precode *b:ref_clojure_precode* 62 | 検索前に実行するコードを指定します。"use" や 63 | "require" が指定されることを想定しています。 64 | |b:ref_clojure_precode| は |g:ref_clojure_precode| 65 | の値の後に追加されます。 66 | なお、どちらも与えられていない場合、以下に示されるデフ 67 | ォルトのコードが自動で挿入されます。これはdocと 68 | find-docを利用可能にするためです。 > 69 | (ns vim-ref (:use [clojure.repl :only (doc find-doc)])) 70 | 71 | g:ref_clojure_overview *g:ref_clojure_overview* 72 | 真の場合、検索結果の各関数を 1 行で表示します。 73 | 74 | 75 | 76 | ============================================================================== 77 | 更新履歴 *ref-clojure-changelog* 78 | 79 | 0.1.1 2013-06-09 80 | - clojure-1.5でも動作するよう修正。 81 | 0.1.0 2010-06-24 82 | - 初版。 83 | 84 | 85 | ============================================================================== 86 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 87 | -------------------------------------------------------------------------------- /doc/ref-clojure.txt: -------------------------------------------------------------------------------- 1 | *ref-clojure.txt* A ref source for clojure. 2 | 3 | Version: 0.1.1 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-clojure-contents* 10 | 11 | INTRODUCTION |ref-clojure-introduction| 12 | CUSTOMIZING |ref-clojure-customizing| 13 | CHANGELOG |ref-clojure-changelog| 14 | 15 | 16 | ============================================================================== 17 | INTRODUCTION *ref-clojure-introduction* 18 | 19 | *ref-clojure* is a source for |ref.vim| to clojure. 20 | 21 | Requirements: 22 | - |ref.vim| 0.4.1 or later 23 | - clojure 24 | 25 | 26 | 27 | ============================================================================== 28 | ARGUMENTS *ref-clojure-arguments* 29 | 30 | This source accepts the argument of the following forms. 31 | 32 | function name function-name 33 | A usual string is searched as a function name. It 34 | treats as a search pattern when not found. 35 | 36 | search pattern #"pattern" 37 | Search with (find-doc). 38 | 39 | 40 | 41 | ============================================================================== 42 | CUSTOMIZING *ref-clojure-customizing* 43 | 44 | g:ref_clojure_cmd *g:ref_clojure_cmd* 45 | Specifies the clojure command. This allows a |List| 46 | that includes command and arguments. 47 | The default value is the executable one of the 48 | following. If no executable one, it is "". 49 | - 'clj' 50 | - 'clojure-1.5' 51 | Example: > 52 | ['java', '-cp', 'clojure.jar' 'clojure.main'] 53 | 54 | g:ref_clojure_classpath *g:ref_clojure_classpath* 55 | b:ref_clojure_classpath *b:ref_clojure_classpath* 56 | Specifies the $CLASSPATH by string or |List|. 57 | |b:ref_clojure_classpath| is added ahead of the 58 | |g:ref_clojure_classpath|. 59 | 60 | g:ref_clojure_precode *g:ref_clojure_precode* 61 | b:ref_clojure_precode *b:ref_clojure_precode* 62 | Specifies the code executed before searching. 63 | It is assumed that "use" and "require" are specified. 64 | |b:ref_clojure_precode| is added after the value of 65 | the |g:ref_clojure_precode|. 66 | When none of them are given ref-clojure automatically 67 | adds the following line in order to enable using 68 | doc and find-doc. > 69 | (ns vim-ref (:use [clojure.repl :only (doc find-doc)])) 70 | 71 | g:ref_clojure_overview *g:ref_clojure_overview* 72 | If true, each function of the search result is 73 | displayed by one line. 74 | 75 | 76 | 77 | ============================================================================== 78 | CHANGELOG *ref-clojure-changelog* 79 | 80 | 0.1.1 2013-06-09 81 | - Support clojure-1.5. 82 | 0.1.0 2010-06-24 83 | - Initial version. 84 | 85 | 86 | ============================================================================== 87 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 88 | -------------------------------------------------------------------------------- /doc/ref-erlang.jax: -------------------------------------------------------------------------------- 1 | *ref-erlang.txt* Erlang 用の ref ソース。 2 | 3 | Version: 0.1.2 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-erlang-contents* 10 | 11 | 概要 |ref-erlang-introduction| 12 | 引数 |ref-erlang-arguments| 13 | カスタマイズ |ref-erlang-customizing| 14 | 更新履歴 |ref-erlang-changelog| 15 | 16 | 17 | ============================================================================== 18 | 概要 *ref-erlang-introduction* 19 | 20 | *ref-erlang* は Erlang の man(erl -man) を閲覧するための |ref.vim| のソースで 21 | す。Erlang の man は Unix 系 OS でのみ動作します。よって、このソースも Unix 系 22 | OSのみをサポートします。 23 | 24 | 25 | 要件: 26 | - |ref.vim| 0.4.1 以降 27 | - |ref-man| 0.4.1 or later 28 | - UNIX 系 OS 29 | 30 | 31 | 32 | ============================================================================== 33 | 引数 *ref-erlang-arguments* 34 | 35 | このソースは以下の2つの形式の引数を受け付けます。 36 | 37 | module 38 | module:function 39 | 40 | 41 | ============================================================================== 42 | カスタマイズ *ref-erlang-customizing* 43 | 44 | g:ref_erlang_cmd *g:ref_erlang_cmd* 45 | erl コマンドを指定します。コマンドとその引数を含む 46 | |List| も指定できます。 47 | デフォルト値は、実行可能ならば "erl" です。そうでな 48 | ければ "" です。 49 | 50 | g:ref_erlang_man_dir *g:ref_erlang_man_dir* 51 | Erlang の man のディレクトリです。これは補完に使われま 52 | す。 53 | デフォルト値は以下のコマンドによって取得されます。 > 54 | erl -noshell -eval io:fwrite(code:root_dir()). -s init stop 55 | 56 | 57 | ============================================================================== 58 | 更新履歴 *ref-erlang-changelog* 59 | 60 | 0.1.2 2010-10-31 61 | - エラーの処理を改善。 62 | 63 | 0.1.1 2010-06-06 64 | - 関数名を補完できるようにした。 65 | - モジュールが見つからなかった場合、erlang モジュールの関数として再検 66 | 索するようにした。 67 | - クエリが空の時にエラーが発生するバグを修正。 68 | - キーワードのパターンを修正。 69 | 70 | 0.1.0 2010-05-23 71 | - 初版。 72 | 73 | 74 | ============================================================================== 75 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 76 | -------------------------------------------------------------------------------- /doc/ref-erlang.txt: -------------------------------------------------------------------------------- 1 | *ref-erlang.txt* A ref source for Erlang. 2 | 3 | Version: 0.1.2 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-erlang-contents* 10 | 11 | INTRODUCTION |ref-erlang-introduction| 12 | ARGUMENTS |ref-erlang-arguments| 13 | CUSTOMIZING |ref-erlang-customizing| 14 | CHANGELOG |ref-erlang-changelog| 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *ref-erlang-introduction* 19 | 20 | *ref-erlang* is a source for |ref.vim| to Erlang's man(erl -man). Erlang's 21 | man works only on UNIX-like operating system. So, this source supports 22 | similarly only UNIX-like operating system. 23 | 24 | 25 | Requirements: 26 | - |ref.vim| 0.4.1 or later 27 | - |ref-man| 0.4.1 or later 28 | - UNIX-like operating system 29 | 30 | 31 | 32 | ============================================================================== 33 | ARGUMENTS *ref-erlang-arguments* 34 | 35 | This source accepts the argument of the following two forms. 36 | 37 | module 38 | module:function 39 | 40 | 41 | ============================================================================== 42 | CUSTOMIZING *ref-erlang-customizing* 43 | 44 | g:ref_erlang_cmd *g:ref_erlang_cmd* 45 | Specifies the erl command. This allows a |List| that 46 | includes command and arguments. 47 | The default value is "erl" if it is executable. 48 | Otherwise, it is "". 49 | 50 | g:ref_erlang_man_dir *g:ref_erlang_man_dir* 51 | The man directory for Erlang. This is used for 52 | completion. 53 | The default value is acquired by the following 54 | command. > 55 | erl -noshell -eval io:fwrite(code:root_dir()). -s init stop 56 | 57 | 58 | ============================================================================== 59 | CHANGELOG *ref-erlang-changelog* 60 | 61 | 0.1.2 2010-10-31 62 | - Improved the handling of error. 63 | 64 | 0.1.1 2010-06-06 65 | - Function names are completable. 66 | - Search again as a function of the erlang module when the module was 67 | not found. 68 | - Fixed the bug that the error occurs when query was empty. 69 | - Fixed keyword pattern. 70 | 71 | 0.1.0 2010-05-23 72 | - Initial version. 73 | 74 | 75 | ============================================================================== 76 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 77 | -------------------------------------------------------------------------------- /doc/ref-man.jax: -------------------------------------------------------------------------------- 1 | *ref-man.txt* manpage 用の ref ソース。 2 | 3 | Version: 0.4.3 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-man-contents* 10 | 11 | 概要 |ref-man-introduction| 12 | カスタマイズ |ref-man-customizing| 13 | 更新履歴 |ref-man-changelog| 14 | 15 | 16 | ============================================================================== 17 | 概要 *ref-man-introduction* 18 | 19 | *ref-man* は man コマンド用の |ref.vim| ソースです。man は Unix 系 OS でオン 20 | ラインマニュアルを表示するコマンドです。 21 | 22 | |(ref-keyword)| を使う際には、[count] が利用できます。 23 | 例えば、"printf" というテキストの上で "3K" とタイプすると、printf 関数の 24 | manpage が開かれるでしょう。 25 | 26 | 27 | 要件: 28 | - |ref.vim| 0.4.0 以降 29 | - man 30 | 31 | 32 | 33 | ============================================================================== 34 | カスタマイズ *ref-man-customizing* 35 | 36 | g:ref_man_cmd *g:ref_man_cmd* 37 | man コマンドを指定します。コマンドとその引数を含む 38 | |List| も指定できます。 39 | デフォルト値は、実行可能ならば "man -Tutf8" です。そう 40 | でなければ "" です。"-Tutf8" オプションはマルチバイト 41 | 環境のための回避策です。このオプションはいつか要らなく 42 | なるかもしれません。 43 | Note: MacVim を使っている場合、~/.vimrc で以下のように 44 | して、man コマンドのダミーのページャを設定する必要があ 45 | るかもしれません。 > 46 | let g:ref_man_cmd = "man -P cat" 47 | 48 | g:ref_man_lang *g:ref_man_lang* 49 | 空文字列以外を指定した場合、$LANG の値に使われます。 50 | 51 | g:ref_man_manpath *g:ref_man_manpath* 52 | man pages の検索を行うディレクトリのリストを指定しま 53 | す。ディレクトリはコロンで区切ります。 54 | $MANPATH 環境変数がデフォルトの値として設定されます。 55 | 先頭にコロンが存在する場合、システムの manpath がリスト 56 | の先頭に挿入されます。 57 | 末尾にコロンが存在する場合、システムの manpath がリスト 58 | の末尾に付加されます。 59 | 連続するコロン (::) が含まれる場合、システムの manpath 60 | が連続するコロンの間に挿入されます。 61 | 62 | 63 | 64 | ============================================================================== 65 | 更新履歴 *ref-man-changelog* 66 | 67 | 0.4.3 2015-03-22 68 | - [count] の挙動を修正。 69 | 70 | 0.4.2 2010-10-26 71 | - . 入りの項目が補完されないバグを修正。 72 | 73 | 0.4.1 2010-06-04 74 | - エスケープシーケンスを取り除くタイミングを変更。 75 | - filetype c に対して man を登録するようにした。 76 | 77 | 0.4.0 2010-05-31 78 | - |ref.vim| 0.4.0 に対応。 79 | - |vimproc| を使わないようにした。 80 | - man は setuid されていることがあるが、vimproc は setuid に対応して 81 | いないため。 82 | - manpath の最後の項目が無視されるバグを修正。 83 | 84 | 0.3.2 2010-05-16 85 | - エスケープシーケンスによるハイライトを廃止。 86 | - キーワードのマッチを改善。 87 | - いくつかのマルチバイト記号をアスキー文字に置き換えるようにした。 88 | 89 | 0.3.1 2010-05-07 90 | - |ref.vim| 0.3.2 に対応。 91 | 92 | 0.3.0 2010-04-15 93 | - |ref.vim| 0.3.0 に対応。 94 | - |g:ref_man_lang| オプションを追加。 95 | 96 | 0.2.0 2010-01-28 97 | - |ref.vim| 0.2.0 に対応。 98 | - |g:ref_man_cmd| が |List| だと動作しないバグを修正。 99 | 100 | 0.1.3 2010-01-18 101 | - |ref#system()| を使うようにした。 102 | - エスケープシーケンスの除去を改善。 103 | - manpage のエンコーディングを 'termencoding' から 'encoding' に変換す 104 | るようにした。 105 | 106 | 0.1.2 2009-12-22 107 | - |ref#cache()| を使うようにした。 108 | - キーワードのマッチを改善。 109 | 110 | 0.1.1 2009-12-16 111 | - キーワードのマッチを改善。 112 | 113 | 0.1.0 2009-09-01 114 | - キーワードのマッチを改善。 115 | - ページを移動した際にエラーが発生することがあるバグを修正。 116 | - |g:ref_man_use_escape_sequence| オプションを追加。 117 | 118 | 0.0.2 2009-08-19 119 | - |g:ref_man_highlight_limit| オプションを追加。 120 | - 補完関数を改良。 121 | - パフォーマンス。 122 | - 重複した項目を取り除くようにした。 123 | 124 | 0.0.1 2009-08-12 125 | - 初版。 126 | 127 | 128 | ============================================================================== 129 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 130 | -------------------------------------------------------------------------------- /doc/ref-man.txt: -------------------------------------------------------------------------------- 1 | *ref-man.txt* A ref source for manpage. 2 | 3 | Version: 0.4.3 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-man-contents* 10 | 11 | INTRODUCTION |ref-man-introduction| 12 | CUSTOMIZING |ref-man-customizing| 13 | CHANGELOG |ref-man-changelog| 14 | 15 | 16 | ============================================================================== 17 | INTRODUCTION *ref-man-introduction* 18 | 19 | *ref-man* is a source for |ref.vim| to man command. man is a command to view 20 | manual pages on UNIX-like operating systems. 21 | 22 | You can use [count] when you use |(ref-keyword)|. 23 | For example, when you type "3K" on the text "printf", the manpage of printf 24 | function will be opened. 25 | 26 | 27 | Requirements: 28 | - |ref.vim| 0.4.0 or later 29 | - man 30 | 31 | 32 | 33 | ============================================================================== 34 | CUSTOMIZING *ref-man-customizing* 35 | 36 | g:ref_man_cmd *g:ref_man_cmd* 37 | Specifies the man command. This allows a |List| that 38 | includes command and arguments. 39 | The default value is "man -Tutf8" if it is executable. 40 | Otherwise, it is "". "-Tutf8" option is workaround 41 | for multi-byte environment. The option might be 42 | unnecessary someday. 43 | Note: If you are a MacVim user, you may want to 44 | specify a dummy pager of man command with the 45 | following line in your ~/.vimrc. > 46 | let g:ref_man_cmd = "man -P cat" 47 | 48 | g:ref_man_lang *g:ref_man_lang* 49 | It is used for the value of $LANG when it is not empty 50 | string. 51 | 52 | g:ref_man_manpath *g:ref_man_manpath* 53 | Specifies the list of directories to search for man 54 | pages. Separate directories with colons. 55 | The $ MANPATH environment variable is set as the 56 | default value. 57 | If `g:ref_man_manpath` is prefixed by a colon, then 58 | the value of the system's manpath is inserted at the 59 | beginning of the list. If the colon comes at the end 60 | of the list, then the value of the system's manpath is 61 | appended to the end of the list. If the list contains 62 | a double colon (::), then the value of the system's 63 | manpath is inserted between the two colons. 64 | 65 | 66 | 67 | ============================================================================== 68 | CHANGELOG *ref-man-changelog* 69 | 70 | 0.4.3 2015-03-22 71 | - Fix [count] behavior. 72 | 73 | 0.4.2 2010-10-26 74 | - Fixed the bug not completed the item with ".". 75 | 76 | 0.4.1 2010-06-04 77 | - Changed the timing in which the escape sequence is removed. 78 | - C language uses ref-man by default. 79 | 80 | 0.4.0 2010-05-31 81 | - Updated for |ref.vim| 0.4.0. 82 | - Don't use |vimproc|. 83 | - As for man command, setuid might be applied, but vimproc doesn't 84 | correspond setuid. 85 | - Fixed the bug that the last item of manpath is ignored. 86 | 87 | 0.3.2 2010-05-16 88 | - Abolished the highlight with escape sequence. 89 | - Improved the matching of keyword. 90 | - Some multi byte signs were replaced with ASCII character. 91 | 92 | 0.3.1 2010-05-07 93 | - Updated for |ref.vim| 0.3.2. 94 | 95 | 0.3.0 2010-04-15 96 | - Updated for |ref.vim| 0.3.0. 97 | - Added |g:ref_man_lang| option. 98 | 99 | 0.2.0 2010-01-28 100 | - Updated for |ref.vim| 0.2.0. 101 | - Fixed a bug that doesn't work when |g:ref_man_cmd| is a |List|. 102 | 103 | 0.1.3 2010-01-18 104 | - Using |ref#system()|. 105 | - Improved the removing of escape sequences. 106 | - The encoding of manpage is converted from 'termencoding' to 107 | 'encoding'. 108 | 109 | 0.1.2 2009-12-22 110 | - Using |ref#cache()|. 111 | - Improved the matching of keyword. 112 | 113 | 0.1.1 2009-12-16 114 | - Improved the matching of keyword. 115 | 116 | 0.1.0 2009-09-01 117 | - Improved the matching of keyword. 118 | - Fixed a bug that an error might occur when a page is moved. 119 | - Added |g:ref_man_use_escape_sequence| option. 120 | 121 | 0.0.2 2009-08-19 122 | - Added |g:ref_man_highlight_limit| option. 123 | - Improved the completion function. 124 | - For performance. 125 | - Removed duplication items. 126 | 127 | 0.0.1 2009-08-12 128 | - Initial version. 129 | 130 | 131 | ============================================================================== 132 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 133 | -------------------------------------------------------------------------------- /doc/ref-perldoc.jax: -------------------------------------------------------------------------------- 1 | *ref-perldoc.txt* perldoc 用の ref ソース。 2 | 3 | Version: 0.3.5 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-perldoc-contents* 10 | 11 | 概要 |ref-perldoc-introduction| 12 | インターフェース |ref-perldoc-interface| 13 | キーマッピング |ref-perldoc-key-mappings| 14 | カスタマイズ |ref-perldoc-customizing| 15 | 引数 |ref-perldoc-arguments| 16 | 変数 |ref-perldoc-variables| 17 | バグ |ref-perldoc-bugs| 18 | 更新履歴 |ref-perldoc-changelog| 19 | 20 | 21 | ============================================================================== 22 | 概要 *ref-perldoc-introduction* 23 | 24 | *ref-perldoc* は perldoc コマンド用の |ref.vim| のソースです。perldoc は Perl 25 | のリファレンスマニュアルを見るためのコマンドラインツールです。 26 | 27 | 28 | 要件: 29 | - |ref.vim| 0.3.2 以降 30 | - perldoc 31 | 32 | 33 | 34 | ============================================================================== 35 | インターフェース *ref-perldoc-interface* 36 | 37 | ------------------------------------------------------------------------------ 38 | キーマッピング *ref-perldoc-key-mappings* 39 | 40 | (ref-source-perldoc-switch) *(ref-source-perldoc-switch)* 41 | モジュールとソースのページを切り替えます。それ以外の 42 | ページの場合は何もしません。 43 | 44 | デフォルトの割り当て: 45 | {lhs} {rhs} 46 | -------- ----------------------------- 47 | s (ref-source-perldoc-switch) 48 | 49 | 50 | 51 | ============================================================================== 52 | カスタマイズ *ref-perldoc-customizing* 53 | 54 | g:ref_perldoc_cmd *g:ref_perldoc_cmd* 55 | perldoc コマンドを指定します。コマンドとその引数を含む 56 | |List| も指定できます。 57 | デフォルト値は、実行可能ならば "perldoc" です。そうで 58 | なければ "" です。 59 | 60 | g:ref_perldoc_complete_head *g:ref_perldoc_complete_head* 61 | モジュールを補完する際にパッケージ名単位で候補を表示し 62 | ます。 63 | デフォルト値は 0 です。 64 | 65 | g:ref_perldoc_auto_append_f *g:ref_perldoc_auto_append_f* 66 | クエリが全て小文字だった場合に'-f'をつけ、 67 | 組み込み関数のドキュメントを探します。 68 | 関数が見つからなければモジュールを探します。 69 | デフォルト値は 0 です。 70 | 71 | 72 | 73 | 74 | ============================================================================== 75 | 引数 *ref-perldoc-arguments* 76 | 77 | このソースは引数に以下のオプションが利用できます。 78 | 79 | -f 組み込み関数を対象にします。このオプションがなくてもモ 80 | ジュールが見つからなかった場合は関数を探します。 81 | 82 | -m モジュールのソースを表示します。 83 | 84 | 85 | 86 | ============================================================================== 87 | 変数 *ref-perldoc-variables* 88 | 89 | このソースが表示されている間、|ref-viewer| には以下の変数が定義されます。 90 | 91 | b:ref_perldoc_mode *b:ref_perldoc_mode* 92 | 表示モード。以下のうちのいづれかです。 93 | "perl" Perl のコアドキュメント。 94 | "module" モジュール。 95 | "func" 組み込み関数。 96 | "source" モジュールのソースコード。 97 | "list" 単語に一致した候補リスト。 98 | 99 | b:ref_perldoc_word *b:ref_perldoc_word* 100 | 現在の単語。これは、モジュール名か関数名か検索ワードで 101 | す。 102 | 103 | 104 | 105 | ============================================================================== 106 | バグ *ref-perldoc-bugs* 107 | 108 | - ハイライトのための Perl コード片の検出が不完全です。 109 | - 現在は、単純にインデント量で判断しています。 110 | 111 | 112 | 113 | ============================================================================== 114 | 更新履歴 *ref-perldoc-changelog* 115 | 116 | 0.3.5 2015-05-17 117 | - carton に対応した。 118 | 119 | 0.3.4 2011-02-10 120 | - 補完候補に対して |ref#uniq()| を呼ぶようにした。 121 | - .pod ファイルも探すようにした。 122 | 123 | 0.3.3 2010-11-24 124 | - leave() 時のエラーを回避。 125 | 126 | 0.3.2 2010-11-06 127 | - Windows でうまく動かないことがあるバグを修正。 128 | - -f がないとき補完候補に関数名を出さないようにした。 129 | - |(ref-source-perldoc-switch)| を追加。 130 | - 補完候補にないモジュールも探すようにした。 131 | 132 | 0.3.1 2010-05-07 133 | - |ref.vim| 0.3.2 に対応。 134 | 135 | 0.3.0 2010-04-18 136 | - |ref.vim| 0.3.0 に対応。 137 | - |g:ref_perldoc_complete_head| オプションを追加。 138 | 139 | 0.2.0 2010-01-28 140 | - |ref.vim| 0.2.0 に対応。 141 | - -f オプションが使えないバグを修正。 142 | - |g:ref_perldoc_cmd| が |List| だと動作しないバグを修正。 143 | 144 | 0.1.2 2010-01-20 145 | - |ref#system()| を使うようにした。 146 | - -m オプションが使えないバグを修正。 147 | 148 | 0.1.1 2009-12-22 149 | - |ref#cache()| を使うようにした。 150 | 151 | 0.1.0 2009-12-17 152 | - 初版。 153 | 154 | 155 | ============================================================================== 156 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 157 | -------------------------------------------------------------------------------- /doc/ref-perldoc.txt: -------------------------------------------------------------------------------- 1 | *ref-perldoc.txt* A ref source for perldoc. 2 | 3 | Version: 0.3.5 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-perldoc-contents* 10 | 11 | INTRODUCTION |ref-perldoc-introduction| 12 | INTERFACE |ref-perldoc-interface| 13 | KEY MAPPINGS |ref-perldoc-key-mappings| 14 | CUSTOMIZING |ref-perldoc-customizing| 15 | ARGUMENTS |ref-perldoc-arguments| 16 | VARIABLES |ref-perldoc-variables| 17 | BUGS |ref-perldoc-bugs| 18 | CHANGELOG |ref-perldoc-changelog| 19 | 20 | 21 | ============================================================================== 22 | INTRODUCTION *ref-perldoc-introduction* 23 | 24 | *ref-perldoc* is a source for |ref.vim| to perldoc command. perldoc is a 25 | command line tool to view the reference manual on Perl. 26 | 27 | 28 | Requirements: 29 | - |ref.vim| 0.3.2 or later 30 | - perldoc 31 | 32 | 33 | 34 | ============================================================================== 35 | INTERFACE *ref-perldoc-interface* 36 | 37 | ------------------------------------------------------------------------------ 38 | KEY MAPPINGS *ref-perldoc-key-mappings* 39 | 40 | (ref-source-perldoc-switch) *(ref-source-perldoc-switch)* 41 | Switch between the module and the source code. 42 | Nothing is done for other pages. 43 | 44 | Default mappings: 45 | {lhs} {rhs} 46 | -------- ----------------------------- 47 | s (ref-source-perldoc-switch) 48 | 49 | 50 | 51 | ============================================================================== 52 | CUSTOMIZING *ref-perldoc-customizing* 53 | 54 | g:ref_perldoc_cmd *g:ref_perldoc_cmd* 55 | Specifies the perldoc command. This allows a |List| 56 | that includes command and arguments. 57 | The default value is "perldoc" if it is executable. 58 | Otherwise, it is "". 59 | 60 | g:ref_perldoc_complete_head *g:ref_perldoc_complete_head* 61 | The completion candidate of the module is displayed by 62 | each package name. 63 | The default value is 0. 64 | 65 | 66 | g:ref_perldoc_auto_append_f *g:ref_perldoc_auto_append_f* 67 | When a query only has lower-case characters, 68 | append '-f' option to let perldoc search for built-in 69 | functions. 70 | Search for a module if the function was not 71 | found. 72 | The default value is 0. 73 | 74 | 75 | 76 | ============================================================================== 77 | ARGUMENTS *ref-perldoc-arguments* 78 | 79 | As for this source, the following options can be used for the argument. 80 | 81 | -f The built-in function is targeted. It looks for the 82 | function when the module is not found even if this 83 | option doesn't exist. 84 | 85 | -m Show the source of the module. 86 | 87 | 88 | 89 | ============================================================================== 90 | VARIABLES *ref-perldoc-variables* 91 | 92 | While showing this source, the following variables are defined in 93 | |ref-viewer|. 94 | 95 | b:ref_perldoc_mode *b:ref_perldoc_mode* 96 | Display mode. Which is one of the following. 97 | "perl" Perl core document. 98 | "module" The module. 99 | "func" Built-in function. 100 | "source" Source code of module. 101 | "list" Matched list. 102 | 103 | b:ref_perldoc_word *b:ref_perldoc_word* 104 | The current word. It is module name, function name, 105 | or search word. 106 | 107 | 108 | 109 | ============================================================================== 110 | BUGS *ref-perldoc-bugs* 111 | 112 | - The detection of the Perl code splinter for highlight is imperfect. 113 | - It simply judges it from the amount of the indent now. 114 | 115 | 116 | 117 | ============================================================================== 118 | CHANGELOG *ref-perldoc-changelog* 119 | 120 | 0.3.5 2015-05-17 121 | - Support carton. 122 | 123 | 0.3.4 2011-02-10 124 | - Use |ref#uniq()| for the completion candidates. 125 | - Search .pod file. 126 | 127 | 0.3.3 2010-11-24 128 | - Avoid an error on leave(). 129 | 130 | 0.3.2 2010-11-06 131 | - Fixed the bug that might not work well with Windows. 132 | - Do not show function to the completion candidate when no -f. 133 | - Added |(ref-source-perldoc-switch)|. 134 | - Look for the module also that the completion candidate doesn't have. 135 | 136 | 0.3.1 2010-05-07 137 | - Updated for |ref.vim| 0.3.2. 138 | 139 | 0.3.0 2010-04-18 140 | - Updated for |ref.vim| 0.3.0. 141 | - Added |g:ref_perldoc_complete_head| option. 142 | 143 | 0.2.0 2010-01-28 144 | - Updated for |ref.vim| 0.2.0. 145 | - Fixed a bug that doesn't work the -f option. 146 | - Fixed a bug that doesn't work when |g:ref_perldoc_cmd| is a |List|. 147 | 148 | 0.1.2 2010-01-20 149 | - Using |ref#system()|. 150 | - Fixed a bug that doesn't work the -m option. 151 | 152 | 0.1.1 2009-12-22 153 | - Using |ref#cache()|. 154 | 155 | 0.1.0 2009-12-17 156 | - Initial version. 157 | 158 | 159 | ============================================================================== 160 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 161 | -------------------------------------------------------------------------------- /doc/ref-phpmanual.jax: -------------------------------------------------------------------------------- 1 | *ref-phpmanual.txt* PHP マニュアル用の ref ソース。 2 | 3 | Version: 0.3.1 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-phpmanual-contents* 10 | 11 | 概要 |ref-phpmanual-introduction| 12 | カスタマイズ |ref-phpmanual-customizing| 13 | 更新履歴 |ref-phpmanual-changelog| 14 | 15 | 16 | ============================================================================== 17 | 概要 *ref-phpmanual-introduction* 18 | 19 | *ref-phpmanual* は PHP マニュアル用の |ref.vim| のソースです。 20 | 21 | 22 | 要件: 23 | - |ref.vim| 0.3.2 以降 24 | - PHP Manual (Many HTML files) (http://www.php.net/download-docs.php) 25 | 26 | 27 | 28 | ============================================================================== 29 | カスタマイズ *ref-phpmanual-customizing* 30 | 31 | g:ref_phpmanual_path *g:ref_phpmanual_path* 32 | PHP マニュアルのパスです。パスはローカルのディレクトリ 33 | である必要があります。 34 | 35 | g:ref_phpmanual_cmd *g:ref_phpmanual_cmd* 36 | html を表示するためのコマンドです。%s は html ファイル 37 | に置き換えられます。コマンドとその引数を含む |List| も 38 | 指定できます。 39 | デフォルト値は以下の物でコマンドが実行可能なものです。 40 | 実行可能なものがない場合は "" です。 41 | - 'elinks -dump -no-numbering -no-references %s' 42 | - 'w3m -dump %s' 43 | - 'links -dump %s' 44 | - 'lynx -dump -nonumbers %s' 45 | 46 | 47 | 48 | ============================================================================== 49 | 更新履歴 *ref-phpmanual-changelog* 50 | 51 | 0.3.1 2010-05-07 52 | - |ref.vim| 0.3.2 に対応。 53 | 54 | 0.3.0 2010-04-18 55 | - |ref.vim| 0.3.0 に対応。 56 | 57 | 0.2.0 2010-01-28 58 | - |ref.vim| 0.2.0 に対応。 59 | - |g:ref_phpmanual_cmd| が |List| だと動作しないバグを修正。 60 | - クエリが空の際にリストを表示するようにした。 61 | - コマンドの実行がうまくいかないことがあるバグを修正。 62 | - 出力のエンコーディングを変換するようにした。 63 | 64 | 0.1.0 2010-01-21 65 | - |ref#cache()| を使うようにした。 66 | - |ref#system()| を使うようにした。 67 | 68 | 0.0.2 2009-08-20 69 | - 補完用にキャッシュを行うようにした。 70 | - キーワードのマッチを改善。 71 | 72 | 0.0.1 2009-08-09 73 | - 初版。 74 | 75 | 76 | ============================================================================== 77 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 78 | -------------------------------------------------------------------------------- /doc/ref-phpmanual.txt: -------------------------------------------------------------------------------- 1 | *ref-phpmanual.txt* A ref source for PHP manual. 2 | 3 | Version: 0.3.1 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-phpmanual-contents* 10 | 11 | INTRODUCTION |ref-phpmanual-introduction| 12 | CUSTOMIZING |ref-phpmanual-customizing| 13 | CHANGELOG |ref-phpmanual-changelog| 14 | 15 | 16 | ============================================================================== 17 | INTRODUCTION *ref-phpmanual-introduction* 18 | 19 | *ref-phpmanual* is a source for |ref.vim| for PHP manual. 20 | 21 | 22 | Requirements: 23 | - |ref.vim| 0.3.2 or later 24 | - PHP Manual (Many HTML files) (http://www.php.net/download-docs.php) 25 | 26 | 27 | 28 | ============================================================================== 29 | CUSTOMIZING *ref-phpmanual-customizing* 30 | 31 | g:ref_phpmanual_path *g:ref_phpmanual_path* 32 | The path of PHP manual. The path should be a local 33 | directory. 34 | 35 | g:ref_phpmanual_cmd *g:ref_phpmanual_cmd* 36 | A command to view the html file. %s is replaced by 37 | the html file name. This allows a |List| that 38 | includes command and arguments. 39 | The default value is the executable one of the 40 | following. If no executable one, it is "". 41 | - 'elinks -dump -no-numbering -no-references %s' 42 | - 'w3m -dump %s' 43 | - 'links -dump %s' 44 | - 'lynx -dump -nonumbers %s' 45 | 46 | 47 | 48 | ============================================================================== 49 | CHANGELOG *ref-phpmanual-changelog* 50 | 51 | 0.3.1 2010-05-07 52 | - Updated for |ref.vim| 0.3.2. 53 | 54 | 0.3.0 2010-04-18 55 | - Updated for |ref.vim| 0.3.0. 56 | 57 | 0.2.0 2010-01-28 58 | - Updated for |ref.vim| 0.2.0. 59 | - Fixed a bug that doesn't work when |g:ref_phpmanual_cmd| is a 60 | |List|. 61 | - Show the list when query is empty. 62 | - Fixed a bug to which the execution of the command might not work. 63 | - The encoding of the output was converted. 64 | 65 | 0.1.0 2010-01-21 66 | - Uisng |ref#cache()|. 67 | - Uisng |ref#system()|. 68 | 69 | 0.0.2 2009-08-20 70 | - It was made to cache to for the completion. 71 | - Improved the matching of keyword. 72 | 73 | 0.0.1 2009-08-09 74 | - Initial version. 75 | 76 | 77 | ============================================================================== 78 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 79 | -------------------------------------------------------------------------------- /doc/ref-pydoc.jax: -------------------------------------------------------------------------------- 1 | *ref-pydoc.txt* pydoc 用の ref ソース。 2 | 3 | Version: 0.4.2 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-pydoc-contents* 10 | 11 | 概要 |ref-pydoc-introduction| 12 | カスタマイズ |ref-pydoc-customizing| 13 | バグ |ref-pydoc-bugs| 14 | 更新履歴 |ref-pydoc-changelog| 15 | 16 | 17 | ============================================================================== 18 | 概要 *ref-pydoc-introduction* 19 | 20 | *ref-pydoc* は pydoc コマンド用の |ref.vim| のソースです。pydoc は Python のリ 21 | ファレンスマニュアルを見るためのコマンドラインツールです。 22 | 23 | 24 | 要件: 25 | - |ref.vim| 0.4.0 以降 26 | - pydoc 27 | 28 | 29 | 30 | ============================================================================== 31 | カスタマイズ *ref-pydoc-customizing* 32 | 33 | g:ref_pydoc_cmd *g:ref_pydoc_cmd* 34 | pydoc コマンドを指定します。コマンドとその引数を含む 35 | |List| も指定できます。 36 | デフォルト値は、"python" コマンドが実行可能ならば 37 | "python -m pydoc" です。そうでなければ "" です。 38 | 39 | g:ref_pydoc_complete_head *g:ref_pydoc_complete_head* 40 | モジュールを補完する際にモジュール名単位で候補を表示し 41 | ます。 42 | デフォルト値は 0 です。 43 | 44 | 45 | 46 | ============================================================================== 47 | 更新履歴 *ref-pydoc-changelog* 48 | 49 | 0.4.2 2014-09-06 50 | - |g:ref_pydoc_cmd| のデフォルト値を変更。 51 | 52 | 0.4.1 2010-06-03 53 | - リストが表示できないバグを修正。 54 | - キーワードのマッチを少し改善。 55 | 56 | 0.4.0 2010-05-31 57 | - |ref.vim| 0.4.0 に対応。 58 | 59 | 0.3.1 2010-05-07 60 | - |ref.vim| 0.3.2 に対応。 61 | 62 | 0.3.0 2010-04-18 63 | - |ref.vim| 0.3.0 に対応。 64 | - |g:ref_pydoc_complete_head| オプションを追加。 65 | 66 | 0.2.0 2010-01-28 67 | - |g:ref_perldoc_cmd| が |List| だと動作しないバグを修正。 68 | 69 | 0.1.2 2010-01-21 70 | - |ref#system()| を使うようにした。 71 | 72 | 0.1.1 2009-12-22 73 | - |ref#cache()| を使うようにした。 74 | 75 | 0.1.0 2009-08-21 76 | - 初版。 77 | 78 | 79 | ============================================================================== 80 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 81 | -------------------------------------------------------------------------------- /doc/ref-pydoc.txt: -------------------------------------------------------------------------------- 1 | *ref-pydoc.txt* A ref source for pydoc. 2 | 3 | Version: 0.4.2 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-pydoc-contents* 10 | 11 | INTRODUCTION |ref-pydoc-introduction| 12 | CUSTOMIZING |ref-pydoc-customizing| 13 | BUGS |ref-pydoc-bugs| 14 | CHANGELOG |ref-pydoc-changelog| 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *ref-pydoc-introduction* 19 | 20 | *ref-pydoc* is a source for |ref.vim| to pydoc command. pydoc is a command 21 | line tool to view the reference manual on Python. 22 | 23 | 24 | Requirements: 25 | - |ref.vim| 0.4.0 or later 26 | - pydoc 27 | 28 | 29 | 30 | ============================================================================== 31 | CUSTOMIZING *ref-pydoc-customizing* 32 | 33 | g:ref_pydoc_cmd *g:ref_pydoc_cmd* 34 | Specifies the pydoc command. This allows a |List| 35 | that includes command and arguments. 36 | The default value is "python -m pydoc" if "python" is 37 | executable. Otherwise, it is "". 38 | 39 | g:ref_pydoc_complete_head *g:ref_pydoc_complete_head* 40 | The completion candidate of the module is displayed by 41 | each module name. 42 | The default value is 0. 43 | 44 | 45 | 46 | ============================================================================== 47 | CHANGELOG *ref-pydoc-changelog* 48 | 49 | 0.4.2 2014-09-06 50 | - Change the default value of |g:ref_pydoc_cmd|. 51 | 52 | 0.4.1 2010-06-03 53 | - Fixed the bug to which the list cannot be shown. 54 | - Improved the matching of keyword a little. 55 | 56 | 0.4.0 2010-05-31 57 | - Updated for |ref.vim| 0.4.0. 58 | 59 | 0.3.1 2010-05-07 60 | - Updated for |ref.vim| 0.3.2. 61 | 62 | 0.3.0 2010-04-18 63 | - Updated for |ref.vim| 0.3.0. 64 | - Added |g:ref_pydoc_complete_head| option. 65 | 66 | 0.2.0 2010-01-28 67 | - Fixed a bug that doesn't work when |g:ref_pydoc_cmd| is a |List|. 68 | 69 | 0.1.2 2010-01-21 70 | - Using |ref#system()|. 71 | 72 | 0.1.1 2009-12-22 73 | - Using |ref#cache()|. 74 | 75 | 0.1.0 2009-08-21 76 | - Initial version. 77 | 78 | 79 | ============================================================================== 80 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 81 | -------------------------------------------------------------------------------- /doc/ref-refe.jax: -------------------------------------------------------------------------------- 1 | *ref-refe.txt* ReFe 用の ref ソース。 2 | 3 | Version: 0.4.0 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-refe-contents* 10 | 11 | 概要 |ref-refe-introduction| 12 | カスタマイズ |ref-refe-customizing| 13 | バグ |ref-refe-bugs| 14 | 更新履歴 |ref-refe-changelog| 15 | 16 | 17 | ============================================================================== 18 | 概要 *ref-refe-introduction* 19 | 20 | *ref-refe* は refe コマンド用の |ref.vim| のソースです。ReFe は Ruby のリ 21 | ファレンスマニュアルを見るためのコマンドラインツールです。 22 | 23 | 24 | 要件: 25 | - |ref.vim| 0.4.0 以降 26 | - ReFe (http://docs.ruby-lang.org/ja/2.2.0/doc/ReFe.html) 27 | 28 | オプション: 29 | - |ref-man| 30 | - [[man:page(1)]] のようなキーワードを開くのに必要。 31 | - RSense (http://cx4a.org/software/rsense/index.ja.html) 32 | 33 | 34 | 35 | ============================================================================== 36 | カスタマイズ *ref-refe-customizing* 37 | 38 | g:ref_refe_cmd *g:ref_refe_cmd* 39 | refe コマンドを指定します。コマンドとその引数を含む 40 | |List| も指定できます。 41 | デフォルト値は、実行可能ならば "refe" です。そうでなけ 42 | れば "" です。 43 | 44 | g:ref_refe_encoding *g:ref_refe_encoding* 45 | refe コマンドの出力のエンコードを指定します。 46 | この変数が空の場合、出力は変換されません。 47 | デフォルト値は 'termencoding' です。 48 | 49 | g:ref_refe_version *g:ref_refe_version* 50 | refe コマンドのバージョンです。値は 1 か 2 です。この 51 | オプションは `refe --version` によって自動的に設定され 52 | ます。 53 | 54 | g:ref_refe_rsense_cmd *g:ref_refe_rsense_cmd* 55 | RSense のコマンドを指定します。文字列か |List| を指定 56 | します。空の場合は RSense との連携は行いません。 57 | デフォルト値は空です。 58 | 59 | 60 | 61 | ============================================================================== 62 | バグ *ref-refe-bugs* 63 | 64 | - refe のコマンドラインオプションが指定されることは想定されていません。 65 | 66 | 67 | 68 | ============================================================================== 69 | 更新履歴 *ref-refe-changelog* 70 | 71 | 0.4.0 2010-05-31 72 | - |ref.vim| 0.4.0 に対応。 73 | 74 | 0.3.2 2010-05-08 75 | - |ref.vim| 0.3.2 に対応。 76 | 77 | 0.3.1 2010-04-21 78 | - refe1 のメソッドのページが崩れていたのを修正。 79 | 80 | 0.3.0 2010-04-18 81 | - |ref.vim| 0.3.0 に対応。 82 | - refe2 に対応。 83 | - RSense との連携に対応。 84 | 85 | 0.2.0 2010-01-28 86 | - |g:ref_refe_cmd| が |List| だと動作しないバグを修正。 87 | 88 | 0.1.0 2010-01-21 89 | - |ref#system()| を使うようにした。 90 | 91 | 0.0.2 2009-08-20 92 | - |ku-ref| のために挙動を改良。 93 | 94 | 0.0.1 2009-08-09 95 | - 初版。 96 | 97 | 98 | ============================================================================== 99 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 100 | -------------------------------------------------------------------------------- /doc/ref-refe.txt: -------------------------------------------------------------------------------- 1 | *ref-refe.txt* A ref source for ReFe. 2 | 3 | Version: 0.4.0 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-refe-contents* 10 | 11 | INTRODUCTION |ref-refe-introduction| 12 | CUSTOMIZING |ref-refe-customizing| 13 | BUGS |ref-refe-bugs| 14 | CHANGELOG |ref-refe-changelog| 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *ref-refe-introduction* 19 | 20 | *ref-refe* is a source for |ref.vim| to refe command. ReFe is a command line 21 | tool to view the reference manual of Ruby. 22 | 23 | 24 | Requirements: 25 | - |ref.vim| 0.4.0 or later 26 | - ReFe (http://docs.ruby-lang.org/ja/2.2.0/doc/ReFe.html) 27 | 28 | Optional: 29 | - |ref-man| 30 | - To open a keyword like [[man:page(1)]]. 31 | - RSense (http://cx4a.org/software/rsense/) 32 | 33 | 34 | 35 | ============================================================================== 36 | CUSTOMIZING *ref-refe-customizing* 37 | 38 | g:ref_refe_cmd *g:ref_refe_cmd* 39 | Specifies the refe command. This allows a |List| that 40 | includes command and arguments. 41 | The default value is "refe" if it is executable. 42 | Otherwise, it is "". 43 | 44 | g:ref_refe_encoding *g:ref_refe_encoding* 45 | Specifies the encoding of output of the refe command. 46 | Conversion is not done when this variable is empty. 47 | The default value is 'termencoding'. 48 | 49 | g:ref_refe_version *g:ref_refe_version* 50 | The version of refe command. The value is 1 or 2. 51 | This option will be setted automatically by `refe 52 | --version`. 53 | 54 | g:ref_refe_rsense_cmd *g:ref_refe_rsense_cmd* 55 | Specifies the command of RSense. This is a string or 56 | a |List|. When this is empty, RSense is not used. 57 | The default value is empty. 58 | 59 | 60 | 61 | ============================================================================== 62 | BUGS *ref-refe-bugs* 63 | 64 | - It is not assumed that a command line options of refe is specified. 65 | 66 | 67 | 68 | ============================================================================== 69 | CHANGELOG *ref-refe-changelog* 70 | 71 | 0.4.0 2010-05-31 72 | - Updated for |ref.vim| 0.4.0. 73 | 74 | 0.3.2 2010-05-08 75 | - Updated for |ref.vim| 0.3.2. 76 | 77 | 0.3.1 2010-04-21 78 | - Fixed the collapses page of the method of refe1. 79 | 80 | 0.3.0 2010-04-18 81 | - Updated for |ref.vim| 0.3.0. 82 | - Support refe2. 83 | - Support to cooperation with RSense. 84 | 85 | 0.2.0 2010-01-28 86 | - Fixed a bug that doesn't work when |g:ref_refe_cmd| is a |List|. 87 | 88 | 0.1.0 2010-01-21 89 | - Using |ref#system()|. 90 | 91 | 0.0.2 2009-08-20 92 | - Improved the behavior for |ku-ref|. 93 | 94 | 0.0.1 2009-08-09 95 | - Initial version. 96 | 97 | 98 | ============================================================================== 99 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 100 | -------------------------------------------------------------------------------- /doc/ref-webdict.jax: -------------------------------------------------------------------------------- 1 | *ref-webdict.txt* Web の辞書用の ref ソース。 2 | 3 | Version: 1.0 4 | Author : thinca 5 | License: zlib License 6 | 7 | ============================================================================== 8 | 目次 *ref-webdict-contents* 9 | 10 | 概要 |ref-webdict-introduction| 11 | 引数 |ref-webdict-arguments| 12 | カスタマイズ |ref-webdict-customizing| 13 | 更新履歴 |ref-webdict-changelog| 14 | 15 | 16 | 17 | ============================================================================== 18 | 概要 *ref-webdict-introduction* 19 | 20 | *ref-webdict* は Web 上にある辞書を扱うための |ref.vim| ソースです。 21 | 22 | 要件: 23 | - |ref.vim| 0.3.2 以降 24 | - 任意のテキストブラウザ 25 | - elinks 26 | - w3m 27 | - links 28 | - lynx 29 | - wwwrenderer-vim (https://github.com/mattn/wwwrenderer-vim) 30 | 31 | 32 | 33 | ============================================================================== 34 | 引数 *ref-webdict-arguments* 35 | 36 | このソースには、使用するサイトの設定の名前と、引きたいキーワードを指定します。 37 | 名前については |g:ref_source_webdict_sites| を参照してください。 > 38 | 39 | :Ref webdict {site-name} {keyword} 40 | 41 | |g:ref_source_webdict_sites| に "default" を指定している場合、{site-name} を省 42 | 略し、{keyword} が既存の {site-name} に一致しなかった場合は "default" の値が 43 | {site-name} として使われます。 > 44 | 45 | :Ref webdict {keyword} 46 | 47 | 48 | 49 | ============================================================================== 50 | カスタマイズ *ref-webdict-customizing* 51 | 52 | g:ref_source_webdict_sites *g:ref_source_webdict_sites* 53 | 利用する Web の辞書を辞書型の変数で指定します。キーに設定の名前、値に 54 | は URL か、以下のキーを持った辞書を指定します。 55 | 56 | "url" 57 | Web の辞書の URL です。%s がキーワードに置換されます。 58 | "keyword_encoding" 59 | キーワードのエンコーディングです。無指定の場合は "utf-8" が使 60 | われます。 61 | "output_encoding" 62 | 出力のエンコーディングです。無指定の場合は、 63 | |g:ref_source_webdict_encoding| が使われます。 64 | "cache" 65 | 一度開いたページをキャッシュするかどうかです。無指定の場合は、 66 | |g:ref_source_webdict_use_cache| が使われます。 67 | "filter" 68 | 出力を整形するための |Funcref| です。関数は出力を引数として取 69 | ります。 70 | "line" 71 | バッファを開いた際にフォーカスする行番号です。 72 | 73 | 各設定のキーに指定した名前を、引数の先頭に指定します。 74 | キーに "default"、値に設定の名前を文字列で設定すると、サイト名が省略さ 75 | れた際に使用されます。詳しくは |ref-webdict-arguments| を参照してくだ 76 | さい。 77 | 78 | g:ref_source_webdict_cmd *g:ref_source_webdict_cmd* 79 | Webページを表示するためのコマンドです。%s はキーワードを引くための url 80 | に置き換えられます。コマンドとその引数を含む |List| も指定できます。 81 | デフォルト値は以下の物でコマンドが実行可能なものです。実行可能なものが 82 | ない場合は "" です。 83 | - 'elinks -dump -no-numbering -no-references %s' 84 | - 'w3m -dump %s' 85 | - 'links -dump %s' 86 | - 'lynx -dump -nonumbers %s' 87 | - '=wwwrenderer#render("%s")' 88 | 89 | g:ref_source_webdict_encoding *g:ref_source_webdict_encoding* 90 | |g:ref_source_webdict_cmd| で指定したコマンドの出力のエンコードを指定 91 | します。この変数が空の場合、出力は変換されません。 92 | デフォルト値は 'termencoding' です。 93 | 94 | g:ref_source_webdict_use_cache *g:ref_source_webdict_use_cache* 95 | 一度開いたページをキャッシュします。 96 | デフォルト値は 0 です。 97 | 98 | 99 | 100 | ============================================================================== 101 | 更新履歴 *ref-webdict-changelog* 102 | 103 | 1.0 2012-05-12 104 | - 初版。 105 | 106 | 107 | 108 | ============================================================================== 109 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 110 | -------------------------------------------------------------------------------- /doc/ref-webdict.txt: -------------------------------------------------------------------------------- 1 | *ref-webdict.txt* A ref source for Web dict. 2 | 3 | Version: 1.0 4 | Author : thinca 5 | License: zlib License 6 | 7 | ============================================================================== 8 | CONTENTS *ref-webdict-contents* 9 | 10 | INTRODUCTION |ref-webdict-introduction| 11 | ARGUMENTS |ref-webdict-arguments| 12 | CUSTOMIZING |ref-webdict-customizing| 13 | CHANGELOG |ref-webdict-changelog| 14 | 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *ref-webdict-introduction* 19 | 20 | *ref-webdict* is a source for |ref.vim| to manipulate the dictionary on Web. 21 | 22 | Requirements: 23 | - |ref.vim| 0.3.2 or later 24 | - Optional text browser 25 | - elinks 26 | - w3m 27 | - links 28 | - lynx 29 | - wwwrenderer-vim (https://github.com/mattn/wwwrenderer-vim) 30 | 31 | 32 | 33 | ============================================================================== 34 | ARGUMENTS *ref-webdict-arguments* 35 | 36 | For this source, specify the setting name of a using site and the keyword that 37 | you want to look up. For a name, see |g:ref_source_webdict_sites|. > 38 | 39 | :Ref webdict {site-name} {keyword} 40 | 41 | If you specify "default" for |g:ref_source_webdict_sites|, or if {site-name} 42 | is omitted and {keyword} doesn't match an existing {site-name}, the value of 43 | "default" is used as {site-name}. > 44 | 45 | :Ref webdict {keyword} 46 | 47 | 48 | 49 | ============================================================================== 50 | CUSTOMIZING *ref-webdict-customizing* 51 | 52 | g:ref_source_webdict_sites *g:ref_source_webdict_sites* 53 | Specify the using Web dictionary by a dict variable. Put the name of 54 | setting for a key, specify the URL or the dictionary having the 55 | following key for a value. 56 | 57 | "url" 58 | A URL for the Web dictionary. %s is replaced by a keyword. 59 | "keyword_encoding" 60 | Encoding for the keyword. If not specified, "utf-8" is used. 61 | "output_encoding" 62 | Encoding for output. If not specified, 63 | |g:ref_source_webdict_encoding| is used. 64 | "cache" 65 | Whether cache the page you opened once. If not specified, 66 | |g:ref_source_webdict_use_cache| is used. 67 | "filter" 68 | |Funcref| to format output. The function gets output as 69 | arguments. 70 | "line" 71 | Focus the line number when you open a buffer. 72 | 73 | Specify the name putting a key of each setting for the head of 74 | arguments. 75 | If specify "default" for a key and put the name of a setting for a 76 | value by string, it is used when a site name is omitted. For more 77 | detail, see |ref-webdict-arguments|. 78 | 79 | g:ref_source_webdict_cmd *g:ref_source_webdict_cmd* 80 | A command to show the Web page. %s is replaced by the url to look up 81 | a keyword. This allows a |List| that includes command and arguments. 82 | The default value is the executable one of the following. If no 83 | executable one, it is "". 84 | - 'elinks -dump -no-numbering -no-references %s' 85 | - 'w3m -dump %s' 86 | - 'links -dump %s' 87 | - 'lynx -dump -nonumbers %s' 88 | - '=wwwrenderer#render("%s")' 89 | 90 | g:ref_source_webdict_encoding *g:ref_source_webdict_encoding* 91 | Put a encoding for the command output specified with 92 | |g:ref_source_webdict_cmd|. When this variable is empty, output isn't 93 | converted. 94 | The default value is 'termencoding'. 95 | 96 | g:ref_source_webdict_use_cache *g:ref_source_webdict_use_cache* 97 | Cache the page you opened once. 98 | The default value is 0. 99 | 100 | 101 | 102 | ============================================================================== 103 | CHANGELOG *ref-webdict-changelog* 104 | 105 | 1.0 2012-05-12 106 | - Initial version. 107 | 108 | 109 | 110 | ============================================================================== 111 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 112 | -------------------------------------------------------------------------------- /doc/ref.jax: -------------------------------------------------------------------------------- 1 | *ref.txt* 総合リファレンスビューア。 2 | 3 | Version: 0.4.3 4 | Author : thinca 5 | License: クリエイティブ・コモンズの表示 2.1 日本ライセンス 6 | 7 | 8 | ============================================================================== 9 | 目次 *ref-contents* 10 | 11 | 概要 |ref-introduction| 12 | リファレンスビューア |ref-viewer| 13 | インターフェース |ref-interface| 14 | 関数 |ref-functions| 15 | コマンド |ref-commands| 16 | キーマッピング |ref-key-mappings| 17 | カスタマイズ |ref-customizing| 18 | ソース |ref-sources| 19 | オートロード |ref-autoload| 20 | 更新履歴 |ref-changelog| 21 | 22 | 23 | ============================================================================== 24 | 概要 *ref-introduction* 25 | 26 | *ref.vim* はリファレンスを見るための Vim プラグインです。このプラグインは 27 | ビューアのコアの部分とリファレンスのソースに分かれています。これにより、同じイ 28 | ンターフェースで複数のリファレンスを閲覧できます。 29 | 30 | このプラグインには以下のソースが含まれています: 31 | - clojure (|ref-clojure.txt|) 32 | - erlang (|ref-erlang.txt|) 33 | - man (|ref-man.txt|) 34 | - perldoc (|ref-perldoc.txt|) 35 | - phpmanual (|ref-phpmanual.txt|) 36 | - pydoc (|ref-pydoc.txt|) 37 | - redis 38 | - refe (|ref-refe.txt|) 39 | - rfc 40 | - webdict (|ref-webdict.txt|) 41 | 42 | 標準添付以外のソースの一覧: 43 | https://github.com/thinca/vim-ref/wiki/sources 44 | 45 | 他のインターフェースも利用できます: 46 | - ku-ref (|ku-ref.txt|) 47 | - unite-ref (|unite-ref.txt|) 48 | 49 | 要件: 50 | - Vim 7.2 以降 51 | 52 | 最新版: 53 | https://github.com/thinca/vim-ref 54 | 55 | 56 | 57 | ============================================================================== 58 | リファレンスビューア *ref-viewer* 59 | 60 | |ref-viewer| は、リファレンスを見るための単なるバッファです。これは |:help| と 61 | 同じように |:Ref| コマンドや |(ref-keyword)| キーシーケンスによって開か 62 | れます。|ref-viewer| がカレントタブページ内で既に開かれていた場合はそれが再利 63 | 用されます。 64 | |ref-viewer| はバッファ毎にそれぞれ表示したページの履歴を保持していて、いつで 65 | も戻ることができます。 66 | 67 | 68 | 69 | ============================================================================== 70 | インターフェース *ref-interface* 71 | 72 | ------------------------------------------------------------------------------ 73 | 関数 *ref-functions* 74 | 75 | ref#open({source-name}, {query} [, {options}]) *ref#open()* 76 | |:Ref| の関数版です。{options} は辞書で指定します。 77 | 78 | ref#jump([{mode} [, {source-name}]] [, {options}]) *ref#jump()* 79 | カーソル位置からクエリを探してソースを開きます。ソース 80 | 名が省略された場合、|ref#detect()| が使われます。 81 | {mode} にはクエリをどのように取得するかを指定します。 82 | 以下のうちのいずれかを指定します。 83 | 84 | "normal" カーソル下からクエリを取得します。これ 85 | がデフォルトです。 86 | "visual" 直前に選択された範囲の文字列がクエリと 87 | して使われます。 88 | "line"/"char"/"block" 89 | これによりこの関数は 'operatorfunc' と 90 | して機能します。 91 | 92 | 引数に辞書が渡された場合、|ref#open()| の {options} と 93 | 同じように扱われます。 94 | 95 | ref#register({source}) *ref#register()* 96 | ref#register({list-of-sources}) 97 | 新しいソースを登録します。{source} に関しては 98 | |ref-sources|を参照してください。 99 | 100 | ref#available_source_names() *ref#available_source_names()* 101 | すでに登録されているソースの名前のリスト(|List|)を返し 102 | ます。 103 | 104 | ref#available_sources([{source-name}]) *ref#available_sources()* 105 | すでに登録されているソースの一覧を辞書(|Dictionary|)で 106 | 返します。{source-name} が指定されてその名前のソースが 107 | 登録されていた場合はそのソースを返します。そうでない場 108 | 合は 0 を返します。ソースを変更した場合、内部に影響を 109 | 与えます。 110 | 111 | ref#detect() *ref#detect()* 112 | カレントバッファに適切なソースを検出します。この関数は 113 | |g:ref_detect_filetype| を使います。検出に失敗した場合 114 | は空の文字列を返します。 115 | 116 | ref#register_detection({ft}, {source} [, {way}]) *ref#register_detection()* 117 | |g:ref_detect_filetype| にエントリを登録します。すでに 118 | 登録済みの場合は、{way} の値によって以下のようになりま 119 | す。 120 | "ignore" 登録しません。 121 | "overwrite" 置き換えます。 122 | "prepend" リストでない場合はリストにして、先頭に 123 | 追加します。 124 | "append" リストでない場合はリストにして、末尾に 125 | 追加します。 126 | デフォルトは "ignore" です。 127 | 128 | 129 | 以下の関数は主に |ref-sources| によって使われます。 130 | 131 | ref#cache({source-name} [, {name} [, {gather} [, {update}]]]) *ref#cache()* 132 | 取得に時間のかかるリストをキャッシュするための関数で 133 | す。この関数を介することでリストは自動でキャッシュされ 134 | ます。以降はキャッシュされたリストを返します。 135 | {source-name} はソース名です。 136 | {name} は識別のための任意の名前です。これは空文字列で 137 | あってはいけません。 138 | {name} が省略された場合、すでにキャッシュされている 139 | {name} のリストを返します。 140 | {gather} は以下のうちのいずれかです。 141 | 1. リストを取得するための |Funcref|。 142 | 2. |eval()| で評価可能な文字列。(スコープに注意。) 143 | 3. 辞書関数 "call" をメンバに持つ辞書。 144 | 4. キャッシュする |List|. 145 | 1 と 3 は関数の引数に {name} を受け取ります。 146 | 2 は a:name を参照できます。 147 | いずれの場合もリストを返す必要があります。 148 | {gather} が省略された場合、キャッシュされたリストを取 149 | 得します。キャッシュが存在しない場合、0 を返します。 150 | {update} に 0 以外が与えられた場合、キャッシュを更新し 151 | ます。 152 | 153 | ref#rmcache([{source-name} [, {name}]]) *ref#rmcache()* 154 | |ref#cache()| で生成されたキャッシュを削除します。 155 | {name} が省略された場合は {source-name} の全てのキャッ 156 | シュを削除します。 {source-name} が省略された場合は全 157 | てのキャッシュを削除します。 158 | 159 | ref#system({expr} [, {input}]) *ref#system()* 160 | |system()| と同じですが、{expr} はリスト(|List|)を取り 161 | ます。各要素は |shellescape()| で処理されます。 162 | {expr} が文字列の場合、|ref#to_list()| によって分割さ 163 | れます。 164 | この関数は以下の要素を持つ辞書(|Dictionary|)を返しま 165 | す。 166 | result: リターンコード。 167 | stdout: 標準出力。 168 | stderr: 標準エラー出力。 169 | この関数は、|g:ref_use_vimproc| が真の時は |system()| 170 | の代わりに |vimproc#system()| を使用します。 171 | vimproc: https://github.com/Shougo/vimproc 172 | 173 | ref#to_list({expr}, ...) *ref#to_list()* 174 | {expr} を |List| に変換します。 175 | {expr} が |List| の場合、{expr} をそのまま返します。 176 | {expr} が文字列の場合、|split()| で分割します。 177 | それ以外の場合、{expr} を含む |List| を返します。 178 | 複数の引数を渡した場合、全ての引数を変換したものを連結 179 | して返します。 180 | 181 | ref#uniq({list}) *ref#uniq()* 182 | 重複した項目を取り除いた新しいリストを返します。結果 183 | は|sort()| でソートされます。 184 | 185 | ref#get_text_on_cursor({pattern}) *ref#get_text_on_cursor()* 186 | カーソル下のテキストが指定したパターンである場合、その 187 | テキストを取得します。パターンにマッチしない場合は空文 188 | 字列を返します。 189 | 190 | 191 | ------------------------------------------------------------------------------ 192 | コマンド *ref-commands* 193 | 194 | :Ref [{options}] {source-name} [{query}] *:Ref* 195 | |ref-viewer| を開きます。 [query] は |ref-sources| の 196 | クエリに使われます。 197 | {source-name} の前にオプションを指定できます。 198 | オプションは "-" で始まります。以下のオプションが使用 199 | できます。 200 | *:Ref-option* 201 | -open={command} |g:ref_open| を上書きします。 202 | -new 強制的に新しくビューアを開きます。 203 | -nocache キャッシュを使いません。 204 | -noenter |ref-viewer| へ移動しません。 205 | -updatecache キャッシュを更新します。 206 | 207 | :RefHistory *:RefHistory* 208 | |ref-viewer| の履歴をリスト表示します。数字を入力する 209 | ことでそこへジャンプできます。 210 | |ref-viewer| 内でのみ使用できます。 211 | 212 | 213 | ------------------------------------------------------------------------------ 214 | キーマッピング *ref-key-mappings* 215 | 216 | (ref-keyword) *(ref-keyword)* 217 | カーソル位置のキーワードのリファレンスにジャンプしま 218 | す。|ref-source-attr-get_keyword()| も参照してくださ 219 | い。ソースの検出には |ref#detect()| が使われます。ソー 220 | スが見つからなかった場合は |K| を押したのと同じになり 221 | ます。 222 | 223 | 224 | 以下のキーマッピングは |ref-viewer| 内で利用可能です。 225 | 226 | [count] (ref-forward) *(ref-forward)* 227 | [count] (ref-back) *(ref-back)* 228 | |ref-viewer| 内での履歴を辿ります。 229 | 230 | 231 | *g:ref_no_default_key_mappings* 232 | 以下のキーマッピングは g:ref_no_default_key_mappings を定義していなかった場合 233 | に利用可能です。 234 | 235 | (全体) 236 | {lhs} {rhs} 237 | -------- ----------------------------- 238 | K (ref-keyword) 239 | 240 | (|ref-viewer| 内) 241 | {lhs} {rhs} 242 | -------- ----------------------------- 243 | (ref-keyword) 244 | <2-LeftMouse> (ref-keyword) 245 | (ref-keyword) 246 | (ref-back) 247 | (ref-back) 248 | (ref-forward) 249 | 250 | 251 | 252 | ============================================================================== 253 | カスタマイズ *ref-customizing* 254 | 255 | FileType ref *filetype-ref* 256 | このイベントは |ref-viewer| の初期化後に発生します。 257 | 例: > 258 | autocmd FileType ref call s:initialize_ref_viewer() 259 | function! s:initialize_ref_viewer() 260 | nmap b (ref-back) 261 | nmap f (ref-forward) 262 | nnoremap q c 263 | setlocal nonumber 264 | " ... and more settings ... 265 | endfunction 266 | < 267 | 268 | FileType ref-{source-name} *filetype-ref-{source-name}* 269 | |filetype-ref| は最初に |ref-viewer| が開かれた際に発生しますが、実際 270 | に最終的に設定されるファイルタイプは ref-{source-name} になります。 271 | このイベントはソースが切り替わる度に発生します。 272 | 273 | g:ref_open *g:ref_open* 274 | |ref-viewer| を開く際の補助コマンドです。例えば、|:vsplit| や 275 | |:tabnew|などを指定します。デフォルト値は "split" です。 276 | 277 | g:ref_cache_dir *g:ref_cache_dir* 278 | キャッシュを保持しておくためのディレクトリです。|ref#cache()| はこの値 279 | を参照してキャッシュファイルを生成します。デフォルト値は 280 | "~/.cache/vim-ref" です。~ はホームディレクトリを表します。 281 | 282 | g:ref_use_vimproc *g:ref_use_vimproc* 283 | 真の時、|ref#system()| は |vimproc| を使います。デフォルト値は、 284 | |vimproc#system()| が存在する場合は真、そうでない場合は偽です。 285 | 286 | g:ref_detect_filetype *g:ref_detect_filetype* 287 | |filetype| からソースを検出するための |Dictionary| を指定します。これ 288 | は |ref#detect()| で使用されます。キーにファイルタイプ、値にはソース 289 | 名、ソース名のリスト、もしくは |Funcref| を指定します。 290 | リストの場合、最初に本文がみつかったソースが使われます。リストはネスト 291 | 可能です。 292 | |Funcref| の場合、その関数はファイルタイプを引数にとり、ソース名か、 293 | ソース名のリストか、 |Funcref| を返します。検出できない場合は空文字列 294 | を返します。 295 | キーに _ を使うと、ファイルタイプが登録されていなかった場合に使用され 296 | ます。いくつかのソースはロード時にエントリを登録します。 297 | 298 | g:ref_noenter *g:ref_noenter* 299 | b:ref_noenter *b:ref_noenter* 300 | |:Ref-option| の -noenter を常に有効にします。 301 | 302 | 303 | 304 | ============================================================================== 305 | ソース *ref-sources* 306 | 307 | ソースは辞書(|Dictionary|)です。ソースは以下の属性を持ちます。関数は辞書関数 308 | (|Dictionary-function|)です。{query} は|:Ref| で渡される文字列です。 309 | 310 | name *ref-source-attr-name* 311 | 必須。このソースの名前です。 312 | 313 | get_body({query}) *ref-source-attr-get_body()* 314 | 必須。リファレンスの本文を改行区切りの文字列かリストで 315 | 返します。 316 | また、以下の要素を持つ辞書を返すこともできます。 317 | body: 必須。リファレンスの本文。 318 | query: 任意。正規化された {query}。 319 | 本文が見つからない場合はエラーメッセージと共に例外を投 320 | げます。 321 | 322 | available() *ref-source-attr-available()* 323 | 任意。ソースが利用可能ならば真を返します。省略した場合 324 | は常に利用可能です。 325 | 326 | opened({query}) *ref-source-attr-opened()* 327 | 任意。この関数はリファレンスページが開かれる度に呼ばれ 328 | ます。このタイミングで |ref-viewer| を初期化のために 329 | 編集することができます。 330 | 331 | get_keyword() *ref-source-attr-get_keyword()* 332 | 任意。現在のカーソル位置からキーワードを取得します。未 333 | 定義の場合は "expand('')" が使われます。カーソ 334 | ル位置は復元されるので、カーソルを動かしても問題ありま 335 | せん。 336 | キーワードは {query} として扱われます。 337 | [{source-name}, {keyword}] の形式のリストを返すことも 338 | できます。この場合指定されたソースでキーワードが開かれ 339 | ます。 340 | キーワードが見つからない場合はエラーメッセージと共に例 341 | 外を投げます。 342 | 343 | complete({query}) *ref-source-attr-complete()* 344 | 任意。コマンドラインの補完リストを返します。 345 | 346 | normalize({query}) *ref-source-attr-normalize()* 347 | 任意。{query} を正規化します。これはバッファ名として使 348 | われ、そして get_body() と opened() に渡されます。 349 | 350 | leave() *ref-source-attr-leave()* 351 | 任意。この関数は別のソースに移動する際に呼ばれます。 352 | 353 | cache({name} [, {gather} [, {update}]]) *ref-source-attr-cache()* 354 | 本体によって定義されます。|ref#cache()| の短縮版です。 355 | 356 | ------------------------------------------------------------------------------ 357 | オートロード *ref-autoload* 358 | 359 | オートロード関数 ref#{source-name}#define() は、autoload/ref.vim が読み込まれ 360 | る際に自動的に呼ばれ、戻り値がソースとして登録されます。 361 | 362 | 363 | 364 | ============================================================================== 365 | 更新履歴 *ref-changelog* 366 | 367 | x.x.x xxxx-xx-xx 368 | - |ref#register()| がソースのリストを受け取れるようにした。 369 | - Vim 7.3.162 でエラーが出ていたのを修正。 370 | - |ref#rmcache()| で削除されないファイルがあったのを修正。 371 | 372 | 0.4.3 2011-01-20 373 | - |ref#rmcache()| を追加。 374 | - |g:ref_detect_filetype| にソースのリストが使えるようにした。 375 | - |g:ref_detect_filetype| の関数が |Funcref| を返せるようにした。 376 | - |ref#register_detection()| を改善。 377 | - |ref-source-attr-available()| を省略可能にした。 378 | - |ref#cache()| で "/" を含む {name} が取り出せないバグを修正。 379 | - |ref#uniq()| に空文字列を含むリストを渡すとエラーになるバグを修正。 380 | 381 | 0.4.2 2010-10-31 382 | - 本文が空の場合にエラーを表示するようにした。 383 | - エラー時の処理を改善。 384 | - |ref#cache()| で {name} のリストを取れるようにした。 385 | - コマンドラインの補完を改善。 386 | 387 | 0.4.1 2010-06-04 388 | - |ref-source-attr-get_body()| が辞書を返せるようにした。 389 | - |ref#cache()| が {gather} に |List| を受け付けるようにした。 390 | - |ref-source-attr-cache()| の引数が変わっていなかったのを修正。 391 | - |ref#detect()| に関するいくつかのバグを修正。 392 | - 履歴を戻った時 |filetype-ref-{source-name}| が変更されないバグを修 393 | 正。 394 | 395 | 0.4.0 2010-05-31 396 | - ファイルタイプの規則を変更。 397 | - |filetype-ref-{source-name}| を参照。 398 | - 連続で同じページを開いた場合履歴に追加しないようにした。 399 | - |ref-source-attr-cache()| を追加。 400 | - |ref#cache()| の {gather} を省略できるようにした。 401 | - |ref#cache()| に {update} 引数を追加。 402 | - |:Ref-option| に -updatecache を追加。 403 | 404 | 0.3.3 2010-05-23 405 | - |ref#to_list()| を追加。 406 | - |ref#get_text_on_cursor()| の範囲が間違っていたのを修正。 407 | - |ref#open()| がオプションを受け取れるようにした。 408 | - |ref#jump()| がオプションを受け取れるようにした。 409 | - |:Ref-option| に -noenter を追加。 410 | - |g:ref_noenter| と |b:ref_noenter| を追加。 411 | 412 | 0.3.2 2010-05-07 413 | - |ref#uniq()| を追加。 414 | - |ref#get_text_on_cursor()| を追加。 415 | - |ref-source-attr-normalize()| を追加。 416 | - |:Ref| にオプションを指定できるようにした。(|:Ref-option|) 417 | 418 | 0.3.1 2010-04-22 419 | - |g:ref_detect_filetype| が特殊なキー _ を受け付けるようにした。 420 | - |g:ref_detect_filetype| が |Funcref| を受け付けるようにした。 421 | 422 | 0.3.0 2010-04-18 423 | - |ref-sources| の仕様を変更。 424 | - 以前のバージョンとの互換性はありません。 425 | - |ref#system()| の戻り値を変更。 426 | - get_keyword() はリストを返すことでソースを指定できるようにした。 427 | - キャッシュで使用する名前により多くの種類の文字を許容するようにした。 428 | - 検出機能を本体に結合。 429 | - detect ソースを削除。 430 | 431 | 0.2.0 2010-01-28 432 | - |ref#cache()| の {gather} に渡す関数が、引数として {name} を受け取る 433 | ように変更。 434 | - 選択テキストの取得方法を改善。 435 | 436 | 0.1.2 2010-01-22 437 | - |g:ref_use_vimproc| = 0 の時、MS Windows 上で動作しないバグを修正。 438 | 439 | 0.1.1 2010-01-20 440 | - |ref#system()| を追加。 441 | 442 | 0.1.0 2009-12-22 443 | - |ref#cache()| を追加。 444 | 445 | 0.0.2 2009-08-20 446 | - g:ref_split の名前と意味を変更。 447 | - g:ref_open へ変更。 448 | - ソースの補完時に同じ項目が出ることがあるバグを修正。 449 | 450 | 0.0.1 2009-08-09 451 | - 初版。 452 | 453 | 454 | ============================================================================== 455 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 456 | -------------------------------------------------------------------------------- /doc/ref.txt: -------------------------------------------------------------------------------- 1 | *ref.txt* Integrated reference viewer. 2 | 3 | Version: 0.4.3 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *ref-contents* 10 | 11 | INTRODUCTION |ref-introduction| 12 | REFERENCE VIEWER |ref-viewer| 13 | INTERFACE |ref-interface| 14 | FUNCTIONS |ref-functions| 15 | COMMANDS |ref-commands| 16 | KEY MAPPINGS |ref-key-mappings| 17 | CUSTOMIZING |ref-customizing| 18 | SOURCES |ref-sources| 19 | AUTOLOAD |ref-autoload| 20 | CHANGELOG |ref-changelog| 21 | 22 | 23 | ============================================================================== 24 | INTRODUCTION *ref-introduction* 25 | 26 | *ref.vim* is a Vim plugin to view the reference. This plugin can be separated 27 | to core of viewer and sources of reference. As a result, various references 28 | can be viewed by the same interface. 29 | 30 | Following sources are included in this plugin: 31 | - clojure (|ref-clojure.txt|) 32 | - erlang (|ref-erlang.txt|) 33 | - man (|ref-man.txt|) 34 | - perldoc (|ref-perldoc.txt|) 35 | - phpmanual (|ref-phpmanual.txt|) 36 | - pydoc (|ref-pydoc.txt|) 37 | - redis 38 | - refe (|ref-refe.txt|) 39 | - rfc 40 | - webdict (|ref-webdict.txt|) 41 | 42 | External sources list: 43 | https://github.com/thinca/vim-ref/wiki/sources 44 | 45 | Other interfaces are also available: 46 | - ku-ref (|ku-ref.txt|) 47 | - unite-ref (|unite-ref.txt|) 48 | 49 | Requirements: 50 | - Vim 7.2 or later 51 | 52 | Latest version: 53 | https://github.com/thinca/vim-ref 54 | 55 | 56 | 57 | ============================================================================== 58 | REFERENCE VIEWER *ref-viewer* 59 | 60 | |ref-viewer| is mere a buffer to view the reference. This is opened by |:Ref| 61 | command or |(ref-keyword)| key sequence like |:help|. If |ref-viewer| 62 | is already opened in current tab page, it is used again. 63 | Each |ref-viewer| have a history of viewed pages, you can return at any time. 64 | 65 | 66 | 67 | ============================================================================== 68 | INTERFACE *ref-interface* 69 | 70 | ------------------------------------------------------------------------------ 71 | FUNCTIONS *ref-functions* 72 | 73 | ref#open({source-name}, {query} [, {options}]) *ref#open()* 74 | A function version of |:Ref|. {options} is specified 75 | by a dictionary. 76 | 77 | ref#jump([{mode} [, {source-name}]] [, {options}]) *ref#jump()* 78 | Open the source with looking for query from the cursor 79 | position. When the {source-name} is omitted, 80 | |ref#detect()| is used. 81 | How query is acquired is specified by {mode}. 82 | Any of the following is specified. 83 | 84 | "normal" The query is acquired from the cursor 85 | position. This is default. 86 | "visual" The query is acquired from the string 87 | within the range selected immediately 88 | before. 89 | "line"/"char"/"block" 90 | This function can be used for 91 | 'operatorfunc'. 92 | 93 | When the dictionary is passed to the argument, it is 94 | treated as much as {options} of ref#open(). 95 | 96 | ref#register({source}) *ref#register()* 97 | ref#register({list-of-sources}) 98 | Register a new source. See |ref-sources| about 99 | {source}. 100 | 101 | ref#available_source_names() *ref#available_source_names()* 102 | Returns the |List| of names of sources already 103 | registered. 104 | 105 | ref#available_sources([{source-name}]) *ref#available_sources()* 106 | Returns the view of source that has already registered 107 | as a |Dictionary|. If the {source-name} of a source 108 | is specified and it is registered, it is returned, 109 | otherwise 0 is returned. If you changed the source, 110 | it influences internally. 111 | 112 | ref#detect() *ref#detect()* 113 | Detect the appropriate source on current buffer. This 114 | function uses |g:ref_detect_filetype|. Return empty 115 | string when detection failed. 116 | 117 | ref#register_detection({ft}, {source} [, {way}]) *ref#register_detection()* 118 | Register the entry to |g:ref_detect_filetype|. If 119 | the entry already exists, this works as follows by the 120 | value of {way}. 121 | "ignore" Not register. 122 | "overwrite" Overwrite. 123 | "prepend" When it is not a list, it makes to the 124 | list, and it adds it to the head. 125 | "append" When it is not a list, it makes to the 126 | list, and it adds it to the tail. 127 | The default is "ignore". 128 | 129 | 130 | The following functions are used by |ref-sources| mainly. 131 | 132 | ref#cache({source-name} [, {name} [, {gather} [, {update}]]]) *ref#cache()* 133 | It is a function to cache a time-consuming list to 134 | acquisition. The list is cached in the automatic 135 | operation in using this function. The cached list is 136 | returned at the following. 137 | {source-name} is a name of source. 138 | {name} is a arbitrary name for identification. This 139 | is not a empty string. 140 | When {name} is omitted, the list of {name} that has 141 | been already cached is returned. 142 | {gather} is one of the following. 143 | 1. A |Funcref| for getting the list. 144 | 2. A evaluatable string by |eval()|. (Note scope.) 145 | 3. A dictionary with dictionary function "call" in 146 | member. 147 | 4. A |List| for caching. 148 | A function of 1 and 3 is received {name} as argument. 149 | a:name can be referred by 2. 150 | In any case, it is necessary to return the list. 151 | When {gather} is omitted, the cached list is acquired. 152 | When cash doesn't exist, 0 is returned. 153 | When numbers except 0 are given to {update}, cash is 154 | updated. 155 | 156 | ref#rmcache([{source-name} [, {name}]]) *ref#rmcache()* 157 | Remove the cache created by |ref#cache()|. If {name} 158 | is omitted, remove the all of cache of {source-name}. 159 | If {source-name} is omitted, remove the all of cache. 160 | 161 | ref#system({expr} [, {input}]) *ref#system()* 162 | Like |system()|, but {expr} takes a |List|. Each 163 | items are processed by |shellescape()|. 164 | If {expr} is a string, it is separated by 165 | |ref#to_list()|. 166 | In addition, this function returns a |Dictionary| that 167 | has following entries. 168 | result: Return code. 169 | stdout: Standard output. 170 | stderr: Standard error. 171 | This function uses |vimproc#system()| instead of 172 | |system()| if |g:ref_use_vimproc| is true. 173 | vimproc: https://github.com/Shougo/vimproc 174 | 175 | ref#to_list({expr}, ...) *ref#to_list()* 176 | Convert {expr} into a |List|. 177 | If {expr} is a |List|, return {expr}. 178 | If {expr} is a string, split by |split()|. 179 | Otherwise, return a |List| which contains {expr}. 180 | When two or more arguments are passed, the one that 181 | all the arguments were converted is joined and 182 | returned. 183 | 184 | ref#uniq({list}) *ref#uniq()* 185 | Return new list that omitted repeated items. The 186 | result is sorted by |sort()|. 187 | 188 | ref#get_text_on_cursor({pattern}) *ref#get_text_on_cursor()* 189 | When the text under the cursor is a specified pattern, 190 | the text is acquired. The empty string is returned 191 | when not matching it to the pattern. 192 | 193 | 194 | ------------------------------------------------------------------------------ 195 | COMMANDS *ref-commands* 196 | 197 | :Ref [{options}] {source-name} [{query}] *:Ref* 198 | Open the |ref-viewer|. [query] is used by 199 | |ref-sources| as query. 200 | This can specify the option before {source-name}. 201 | Option is start with "-". The following options can 202 | be used. 203 | *:Ref-option* 204 | -open={command} Overwrite the |g:ref_open|. 205 | -new Open the viewer forcely and newly. 206 | -nocache Don't use cache. 207 | -noenter Don't enter the |rev-viewer|. 208 | -updatecache Update cache. 209 | 210 | :RefHistory *:RefHistory* 211 | List the history in |ref-viewer|. It is possible to 212 | jump there by inputting the number. 213 | This command is available only in the |ref-viewer|. 214 | 215 | 216 | ------------------------------------------------------------------------------ 217 | KEY MAPPINGS *ref-key-mappings* 218 | 219 | (ref-keyword) *(ref-keyword)* 220 | Jump to reference of the keyword under the cursor. 221 | See also |ref-source-attr-get_keyword()|. 222 | |ref#detect()| is used for the detection of the 223 | source. When the source that should be used is not 224 | found, the same behavior as |K|. 225 | 226 | 227 | 228 | The following key mappings are available in |ref-viewer|. 229 | 230 | [count] (ref-forward) *(ref-forward)* 231 | [count] (ref-back) *(ref-back)* 232 | Follow the history in |ref-viewer|. 233 | 234 | 235 | *g:ref_no_default_key_mappings* 236 | The following key mappings will be also available unless 237 | g:ref_no_default_key_mappings is defined: 238 | 239 | (In global) 240 | {lhs} {rhs} 241 | -------- ----------------------------- 242 | K (ref-keyword) 243 | 244 | (In |ref-viewer|) 245 | {lhs} {rhs} 246 | -------- ----------------------------- 247 | (ref-keyword) 248 | <2-LeftMouse> (ref-keyword) 249 | (ref-keyword) 250 | (ref-back) 251 | (ref-back) 252 | (ref-forward) 253 | 254 | 255 | 256 | ============================================================================== 257 | CUSTOMIZING *ref-customizing* 258 | 259 | FileType ref *filetype-ref* 260 | This event occurs after the initialization of the |ref-viewer|. 261 | Example: > 262 | autocmd FileType ref call s:initialize_ref_viewer() 263 | function! s:initialize_ref_viewer() 264 | nmap b (ref-back) 265 | nmap f (ref-forward) 266 | nnoremap q c 267 | setlocal nonumber 268 | " ... and more settings ... 269 | endfunction 270 | < 271 | 272 | FileType ref-{source-name} *filetype-ref-{source-name}* 273 | The filetype set actually finally becomes ref-{source-name} though 274 | |filetype-ref| is generated when |ref-viewer| is opened first. 275 | This event is generated every time the source changes. 276 | 277 | g:ref_open *g:ref_open* 278 | The Assistance command used when |ref-viewer| is opened. For example, 279 | |:vsplit|, |:tabnew|, and so on. The default value is "split". 280 | 281 | g:ref_cache_dir *g:ref_cache_dir* 282 | The directory for caching. Some sources uses this via |ref#cache()|. 283 | The default value is "~/.cache/vim-ref". ~ means home directory. 284 | 285 | g:ref_use_vimproc *g:ref_use_vimproc* 286 | When true, |ref#system()| use |vimproc|. When |vimproc#system()| 287 | exists, the default value is true, and otherwise false. 288 | 289 | g:ref_detect_filetype *g:ref_detect_filetype* 290 | Specifies the |Dictionary| to detect the using source from |filetype|. 291 | This is used by |ref#detect()|. The key is a filetype, and the value 292 | is a source name, a list of sources, or a |Funcref|. 293 | If the value is a list of sources, the source that the body was found 294 | at first is used. The list is nestable. 295 | If the value is a |Funcref|, it take a filetype as argument and return 296 | a source name, a list of source names, or a |Funcref|. If it can not 297 | detect, return empty string. 298 | If _ key exists, it is used when the filetype was not registered. 299 | Some sources register the appropriate entry on loaded. 300 | 301 | g:ref_noenter *g:ref_noenter* 302 | b:ref_noenter *b:ref_noenter* 303 | Always enable the -noenter of |:Ref-option|. 304 | 305 | 306 | 307 | ============================================================================== 308 | SOURCES *ref-sources* 309 | 310 | A source is a |Dictionary|. A source have the following attributes. A 311 | function is a |Dictionary-function|. The {query} is a string passed by |:Ref| 312 | command. 313 | 314 | name *ref-source-attr-name* 315 | Required. The name for this source. 316 | 317 | get_body({query}) *ref-source-attr-get_body()* 318 | Required. Return the body of reference by List of 319 | line break delimitation or String. 320 | A dictionary that has the following entries also can 321 | be returned. 322 | body: Required. The body of reference. 323 | query: Optional. The normalized {query}. 324 | Throws an exception with an error message if body is 325 | not found. 326 | 327 | available() *ref-source-attr-available()* 328 | Optional. Return true if this source is available. 329 | Always available when this is omitted. 330 | 331 | opened({query}) *ref-source-attr-opened()* 332 | Optional. When every reference page is opened, this 333 | function is called. You can edit the |ref-viewer| 334 | buffer in this timing to initialization. 335 | 336 | get_keyword() *ref-source-attr-get_keyword()* 337 | Optional. Pick up the keyword from current cursor 338 | position. If omitted, "expand('')" is used. 339 | You can move the cursor because cursor position are 340 | restored. 341 | The keyword is treated as {query}. 342 | The list of the form of [{source-name}, {keyword}] can 343 | be returned. In this case, the keyword is opened by 344 | the specified source. 345 | Throws an exception with an error message if keyword 346 | is not found. 347 | 348 | complete({query}) *ref-source-attr-complete()* 349 | Optional. Return the completion list for command-line. 350 | 351 | normalize({query}) *ref-source-attr-normalize()* 352 | Optional. Normalize the {query}. It is used for 353 | buffer name, and passed to get_body() and opened(). 354 | 355 | leave() *ref-source-attr-leave()* 356 | Optional. This function is called when move to other 357 | source page. 358 | 359 | cache({name} [, {gather} [, {update}]]) *ref-source-attr-cache()* 360 | Defined by core. This is a shortcut to |ref#cache()|. 361 | 362 | ------------------------------------------------------------------------------ 363 | AUTOLOAD *ref-autoload* 364 | 365 | A auto load function ref#{source-name}#define() is called automatically when 366 | autoload/ref.vim is loaded, and the return value is registered as source. 367 | 368 | 369 | 370 | ============================================================================== 371 | CHANGELOG *ref-changelog* 372 | 373 | x.x.x xxxx-xx-xx 374 | - |ref#register()| can accept a list of sources. 375 | - Fixed for Vim 7.3.162 . 376 | - Fixed |ref#rmcache()|. 377 | 378 | 0.4.3 2011-01-20 379 | - Added |ref#rmcache()|. 380 | - |g:ref_detect_filetype| accepts a list of sources. 381 | - A function of |g:ref_detect_filetype| can return a |Funcref|. 382 | - Improved |ref#register_detection()|. 383 | - |ref-source-attr-available()| became omitable. 384 | - Fixed the bug to which {name} including "/" can not be taken out by 385 | |ref#cache()|. 386 | - Fixed a bug when a list including empty string is passed to 387 | |ref#uniq()|. 388 | 389 | 0.4.2 2010-10-31 390 | - Display an error when a body is empty. 391 | - Improved the handling of an error. 392 | - The list of {name} was able to be taken by |ref#cache()|. 393 | - Improved the command line completion. 394 | 395 | 0.4.1 2010-06-04 396 | - |ref-source-attr-get_body()| can return a |Dictionary|. 397 | - |ref#cache()| accepts a |List| as {gather}. 398 | - Fixed the arguments of |ref-source-attr-cache()|. 399 | - Fixed the some bugs for |ref#detect()|. 400 | - Fixed a bug that |filetype-ref-{source-name}| is not changed when go 401 | back the history. 402 | 403 | 0.4.0 2010-05-31 404 | - Changed filetype convention. 405 | - See |filetype-ref-{source-name}|. 406 | - Do not add to the history when a continuous, same page was opened. 407 | - Added |ref-source-attr-cache()|. 408 | - {gather} of |ref#cache()| was made omissible. 409 | - Added the {update} argument to |ref#cache()|. 410 | - Added the -updatecache to |:Ref-option|. 411 | 412 | 0.3.3 2010-05-23 413 | - Added |ref#to_list()|. 414 | - Fixed a bug that the range of |ref#get_text_on_cursor()| was wrong. 415 | - |ref#open()| can take options. 416 | - |ref#jump()| can take options. 417 | - Added the -noenter to |:Ref-option|. 418 | - Added the |g:ref_noenter| and the |b:ref_noenter|. 419 | 420 | 0.3.2 2010-05-07 421 | - Added |ref#uniq()|. 422 | - Added |ref#get_text_on_cursor()|. 423 | - Added |ref-source-attr-normalize()|. 424 | - The option is able to be specified for Ref. (|:Ref-option|) 425 | 426 | 0.3.1 2010-04-22 427 | - |g:ref_detect_filetype| accepts a special key _. 428 | - |g:ref_detect_filetype| accepts |Funcref|. 429 | 430 | 0.3.0 2010-04-18 431 | - Changed the specification of |ref-sources|. 432 | - It has no compatibility with any previous versions. 433 | - Changed returns value of |ref#system()|. 434 | - get_keyword() can specify the source with list. 435 | - The name for cache allows a lot of kinds of characters. 436 | - The detection feature was merged to core. 437 | - Removed the detect source. 438 | 439 | 0.2.0 2010-01-28 440 | - A function of {gather} in |ref#cache()| takes {name} as an argument. 441 | - Improved the way to get selected text. 442 | 443 | 0.1.2 2010-01-22 444 | - Fixed a bug that doesn't work on MS Windows when |g:ref_use_vimproc| 445 | = 0. 446 | 447 | 0.1.1 2010-01-20 448 | - Added |ref#system()|. 449 | 450 | 0.1.0 2009-12-22 451 | - Added |ref#cache()|. 452 | 453 | 0.0.2 2009-08-20 454 | - Changed the name and the means of g:ref_split. 455 | - Changed to g:ref_open. 456 | - Fixed the bug that same items appears in completion of source. 457 | 458 | 0.0.1 2009-08-09 459 | - Initial version. 460 | 461 | 462 | ============================================================================== 463 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 464 | -------------------------------------------------------------------------------- /doc/unite-ref.txt: -------------------------------------------------------------------------------- 1 | *unite-ref.txt* ref.vim support for unite.vim. 2 | 3 | Version: 0.1.1 4 | Author : thinca 5 | License: Creative Commons Attribution 2.1 Japan License 6 | 7 | 8 | ============================================================================== 9 | CONTENTS *unite-ref-contents* 10 | 11 | INTRODUCTION |unite-ref-introduction| 12 | SOURCES |unite-ref-sources| 13 | FOR REF SOURCES |unite-ref-for-ref-sources| 14 | CHANGELOG |unite-ref-changelog| 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *unite-ref-introduction* 19 | 20 | *unite-ref* is a source and a kind for |unite| to use |ref.vim|. 21 | 22 | Requirements: 23 | - Vim 7.2 or later 24 | - |unite| 1.0 or later 25 | - |ref.vim| 0.4.2 or later 26 | 27 | 28 | 29 | ============================================================================== 30 | SOURCES *unite-ref-sources* 31 | 32 | This defines some sources of unite corresponding to some sources of ref that 33 | can be used. 34 | The name of a source of unite becomes like "ref/{source-name-of-ref}". 35 | 36 | The source of unite uses |ref-source-attr-complete()| for candidates. 37 | So, the source without |ref-source-attr-complete()| can not be used. 38 | 39 | 40 | 41 | ============================================================================== 42 | FOR REF SOURCES *unite-ref-for-ref-sources* 43 | 44 | If a source of ref has an attribute named "unite" and it is a |Dictionary|, it 45 | is extended to a source of unite. As a result, the attribute of the source of 46 | unite can be overwritten. 47 | If "unite" attribute exists, the unite source has "source__original" 48 | attribute. This is useful to change a bit the default behavior. 49 | 50 | > 51 | function! s:source.unite.gather_candidates(args, context) 52 | let res = self.source__original.gather_candidates(a:args, a:context) 53 | " Do something ... 54 | return res 55 | endfunction 56 | < 57 | 58 | 59 | ============================================================================== 60 | CHANGELOG *unite-ref-changelog* 61 | 62 | 0.1.1 2011-02-26 63 | - Updated for latest version of |unite|. 64 | 65 | 0.1.0 2010-11-22 66 | - Initial version. 67 | 68 | 69 | ============================================================================== 70 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 71 | -------------------------------------------------------------------------------- /plugin/ref.vim: -------------------------------------------------------------------------------- 1 | " Integrated reference viewer. 2 | " Version: 0.4.3 3 | " Author : thinca 4 | " License: Creative Commons Attribution 2.1 Japan License 5 | " 6 | 7 | if exists('g:loaded_ref') 8 | finish 9 | endif 10 | let g:loaded_ref = 1 11 | 12 | let s:save_cpo = &cpo 13 | set cpo&vim 14 | 15 | 16 | command! -nargs=+ -complete=customlist,ref#complete Ref call ref#ref() 17 | 18 | nnoremap (ref-keyword) :call ref#K('normal') 19 | xnoremap (ref-keyword) :call ref#K('visual') 20 | 21 | if !exists('g:ref_no_default_key_mappings') || !g:ref_no_default_key_mappings 22 | silent! nmap K (ref-keyword) 23 | silent! xmap K (ref-keyword) 24 | endif 25 | 26 | 27 | 28 | let &cpo = s:save_cpo 29 | unlet s:save_cpo 30 | --------------------------------------------------------------------------------