[deconstruct][vim] Add next/previous hole commands#1287
Conversation
d63b6ae to
e46afd7
Compare
trefis
left a comment
There was a problem hiding this comment.
With the changes proposed here, a call to :MerlinDestruct now entails three different queries to merlin.
Perhaps we could update the protocol in a backwards compatible way (adding a new command, or optional flags to the existing one) to only make one call?
vim/merlin/autoload/merlin.py
Outdated
| current_enclosing = -1 | ||
|
|
||
| def replace_buffer_portion(start, end, txt): | ||
| def replace_buffer_portion(start, end, txt, next_hole = False): |
There was a problem hiding this comment.
FTR. I think this is only ever called with next_hole=true
To clarify, the three commands are the following:
IMO the combination that would make most sense would be to have a flag for On my (very) small examples I don't feel any latency however. Are scenarios with multiple successive calls to destruct frequent ? |
|
The call to
I had something like that in mind yes. |
589fde4 to
c865838
Compare
|
I just rebased this PR to use the new type information from the |
c865838 to
db10e45
Compare
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
This PR add two new commands to the vim plugin :
MerlinNextHoleetMerlinPreviousHoleIt also automatically jump to the first hole when destruct is called. This should allow nice chaining with Construct.