-
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?
Conversation
This adds the :MerlinSearchType command to query for a value with a matching type. It works exactly like the previous :MerlinSearch, the search results are shown in the completion menu.
':MerlinSearch' switches between polarity search and search by type depending on the first character of the query, like is done in the emacs plugin. Documentation about the three search functions is added.
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.
Thanks a lot!
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.
Thanks @Julow !
for prop in entries: | ||
vim.command("let tmp = {'word':'%s','menu':'%s','info':'%s','kind':'%s'}" % | ||
(prep(prop['name']),prep(prop['desc']),prep_nl(prop['info']),prep(prop['kind'][:1]))) | ||
vim.command("let tmp = " + vim_record({ |
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
and prep_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 the prep
and prep_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:
let g:merlin_completion_with_doc = 1
set completeopt+=popup
" 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 |
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.
@xvw this detection is also made on Merlin side isn't it ?
Maybe we could have a simpler interface in both emacs and vim:
- Keep the existing PolaritySearch
- Add a new SearchByType or Search, that does indeed also support the polarity search syntax.
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.
Yes, in Emacs I've moved the original search
behaviour into a search-by-polarity
command and then the search
command relies on the merlin search-by-type
command (which classifies the query)
Restores the previous behavior.
This adds the
:MerlinSearchType
command to query for a value with a matching type. It works like the previous:MerlinSearch
but uses the new search feature added in #1828, the search results are shown in the completion menu.:MerlinSearch
switches between polarity search and search by type depending on the first character of the query, like is done in the emacs plugin.Documentation about the three search functions is added.