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 5 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.server.construct.chainConstruct` setting to configure construct chaining. (#1673)
PizieDust marked this conversation as resolved.
Show resolved Hide resolved

## 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.server.construct.chainConstruct` | Controls whether construct should automatically compute for the next typed hole. | `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.server.construct.chainConstruct": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable/Disable chaining construct to display values for subsequent holes."
smorimoto marked this conversation as resolved.
Show resolved Hide resolved
},
"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_chainConstructResults_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_chainConstructResults_setting =
create_setting
~scope:ConfigurationTarget.Workspace
~key:"ocaml.server.construct.chainConstruct"
~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_chainConstructResults_setting : bool setting
2 changes: 1 addition & 1 deletion vscode-ocaml-platform.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ depends: [
"ocaml-version" {>= "3.5.0"}
"ppxlib" {>= "0.26.0"}
"opam-file-format" {>= "2.1.2"}
"ocamlformat" {= "0.26.2" & with-dev-setup}
"ocamlformat" {= "0.27.0" & with-dev-setup}
"ocaml-lsp-server" {with-dev-setup}
"odoc" {with-doc}
]
Expand Down
2 changes: 1 addition & 1 deletion vscode.opam
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ depends: [
"gen_js_api" {= "1.1.2"}
"promise_jsoo" {>= "0.3.1"}
"jsonoo" {>= "0.2.1"}
"ocamlformat" {= "0.26.2" & with-dev-setup}
"ocamlformat" {= "0.27.0" & with-dev-setup}
smorimoto marked this conversation as resolved.
Show resolved Hide resolved
"ocaml-lsp-server" {with-dev-setup}
"odoc" {with-doc}
]
Expand Down
Loading