-
Notifications
You must be signed in to change notification settings - Fork 245
vim: Expose the search-by-type feature #1846
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
Conversation
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)
|
Oh, I completely forgot about this one, sorry. @Julow is it ready ? 🙂 |
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.
321c7c9 to
c742acc
Compare
|
I rebased and tested this in my own setup and it works perfectly. |
|
Thanks ! |
CHANGES:
Fri Jan 10 17:55:42 CET 2025
+ merlin binary
- Support for OCaml 5.3
- Use new 5.3 features to improve locate behavior in some cases. Merlin no
longer confuses uids from interfaces and implementations. (ocaml/merlin#1857)
- Perform less merges in the indexer (ocaml/merlin#1881)
- Add initial support for project-wide renaming: occurrences can now return
all usages of all related definitions. (ocaml/merlin#1877)
+ vim plugin
- Added support for search-by-type (ocaml/merlin#1846)
This is exposed through the existing `:MerlinSearch` command, that
switches between search-by-type and polarity search depending on the
first character of the query.
CHANGES:
Mon Jun 23 10:10:42 CEST 2024
+ merlin library
- Expose utilities to manipulate typed-holes in `Merlin_analysis.Typed_hole`
(ocaml/merlin#1888)
- `inlay-hints` fix inlay hints on function parameters (ocaml/merlin#1923)
- Handle class type in outline (ocaml/merlin#1932)
- Handle locally defined value in outline (ocaml/merlin#1936)
+ vim plugin
- Added support for search-by-type (ocaml/merlin#1846)
This is exposed through the existing `:MerlinSearch` command, that
switches between search-by-type and polarity search depending on the
first character of the query.
This adds the
:MerlinSearchTypecommand to query for a value with a matching type. It works like the previous:MerlinSearchbut uses the new search feature added in #1828, the search results are shown in the completion menu.:MerlinSearchswitches 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.