diff --git a/vim/merlin/autoload/merlin.vim b/vim/merlin/autoload/merlin.vim index 67f5c03592..caa3959331 100644 --- a/vim/merlin/autoload/merlin.vim +++ b/vim/merlin/autoload/merlin.vim @@ -301,6 +301,16 @@ function! merlin#SearchByType(debug,query) endif endfunction +" Do a polarity search or a search by type depending on the first character of +" the query. +function! merlin#Search(debug, query) + if a:query =~ "^[-+]" + call merlin#PolaritySearch(a:debug, a:query) + else + call merlin#SearchByType(a:debug, a:query) + endif +endfunction + function! s:StopHighlight() if exists('w:enclosing_zone') && w:enclosing_zone != -1 call matchdelete(w:enclosing_zone) @@ -821,11 +831,10 @@ function! merlin#Register() command! -buffer -nargs=0 MerlinGotoDotMerlin call merlin#GotoDotMerlin() command! -buffer -nargs=0 MerlinEchoDotMerlin call merlin#EchoDotMerlin() - """ Polarity search - command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearch call merlin#PolaritySearch(0,) - - """ Search by type + """ Search + command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearchPolarity call merlin#PolaritySearch(0,) command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearchType call merlin#SearchByType(0,) + command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearch call merlin#Search(0,) """ debug -------------------------------------------------------------------- command! -buffer -nargs=0 MerlinDebugLastCommands MerlinPy merlin.vim_last_commands() diff --git a/vim/merlin/doc/merlin.txt b/vim/merlin/doc/merlin.txt index b1c571d5d7..3d23b100c4 100644 --- a/vim/merlin/doc/merlin.txt +++ b/vim/merlin/doc/merlin.txt @@ -158,6 +158,44 @@ Act either as *:py* or *:py3* depending on the version of python is used by the vim plugin. This is only useful if you want to write custom merlin extensions. +:MerlinSearch *:MerlinSearch* + +Act either as :MerlinSearchPolarity or :MerlinSearchType depending on the first +character of the query. If the query starts with '-' or '+', then +:MerlinSearchPolarity is used, otherwise, :MerlinSearchType is used. + +> + :MerlinSearch -int +string + :MerlinSearch int -> string +< + +:MerlinSearchPolarity *:MerlinSearchPolarity* + +Search for values in the current scope that have a type matching the query. +The results are displayed in a completion menu. + +The query language is simply a list of path identifiers prefixed by `+` or `-`, +e.g. `-int`, `-int +string`, `-Hashtbl.t +int`. + +`-` is interpreted as "consuming" and `+` as "producing": `-int +string` looks +for functions consuming an `int` and producing a `string`. + +> + :MerlinSearchPolarity -int +string +< + +:MerlinSearchType *:MerlinSearchType* + +Works similarly to :MerlinSearchPolarity but uses a different query language. +The results are displayed in a completion menu. + +The query language is a list of type constructors separated by '->'. +Type parameters and functions are allowed: `('a -> bool) -> 'a list -> bool`. + +> + :MerlinSearchType int -> string +< + ============================================================================== OPTIONS *merlin-options*