-
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
Configurable Unix system command #1585
Conversation
b7890c0
to
f6ad8d8
Compare
@rgrinberg , can you specify the |
Note that it's not about avoiding fork/exec (although i'll take it when it's possible). It's for:
|
Btw, this fix isn't bringing us to an ideal long term situation. We don't want merlin imposing on lsp on how to lunch processes, nor do we want lsp imposing on merlin in the same way. Something closer to what we want would be an API for running preprocessors. E.g:
|
We could make it customizable in https://github.com/ocaml/merlin/blob/master/src/utils/lib_config.mli It's not the most elegant solution but it might provide the flexibility we need until a more involved refactor of "merlin-as-a-lib" is done. |
@rgrinberg , I'm not sure that I follow. If we create the API with following function:
then how will we handle cancelation? I assume that returned int stands for exit code and PID is not exposed. |
The implementation of that function on the lsp side would register the spawned pid somewhere and then kill it once cancellation is called. By the way, the error code should be a bit more accurate:
|
6a4e78d
to
a8c8e9c
Compare
@voodoos , @rgrinberg |
merlin_system_command
Looks good to me ! |
Ok, I'll just rebase it on current main branch and provide a changelog :-) |
👍 also we will wait for @rgrinberg double-check before merging :-) |
This interface is problematic because it relies on the shell to run the pp/ppx commands. We want the drop the dependency on the shell whenever possible. Personally, I would prefer an API that is even higher level. For example:
Also I find the reliance on error code to signal errors to be a poor choice as well. I suppose it's good enough to solve the immediate problem, but I wouldn't want to be stuck with this interface. Is there a reason why we're in a rush to fix this issue? |
The primary reason for prioritizing this issue is the potential for reducing maintenance costs on both projects. By upstreaming the merlin fork, we can simplify the overall development process and minimize duplicated efforts. Moreover, this issue has been identified as a significant factor blocking adoption for some users in the OCaml community. The proposed Pull Request offers a quick and efficient way to upstream this patch. This solution is not the final version. We intend to further refine the integration between ocaml-lsp and merlin once the initial version has been upstreamed. |
fa6cdd6
to
9c5676b
Compare
@rgrinberg, about the return type: Adding a We should at some point (and probably sooner than later) add cancellation support to the |
Sure, I was talking about the ideal API that we should be looking towards. Of course merlin should handle cancellation in a smarter way than just continuing with the unpreprocessed ast. |
@3Rafal could you add a changelog entry ? I will try to review by the end of the week. |
9c5676b
to
2f23f0d
Compare
@voodoos , done. :) |
I had a go at the latest changes we discussed with Rafal. This lead me to (re)-discover the source of our difficulties: in configuration, a ppx and its arguments are passed in one block to Merlin which makes it hard to distinguished the program from it's arguments. Additionally, when the That means that unless we decide to parse these and unquote them (which is something we really don't want to do) there is no way for us to use sane quotation functions like I documented the hook exposed in merlin/src/utils/lib_config.mli Lines 22 to 54 in 5d09af9
@rgrinberg We should at some point add a new directive to the configuration protocol to finally pass ppx configuration in a clean way when using Dune. |
This is meant for tools using Merlin as a lib to customize the way proprocessors and ppxes are spawed. Provided implementations must respect a precise set of constraints. Author: Rafal Gwozdzinski <[email protected]> Co-authored-by: Ulysse Gérard <[email protected]>
5d09af9
to
8446560
Compare
from 3Rafal/unix-merlin-system-command
CHANGES: Fri May 26 15:23:42 CEST 2023 + merlin binary - Allow monadic IO in dot protocol (ocaml/merlin#1581) - Add a `scope` option to the `occurrences` command in preparation for the upcoming `project-wide-occurrences` feature (ocaml/merlin#1596) - Construct bool-typed holes as `false` instead of `true` in the `construct` command, for consistency (ocaml/merlin#1599). - Add a hook to configure system command for spawning ppxes when Merlin is used as a library. (ocaml/merlin#1585) - Implement an all-or-nothing cache for the PPX phase (ocaml/merlin#1584) - Cleanup functors caches when backtracking, to avoid memory leaks (ocaml/merlin#1609, fixes ocaml/merlin#1529 and ocaml-lsp#1032) - Fix `construct` results ordering for sum types sand poly variants (ocaml/merlin#1603) - Fix object method completion not working (ocaml/merlin#1606, fixes ocaml/merlin#1575) - Improve context detection for package types (ocaml/merlin#1608, fixes ocaml/merlin#1607) - Fix incorrect locations for string literals (ocaml/merlin#1574) - Fixed an issue that caused `errors` to erroneously alert about missing `cmi` files (ocaml/merlin#1577) - Prevent destruct from crashing on closed variant types (ocaml/merlin#1602, fixes ocaml/merlin#1601) - Improve longident parsing (ocaml/merlin#1612, fixes ocaml/merlin#945) + editor modes - emacs: call the user's configured completion UI in `merlin-construct` (ocaml/merlin#1598) + test suite - Add missing dependency to a test using ppxlib (ocaml/merlin#1583) - Add tests for the new PPX phase cache (ocaml/merlin#1584) - Add and update tests for `construct` ordering (ocaml/merlin#1603)
CHANGES: Fri May 26 15:23:42 CEST 2023 + merlin binary - Allow monadic IO in dot protocol (ocaml/merlin#1581) - Add a `scope` option to the `occurrences` command in preparation for the upcoming `project-wide-occurrences` feature (ocaml/merlin#1596) - Construct bool-typed holes as `false` instead of `true` in the `construct` command, for consistency (ocaml/merlin#1599). - Add a hook to configure system command for spawning ppxes when Merlin is used as a library. (ocaml/merlin#1585) - Implement an all-or-nothing cache for the PPX phase (ocaml/merlin#1584) - Cleanup functors caches when backtracking, to avoid memory leaks (ocaml/merlin#1609, fixes ocaml/merlin#1529 and ocaml-lsp#1032) - Fix `construct` results ordering for sum types sand poly variants (ocaml/merlin#1603) - Fix object method completion not working (ocaml/merlin#1606, fixes ocaml/merlin#1575) - Improve context detection for package types (ocaml/merlin#1608, fixes ocaml/merlin#1607) - Fix incorrect locations for string literals (ocaml/merlin#1574) - Fixed an issue that caused `errors` to erroneously alert about missing `cmi` files (ocaml/merlin#1577) - Prevent destruct from crashing on closed variant types (ocaml/merlin#1602, fixes ocaml/merlin#1601) - Improve longident parsing (ocaml/merlin#1612, fixes ocaml/merlin#945) + editor modes - emacs: call the user's configured completion UI in `merlin-construct` (ocaml/merlin#1598) + test suite - Add missing dependency to a test using ppxlib (ocaml/merlin#1583) - Add tests for the new PPX phase cache (ocaml/merlin#1584) - Add and update tests for `construct` ordering (ocaml/merlin#1603)
CHANGES: Fri May 26 15:23:42 CEST 2023 + merlin binary - Allow monadic IO in dot protocol (ocaml/merlin#1581) - Add a `scope` option to the `occurrences` command in preparation for the upcoming `project-wide-occurrences` feature (ocaml/merlin#1596) - Construct bool-typed holes as `false` instead of `true` in the `construct` command, for consistency (ocaml/merlin#1599). - Add a hook to configure system command for spawning ppxes when Merlin is used as a library. (ocaml/merlin#1585) - Implement an all-or-nothing cache for the PPX phase (ocaml/merlin#1584) - Cleanup functors caches when backtracking, to avoid memory leaks (ocaml/merlin#1609, fixes ocaml/merlin#1529 and ocaml-lsp#1032) - Fix `construct` results ordering for sum types sand poly variants (ocaml/merlin#1603) - Fix object method completion not working (ocaml/merlin#1606, fixes ocaml/merlin#1575) - Improve context detection for package types (ocaml/merlin#1608, fixes ocaml/merlin#1607) - Fix incorrect locations for string literals (ocaml/merlin#1574) - Fixed an issue that caused `errors` to erroneously alert about missing `cmi` files (ocaml/merlin#1577) - Prevent destruct from crashing on closed variant types (ocaml/merlin#1602, fixes ocaml/merlin#1601) - Improve longident parsing (ocaml/merlin#1612, fixes ocaml/merlin#945) + editor modes - emacs: call the user's configured completion UI in `merlin-construct` (ocaml/merlin#1598) + test suite - Add missing dependency to a test using ppxlib (ocaml/merlin#1583) - Add tests for the new PPX phase cache (ocaml/merlin#1584) - Add and update tests for `construct` ordering (ocaml/merlin#1603) [new release] merlin, merlin-lib and dot-merlin-reader (4.9-414) CHANGES: Fri May 26 15:23:42 CEST 2023 + merlin binary - Allow monadic IO in dot protocol (ocaml/merlin#1581) - Add a `scope` option to the `occurrences` command in preparation for the upcoming `project-wide-occurrences` feature (ocaml/merlin#1596) - Construct bool-typed holes as `false` instead of `true` in the `construct` command, for consistency (ocaml/merlin#1599). - Add a hook to configure system command for spawning ppxes when Merlin is used as a library. (ocaml/merlin#1585) - Implement an all-or-nothing cache for the PPX phase (ocaml/merlin#1584) - Cleanup functors caches when backtracking, to avoid memory leaks (ocaml/merlin#1609, fixes ocaml/merlin#1529 and ocaml-lsp#1032) - Fix `construct` results ordering for sum types sand poly variants (ocaml/merlin#1603) - Fix object method completion not working (ocaml/merlin#1606, fixes ocaml/merlin#1575) - Improve context detection for package types (ocaml/merlin#1608, fixes ocaml/merlin#1607) - Fix incorrect locations for string literals (ocaml/merlin#1574) - Fixed an issue that caused `errors` to erroneously alert about missing `cmi` files (ocaml/merlin#1577) - Prevent destruct from crashing on closed variant types (ocaml/merlin#1602, fixes ocaml/merlin#1601) - Improve longident parsing (ocaml/merlin#1612, fixes ocaml/merlin#945) + editor modes - emacs: call the user's configured completion UI in `merlin-construct` (ocaml/merlin#1598) + test suite - Add missing dependency to a test using ppxlib (ocaml/merlin#1583) - Add tests for the new PPX phase cache (ocaml/merlin#1584) - Add and update tests for `construct` ordering (ocaml/merlin#1603)
CHANGES: unreleased + merlin binary - Preview support for OCaml 5.1-alpha1. Short path is temporary disabled and inline records might not behave as expected. - Allow monadic IO in dot protocol (ocaml/merlin#1581) - Add a `scope` option to the `occurrences` command in preparation for the upcoming `project-wide-occurrences` feature (ocaml/merlin#1596) - Construct bool-typed holes as `false` instead of `true` in the `construct` command, for consistency (ocaml/merlin#1599). - Add a hook to configure system command for spawning ppxes when Merlin is used as a library. (ocaml/merlin#1585) - Implement an all-or-nothing cache for the PPX phase (ocaml/merlin#1584) - Cleanup functors caches when backtracking, to avoid memory leaks (ocaml/merlin#1609, fixes ocaml/merlin#1529 and ocaml-lsp#1032) - Fix `construct` results ordering for sum types sand poly variants (ocaml/merlin#1603) - Fix object method completion not working (ocaml/merlin#1606, fixes ocaml/merlin#1575) - Improve context detection for package types (ocaml/merlin#1608, fixes ocaml/merlin#1607) - Fix incorrect locations for string literals (ocaml/merlin#1574) - Fixed an issue that caused `errors` to erroneously alert about missing `cmi` files (ocaml/merlin#1577) - Prevent destruct from crashing on closed variant types (ocaml/merlin#1602, fixes ocaml/merlin#1601) - Improve longident parsing (ocaml/merlin#1612, fixes ocaml/merlin#945) + editor modes - emacs: call the user's configured completion UI in `merlin-construct` (ocaml/merlin#1598) + test suite - Add missing dependency to a test using ppxlib (ocaml/merlin#1583) - Add tests for the new PPX phase cache (ocaml/merlin#1584) - Add and update tests for `construct` ordering (ocaml/merlin#1603)
As described in ocaml/ocaml-lsp#1052
There was already a discussion about introducing Spawn dependency to replace
Sys.command
here: #1420