Skip to content
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

Make construct chaining configurable #1673

Merged
merged 12 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Unreleased

- Add `ocaml.commands.construct.recursiveCalls` setting to configure construct chaining. (#1673)

## 1.23.0

- Add `ocaml.jump` to jump to a specific target. (#1654)
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,22 @@ to `ocamllsp`.
This extension provides options in VSCode's configuration settings. You can find
the settings under `File > Preferences > Settings`.

| Name | Description | Default |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------- | ------- |
| `ocaml.sandbox` | Determines where to find the sandbox for a given project | `null` |
| `ocaml.dune.autoDetect` | Controls whether dune tasks should be automatically detected. | `true` |
| `ocaml.trace.server` | Controls the logging output of the language server. Valid settings are `off`, `messages`, or `verbose`. | `off` |
| `ocaml.useOcamlEnv` | Controls whether to use ocaml-env (if available) for opam commands from OCaml for Windows. | `true` |
| `ocaml.terminal.shell.linux` | The path of the shell that the sandbox terminal uses on Linux | `null` |
| `ocaml.terminal.shell.osx` | The path of the shell that the sandbox terminal uses on macOS | `null` |
| `ocaml.terminal.shell.windows` | The path of the shell that the sandbox terminal uses on Windows | `null` |
| `ocaml.terminal.shellArgs.linux` | The command line arguments that the sandbox terminal uses on Linux | `null` |
| `ocaml.terminal.shellArgs.osx` | The command line arguments that the sandbox terminal uses on macOS | `null` |
| `ocaml.terminal.shellArgs.windows` | The command line arguments that the sandbox terminal uses on Window | `null` |
| `ocaml.repl.path` | The path of the REPL that the extension uses | `null` |
| `ocaml.repl.args` | The REPL arguments that the extension uses | `null` |
| `ocaml.repl.useUtop` | Controls whether to use Utop for the REPL if it is installed in the current switch. | `true` |
| Name | Description | Default |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------- |
| `ocaml.sandbox` | Determines where to find the sandbox for a given project | `null` |
| `ocaml.dune.autoDetect` | Controls whether dune tasks should be automatically detected. | `true` |
| `ocaml.trace.server` | Controls the logging output of the language server. Valid settings are `off`, `messages`, or `verbose`. | `off` |
| `ocaml.useOcamlEnv` | Controls whether to use ocaml-env (if available) for opam commands from OCaml for Windows. | `true` |
| `ocaml.terminal.shell.linux` | The path of the shell that the sandbox terminal uses on Linux | `null` |
| `ocaml.terminal.shell.osx` | The path of the shell that the sandbox terminal uses on macOS | `null` |
| `ocaml.terminal.shell.windows` | The path of the shell that the sandbox terminal uses on Windows | `null` |
| `ocaml.terminal.shellArgs.linux` | The command line arguments that the sandbox terminal uses on Linux | `null` |
| `ocaml.terminal.shellArgs.osx` | The command line arguments that the sandbox terminal uses on macOS | `null` |
| `ocaml.terminal.shellArgs.windows` | The command line arguments that the sandbox terminal uses on Window | `null` |
| `ocaml.repl.path` | The path of the REPL that the extension uses | `null` |
| `ocaml.repl.args` | The REPL arguments that the extension uses | `null` |
| `ocaml.repl.useUtop` | Controls whether to use Utop for the REPL if it is installed in the current switch. | `true` |
| `ocaml.commands.construct.recursiveCalls` | When enabled, the construct command will execute again on the next hole after a value has been chosen. | `true` |

If `ocaml.terminal.shell.*` or `ocaml.terminal.shellArgs.*` is `null`, the
configured VSCode shell and shell arguments will be used instead.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@
"default": false,
"markdownDescription": "Enable/Disable syntax documentation"
},
"ocaml.commands.construct.recursiveCalls": {
"type": "boolean",
"default": true,
"markdownDescription": "When enabled, the construct command will execute again on the next hole after a value has been chosen."
},
"ocaml.dune.autoDetect": {
"type": "boolean",
"default": true,
Expand Down
31 changes: 17 additions & 14 deletions src/extension_commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -609,20 +609,23 @@ module Construct = struct
match selected_result with
| Some (value, range) -> (
let* value_inserted = insert_to_document text_editor range value in
match value_inserted with
| true -> (
let* new_range =
Holes_commands.closest_hole
(Range.start range)
text_editor
client
`Next
in
match new_range with
| Some range ->
process_construct (Range.end_ range) text_editor client instance
| None -> Promise.return ())
| false -> Promise.return ())
match Settings.(get server_constructRecursiveCalls_setting) with
| Some true | None -> (
match value_inserted with
| true -> (
let* new_range =
Holes_commands.closest_hole
(Range.start range)
text_editor
client
`Next
in
match new_range with
| Some range ->
process_construct (Range.end_ range) text_editor client instance
| None -> Promise.return ())
| false -> Promise.return ())
| Some false -> Promise.return ())
| None -> Promise.return ()

let _construct =
Expand Down
7 changes: 7 additions & 0 deletions src/settings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,10 @@ let server_syntaxDocumentation_setting =
~key:"ocaml.server.syntaxDocumentation"
~of_json:Jsonoo.Decode.bool
~to_json:Jsonoo.Encode.bool

let server_constructRecursiveCalls_setting =
create_setting
~scope:ConfigurationTarget.Workspace
~key:"ocaml.commands.construct.recursiveCalls"
~of_json:Jsonoo.Decode.bool
~to_json:Jsonoo.Encode.bool
2 changes: 2 additions & 0 deletions src/settings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ val server_extendedHover_setting : bool setting
val server_duneDiagnostics_setting : bool setting

val server_syntaxDocumentation_setting : bool setting

val server_constructRecursiveCalls_setting : bool setting
Loading