Skip to content

Commit

Permalink
Launch superbol
Browse files Browse the repository at this point in the history
  • Loading branch information
emilienlemaire committed Apr 24, 2023
1 parent 5325588 commit 605ff59
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*~
_build
.merlin
.vscode
.vscode/settings.json
/_drom
/_opam
/_build
Expand All @@ -20,5 +20,6 @@ _build
/yarn.lock
/package-json
ATTIC
/out


3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}"
]
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension (no disable-extensions)",
Expand Down
9 changes: 4 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "dune build @vscode -w",
"label": "dune build @vscode -w",
"type": "npm",
"script": "compile",
"problemMatcher": "$ocamlc",
"presentation": {
"reveal": "never"
"reveal": "always"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
}
16 changes: 16 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require("esbuild")
.build({
logLevel: "info",
entryPoints: [
"_build/default/src/superbol-vscode-extension/superbol_vscode_extension.bc.js"
],
bundle: true,
external: ["vscode"],
outdir: "out",
platform: "node",
target: "es6",
sourcemap: true,
minifyWhitespace: true,
minifySyntax: true,
})
.catch(() => process.exit())
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
"Snippets",
"Other"
],
"activationEvents": [
"onLanguage:cobol"
],
"activationEvents": [],
"contributes": {
"languages": [
{
"id": "cobol",
"filenamePatterns": ["*.cbl", "*.cob"]
}
],
"configuration": {
"title": "Superbol COBOL",
"properties": {
Expand All @@ -50,6 +54,7 @@
},
"main": "./dist/superbol_vscode_extension.bc.js",
"scripts": {
"compile" : "drom build && node build.js",
"package": "vsce package --out superbol-vscode-extension.vsix --yarn",
"deploy:vsce": "vsce publish --packagePath superbol-vscode-extension.vsix --yarn",
"deploy:ovsx": "ovsx publish --yarn"
Expand Down
44 changes: 42 additions & 2 deletions src/superbol-vscode-extension/superbol_vscode_extension.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function activate(context: vscode.ExtensionContext) {

(* open Js_of_ocaml *)

let indentRange
(* let indentRange
~document
~options:_
~token:_
Expand Down Expand Up @@ -174,4 +174,44 @@ let activate (extension : Vscode.ExtensionContext.t) =
activate() *)
let () =
let open Js_of_ocaml.Js in
export "activate" (wrap_callback activate)
export "activate" (wrap_callback activate) *)

let client = ref None

let activate (_extension: Vscode.ExtensionContext.t) =
let command =
Vscode.Workspace.getConfiguration ()
|> Vscode.WorkspaceConfiguration.get ~section:"superbol.path"
|> function Some o -> Ojs.string_of_js o
| None -> "superbol"
in
let args = ["x-lsp"] in
let serverOptions = Vscode_languageclient.ServerOptions.create
~command
~args
()
in
let documentSelector =
[| `Filter (Vscode_languageclient.DocumentFilter.createLanguage ~language:"cobol" ()) |]
in
let clientOptions = Vscode_languageclient.ClientOptions.create ~documentSelector () in
client :=
Some (Vscode_languageclient.LanguageClient.make
~id:"cobolServer"
~name:"Cobol Server"
~serverOptions
~clientOptions
());
match !client with
| Some client -> Vscode_languageclient.LanguageClient.start client
| None -> Promise.return ()

let deactivate () =
match !client with
| None -> Promise.return ()
| Some client -> Vscode_languageclient.LanguageClient.stop client

let () =
Js_of_ocaml.Js.(export "activate" (wrap_callback activate));
Js_of_ocaml.Js.(export "deactivate" (wrap_callback deactivate))

57 changes: 46 additions & 11 deletions superbol-vscode-extension-deps.opam.locked
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,86 @@ doc: "https://ocamlpro.github.io/superbol-vscode-extension/sphinx"
bug-reports: "https://github.com/ocamlpro/superbol-vscode-extension/issues"
depends: [
"angstrom" {= "0.15.0"}
"base-bigarray" {= "base+bin+6aa7b5b3+f2cc4984"}
"base-threads" {= "base+bin+88ec833a+f2cc4984"}
"base-unix" {= "base+bin+6c5a8d56+f2cc4984"}
"bigstringaf" {= "0.9.0"}
"astring" {= "0.8.5" & with-test}
"base" {= "v0.15.1" & with-test}
"base-bigarray" {= "base"}
"base-bytes" {= "base" & with-test}
"base-threads" {= "base"}
"base-unix" {= "base"}
"bigstringaf" {= "0.9.1"}
"camlp-streams" {= "5.0.1" & with-test}
"cmdliner" {= "1.1.1"}
"conf-pkg-config" {= "2"}
"cppo" {= "1.6.9"}
"cstruct" {= "6.1.1"}
"csexp" {= "1.5.1"}
"cstruct" {= "6.2.0"}
"dune" {= "3.7.0"}
"dune-build-info" {= "3.7.0" & with-test}
"dune-configurator" {= "3.7.0"}
"either" {= "1.0.0" & with-test}
"ez_file" {= "0.3.0"}
"ezjsonm" {= "1.3.0"}
"fix" {= "20220121" & with-test}
"fmt" {= "0.9.0"}
"fpath" {= "0.7.3" & with-test}
"gen" {= "1.1"}
"gen_js_api" {= "1.1.2"}
"hex" {= "1.5.0"}
"js_of_ocaml" {= "5.0.1"}
"js_of_ocaml-compiler" {= "5.0.1"}
"js_of_ocaml-ppx" {= "5.0.1"}
"jane-street-headers" {= "v0.15.0" & with-test}
"js_of_ocaml" {= "5.1.1"}
"js_of_ocaml-compiler" {= "5.1.1"}
"js_of_ocaml-ppx" {= "5.1.1"}
"json-data-encoding" {= "0.12.1"}
"jsonm" {= "1.0.2"}
"jsonoo" {= "0.2.1"}
"jst-config" {= "v0.15.1" & with-test}
"menhir" {= "20220210"}
"menhirLib" {= "20220210"}
"menhirSdk" {= "20220210"}
"ocaml" {= "4.14.1"}
"ocaml-base-compiler" {= "4.14.1"}
"ocaml-compiler-libs" {= "v0.12.4"}
"ocaml-config" {= "2"}
"ocaml-options-vanilla" {= "1+bin+8afbbae3+f2cc4984"}
"ocaml-options-vanilla" {= "1"}
"ocaml-syntax-shims" {= "1.0.0"}
"ocaml-version" {= "3.6.1" & with-test}
"ocamlbuild" {= "0.14.2"}
"ocamlfind" {= "1.9.6"}
"ocamlformat" {= "0.25.1" & with-test}
"ocamlformat-lib" {= "0.25.1" & with-test}
"ocp-indent" {= "1.8.1" & with-test}
"ocplib_stuff" {= "0.3.0"}
"odoc" {= "2.2.0" & with-doc}
"odoc-parser" {= "2.0.0" & with-doc}
"ojs" {= "1.1.2"}
"ppx_assert" {= "v0.15.0" & with-test}
"ppx_base" {= "v0.15.0" & with-test}
"ppx_cold" {= "v0.15.0" & with-test}
"ppx_compare" {= "v0.15.0" & with-test}
"ppx_derivers" {= "1.2.1"}
"ppx_deriving_encoding" {= "0.3.0"}
"ppxlib" {= "0.29.1"}
"ppx_enumerate" {= "v0.15.0" & with-test}
"ppx_expect" {= "v0.15.1" & with-test}
"ppx_hash" {= "v0.15.0" & with-test}
"ppx_here" {= "v0.15.0" & with-test}
"ppx_inline_test" {= "v0.15.0" & with-test}
"ppx_optcomp" {= "v0.15.0" & with-test}
"ppx_sexp_conv" {= "v0.15.1" & with-test}
"ppxlib" {= "0.28.0"}
"promise_jsoo" {= "0.3.1"}
"re" {= "1.10.4"}
"result" {= "1.5"}
"sedlex" {= "3.1"}
"seq" {= "base"}
"sexplib0" {= "v0.15.1"}
"stdio" {= "v0.15.0" & with-test}
"stdlib-shims" {= "0.3.0"}
"stringext" {= "1.6.0"}
"time_now" {= "v0.15.0" & with-test}
"topkg" {= "1.0.7"}
"tyxml" {= "4.5.0" & with-doc}
"uri" {= "4.2.0"}
"uucp" {= "15.0.0" & with-test}
"uuseg" {= "15.0.0" & with-test}
"uutf" {= "1.0.3"}
"yojson" {= "2.0.2"}
]
Expand Down

0 comments on commit 605ff59

Please sign in to comment.