Skip to content
Draft
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
3 changes: 3 additions & 0 deletions assets/run-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/run-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,20 @@
"command": "ocaml.install-dune-lsp",
"category": "OCaml",
"title": "Start the Ocaml-LSP server for Dune Package Management"
},
{
"command": "ocaml.view-metrics",
"category": "OCaml",
"title": "View metrics"
},
{
"command": "ocaml.run-standalone-file",
"category": "OCaml",
"title": "Run as a standalone bytecode executable",
"icon": {
"light": "assets/run-light.svg",
"dark": "assets/run-dark.svg"
}
}
],
"configuration": {
Expand Down Expand Up @@ -563,6 +577,58 @@
}
],
"debuggers": [
{
"type": "ocaml.run-standalone-file",
"label": "Run standalone OCaml file",
"configurationAttributes": {
"launch": {
"required": [
"program"
],
"properties": {
"cwd": {
"type": "string",
"description": "The working directory for runned program."
},
"program": {
"type": "string",
"description": "The path of runned program."
},
"arguments": {
"type": "array",
"items": {
"type": "string"
},
"description": "The command-line arguments for runned program.",
"default": []
}
}
}
},
"initialConfigurations": [
{
"name": "Run standalone OCaml file",
"type": "ocaml.run-standalone-file",
"request": "launch",
"program": "${command:AskProgram}"
}
],
"configurationSnippets": [
{
"label": "OCaml: Run standalone file",
"description": "Configuration for running OCaml program",
"body": {
"name": "${2: Launch program}",
"type": "ocaml.run-standalone-file",
"request": "launch",
"program": "^\"\\${workspaceFolder}/${1:OCaml standalone file}\""
}
}
],
"variables": {
"AskProgram": "ocaml.ask-run-program"
}
},
{
"type": "ocaml.earlybird",
"label": "OCaml earlybird (experimental)",
Expand Down Expand Up @@ -1179,6 +1245,10 @@
"command": "ocaml.goto-closure-code-location",
"when": "false"
},
{
"command": "ocaml.start-run",
"when": "false"
},
{
"command": "ocaml.copy-type-under-cursor",
"when": "editorLangId == ocaml || editorLangId == ocaml.interface || editorLangId == reason"
Expand All @@ -1202,6 +1272,11 @@
"key": "Alt+O",
"when": "editorTextFocus && (editorLangId == ocaml || editorLangId == ocaml.interface || editorLangId == ocaml.mlx || editorLangId == reason)",
"group": "navigation"
},
{
"command": "ocaml.run-standalone-file",
"when": "editorTextFocus && editorLangId == ocaml",
"group": "navigation"
}
],
"view/title": [
Expand Down Expand Up @@ -1461,7 +1536,9 @@
},
"activationEvents": [
"onCommand:ocaml.ask-debug-program",
"onCommand:ocaml.ask-run-program",
"onDebugResolve:ocaml.earlybird",
"onDebugResolve:ocaml.run-standalone-file",
"onLanguage:cram",
"workspaceContains:**/*.ml",
"workspaceContains:**/*.mli",
Expand Down
22 changes: 12 additions & 10 deletions src-bindings/vscode/vscode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3352,13 +3352,24 @@ module DebugAdapterDescriptor = struct
;;
end

module DebugConfiguration = struct
include Interface.Make ()

include
[%js:
val create : name:string -> request:string -> type_:string -> t [@@js.builder]
val set : t -> string -> Ojs.t -> unit [@@js.index_set]]
end

module DebugSession = struct
include Class.Make ()

include
[%js:
val customRequest : t -> command:string -> ?args:Ojs.t -> unit -> Ojs.t Promise.t
[@@js.call]]
[@@js.call]

val configuration : t -> DebugConfiguration.t [@@js.get]]
end

module DebugAdapterDescriptorFactory = struct
Expand All @@ -3382,15 +3393,6 @@ module DebugAdapterDescriptorFactory = struct
[@@js.builder]]
end

module DebugConfiguration = struct
include Interface.Make ()

include
[%js:
val create : name:string -> request:string -> type_:string -> t [@@js.builder]
val set : t -> string -> Ojs.t -> unit [@@js.index_set]]
end

module DebugConfigurationProvider = struct
include Interface.Make ()

Expand Down
15 changes: 8 additions & 7 deletions src-bindings/vscode/vscode.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2383,10 +2383,18 @@ module DebugAdapterDescriptor : sig
include Ojs.T with type t := t
end

module DebugConfiguration : sig
include Ojs.T

val create : name:string -> request:string -> type_:string -> t
val set : t -> string -> Ojs.t -> unit
end

module DebugSession : sig
include Ojs.T

val customRequest : t -> command:string -> ?args:Ojs.t -> unit -> Ojs.t Promise.t
val configuration : t -> DebugConfiguration.t
end

module DebugAdapterDescriptorFactory : sig
Expand All @@ -2407,13 +2415,6 @@ module DebugAdapterDescriptorFactory : sig
-> t
end

module DebugConfiguration : sig
include Ojs.T

val create : name:string -> request:string -> type_:string -> t
val set : t -> string -> Ojs.t -> unit
end

module DebugConfigurationProvider : sig
include Ojs.T

Expand Down
4 changes: 2 additions & 2 deletions src/cmd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ let check ?env t =
Spawn s
;;

let run ?cwd ?env ?stdin cmd =
let run ?output ?cwd ?env ?stdin cmd =
let cwd = Option.map cwd ~f:Path.to_string in
let logger event =
let (lazy output) = Output.command_output_channel in
let (lazy output) = Option.value output ~default:Output.command_output_channel in
match event with
| ChildProcess.Spawned ->
Vscode.OutputChannel.appendLine output ~value:("$ " ^ to_string cmd)
Expand Down
3 changes: 2 additions & 1 deletion src/cmd.mli
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ val output
val equal_spawn : spawn -> spawn -> bool

val run
: ?cwd:Path.t
: ?output:OutputChannel.t Lazy.t
-> ?cwd:Path.t
-> ?env:string Interop.Dict.t
-> ?stdin:stderr
-> t
Expand Down
13 changes: 13 additions & 0 deletions src/command_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ module Internal = struct
~return_type:(module Return)
;;

let ask_run_program =
let module Return = struct
type t = string option Promise.t [@@js]
end
in
typed_handle
"ask-run-program"
~args_of_js:(Fn.const ())
~args_to_js:(Fn.const [])
~return_type:(module Return)
;;

let copy_type_under_cursor = unit_handle "copy-type-under-cursor"
let construct = unit_handle "construct"
let merlin_jump = unit_handle "jump"
Expand All @@ -154,6 +166,7 @@ module Internal = struct
let init_opam = unit_handle "init-opam"
let install_ocaml_dev = unit_handle "install-ocaml-dev"
let open_utop = unit_handle "open-utop"
let run_standalone_file = unit_handle "run-standalone-file"
end

module Vscode = struct
Expand Down
2 changes: 2 additions & 0 deletions src/command_api.mli
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module Internal : sig
val start_debugging : (Vscode.Uri.t option, unit) handle
val goto_closure_code_location : (Jsonoo.t, unit) handle
val ask_debug_program : (unit, string option Promise.t) handle
val ask_run_program : (unit, string option Promise.t) handle
val copy_type_under_cursor : (unit, unit) handle
val construct : (unit, unit) handle
val merlin_jump : (unit, unit) handle
Expand All @@ -55,6 +56,7 @@ module Internal : sig
val init_opam : (unit, unit) handle
val install_ocaml_dev : (unit, unit) handle
val open_utop : (unit, unit) handle
val run_standalone_file : (unit, unit) handle
end

module Vscode : sig
Expand Down
2 changes: 2 additions & 0 deletions src/output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ let extension_output_channel =
let command_output_channel =
lazy (Vscode.Window.createOutputChannel ~name:"OCaml Commands" ())
;;

let run_output_channel = lazy (Vscode.Window.createOutputChannel ~name:"Run OCaml" ())
2 changes: 2 additions & 0 deletions src/output.mli
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ val extension_output_channel : Vscode.OutputChannel.t Lazy.t
(** [command_output_channel] is the output channel for user-friendly logs of
shell commands *)
val command_output_channel : Vscode.OutputChannel.t Lazy.t

val run_output_channel : Vscode.OutputChannel.t Lazy.t
Loading
Loading