-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vim: Expose the search-by-type feature #1846
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,15 +284,33 @@ function! merlin#PolaritySearch(debug,query) | |
let s:search_result = [] | ||
MerlinPy merlin.vim_polarity_search(vim.eval("a:query"), "s:search_result") | ||
if a:debug != 1 && s:search_result != [] | ||
call feedkeys("i=merlin#PolarityComplete()\<CR>","n") | ||
call feedkeys("i=merlin#SearchComplete()\<CR>","n") | ||
endif | ||
endfunction | ||
|
||
function! merlin#PolarityComplete() | ||
function! merlin#SearchComplete() | ||
call complete(col('.'), s:search_result) | ||
return '' | ||
endfunction | ||
|
||
function! merlin#SearchByType(debug,query) | ||
let s:search_result = [] | ||
MerlinPy merlin.vim_search_by_type(vim.eval("a:query"), "s:search_result") | ||
if a:debug != 1 && s:search_result != [] | ||
call feedkeys("i=merlin#SearchComplete()\<CR>","n") | ||
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 | ||
Comment on lines
+304
to
+312
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xvw this detection is also made on Merlin side isn't it ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in Emacs I've moved the original |
||
|
||
function! s:StopHighlight() | ||
if exists('w:enclosing_zone') && w:enclosing_zone != -1 | ||
call matchdelete(w:enclosing_zone) | ||
|
@@ -813,8 +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,<q-args>) | ||
""" Search | ||
command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearchPolarity call merlin#PolaritySearch(0,<q-args>) | ||
command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearchType call merlin#SearchByType(0,<q-args>) | ||
command! -buffer -complete=customlist,merlin#ExpandTypePrefix -nargs=+ MerlinSearch call merlin#Search(0,<q-args>) | ||
|
||
""" debug -------------------------------------------------------------------- | ||
command! -buffer -nargs=0 MerlinDebugLastCommands MerlinPy merlin.vim_last_commands() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear to me that vim_record behaves similarly as the previous use of
prep
andprep_nl
. Does it "preserve newlines" ? And only for the "info" field ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there was a problem here!
I've fixed
vim_record
to properly encode newlines and added back theprep
andprep_nl
functions. I'm not sure in which cases these are useful.I've just learnt from this "info" feature and I find it awesome. I tested that completion works fine with these settings: