misc/vim: make Nitdoc a command
[nit.git] / misc / vim / plugin / nit.vim
index 3cef764..9968b5e 100644 (file)
@@ -146,7 +146,7 @@ fun NitOmnifuncAddFromFile(base, matches, path)
                        call s:NitOmnifuncAddAMatch(synopsis_matches, words, name)
                elseif get(words, 3, '') =~? a:base
                        " Match in the longer doc
-                       call s:NitOmnifuncAddAMatch(synopsis_matches, words, name)
+                       call s:NitOmnifuncAddAMatch(doc_matches, words, name)
                endif
        endfor
 
@@ -266,9 +266,13 @@ fun NitOmnifunc(findstart, base)
 endfun
 
 " Show doc for the entity under the cursor in the preview window
-fun Nitdoc()
-       " Word under cursor
-       let word = expand("<cword>")
+fun Nitdoc(...)
+       if a:0 == 0 || empty(a:1)
+               " Word under cursor
+               let word = expand("<cword>")
+       else
+               let word = join(a:000, ' ')
+       endif
 
        " All possible docs (there may be more than one entity with the same name)
        let docs = []
@@ -351,4 +355,7 @@ endfun
 " Activate the omnifunc on Nit files
 autocmd FileType nit set omnifunc=NitOmnifunc
 
+" Define the user command Nitdoc for ease of use
+command -nargs=* Nitdoc call Nitdoc("<args>")
+
 let s:script_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h')