X-Git-Url: http://nitlanguage.org diff --git a/misc/vim/plugin/nit.vim b/misc/vim/plugin/nit.vim index 86d5e45..c810664 100644 --- a/misc/vim/plugin/nit.vim +++ b/misc/vim/plugin/nit.vim @@ -46,14 +46,14 @@ function NitComplete() " This gives us better results for Nit set noignorecase - set completeopt=longest,menuone,preview + set completeopt=longest,menuone " Do not predict small 3 letters keywords (or their prefix), they slow down " prediction and some also require double-enter on end of line. let g:acp_behaviorKeywordIgnores = ['new', 'var', 'in', 'do', 'els', 'end', 'ret', 'for', 'fun'] " Use nitls to compute all interesting files from the current directory and the standard library - for file in split(system('nitls -M standard .', '\n')) + for file in split(system('nitls -M core .', '\n')) silent let &complete = &complete . ',s' . file silent set complete? endfor @@ -358,12 +358,13 @@ endfun " Call `git grep` on the word under the cursor " -" Shows declarations first, then all matches, in the preview window. +" In the preview window, list introductions, declarations and then all matches. fun NitGitGrep() let word = expand("") let out = tempname() - execute 'silent !(git grep "\\(module\\|class\\|universal\\|interface\\|var\\|fun\\) '.word.'";'. - \'echo; git grep '.word.') > '.out + execute 'silent !(git grep -n -e "\<\\(module\\|class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" --and --not -e redef -- ''*.nit'';'. + \'git grep -n "redef \<\\(class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" -- ''*.nit'';'. + \'echo; git grep -n -e "\<'.word.'\>" --and --not -e "\<\\(module\\|class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" -- ''*.nit'') > '.out " Open the preview window on a temp file execute "silent pedit " . out @@ -382,8 +383,23 @@ fun NitGitGrep() redraw! endfun -" Activate the omnifunc on Nit files -autocmd FileType nit set omnifunc=NitOmnifunc +" Call `nit` on the current file +fun NitExecute() + let path = expand('%') + + if &modified + let path = tempname() . '.nit' + execute '%write '. path + endif + + execute '!nit "' . path . '"' +endfun +command NitExecute call NitExecute() + +if !exists("g:nit_disable_omnifunc") || !g:nit_disable_omnifunc + " Activate the omnifunc on Nit files + autocmd FileType nit set omnifunc=NitOmnifunc +endif " Define the user command Nitdoc for ease of use command -nargs=* Nitdoc call Nitdoc("")