Skip to content

Commit

Permalink
Merge pull request #167 from nberth/using-vscode-provided-storage
Browse files Browse the repository at this point in the history
Optionally pass a `--storage-directory` argument to the LSP server
  • Loading branch information
nberth authored Jul 30, 2024
2 parents 2a30f4b + 3993ece commit d155fae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [0.1.4] Next release

### Added
- Configuration flag for caching in storage provided by Visual Studio Code [#167](https://github.com/OCamlPro/superbol-studio-oss/pull/167)
- Configuration setting for copybook filename extensions [#332](https://github.com/OCamlPro/superbol-studio-oss/pull/332), with updated JSON schema [#333](https://github.com/OCamlPro/superbol-studio-oss/pull/333)
- COBOL language configuration for highlighting matching brackets and auto-insertion of line numbers in fixed-format code [#330](https://github.com/OCamlPro/superbol-studio-oss/pull/330)

Expand Down
8 changes: 7 additions & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/lsp/superbol_free_lib/vscode_extension.ml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ let contributes =
(with_superbol_toml_note
"File extensions for copybook resolution")
~default:Cobol_common.Copybook.copybook_extensions
~order:1;
~order:4;

(* Paths *)

Expand Down Expand Up @@ -373,6 +373,16 @@ let contributes =
``COBOL85``."
~order:21;

Manifest.PROPERTY.bool "superbol.cacheInGlobalStorage"
~default:false
~markdownDescription:
"Use storage provided by Visual Studio Code for caching. When \
this setting is set to *false*, the cache related to the \
contents of a given workspace folder *f* is stored in a file \
named *f*`/_superbol/lsp-cache`.\n\nNote: cache files are not \
removed automatically, whatever their location."
~order:22;

(* Debugger-specific: *)

Manifest.PROPERTY.bool
Expand Down
16 changes: 14 additions & 2 deletions src/vscode/superbol-vscode-platform/superbol_languageclient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ let find_superbol root =


let server_options ~context =
let root_uri = Vscode.ExtensionContext.extensionUri context in
let root_uri = Vscode.ExtensionContext.extensionUri context
and storage_uri =
(* Use the global state URI as the server stores caches on a per-project
basis (ie. for each workspace directory), not on a per-workspace
basis. *)
if Superbol_workspace.bool "cacheInGlobalStorage"
then Some (Vscode.ExtensionContext.globalStorageUri context)
else None
in
let command =
match Superbol_workspace.superbol_exe () with
| Some cmd ->
Expand All @@ -72,7 +80,10 @@ let server_options ~context =
let args =
let force_diagnostics = Superbol_workspace.bool "forceSyntaxDiagnostics" in
"lsp" ::
if force_diagnostics then ["--force-syntax-diagnostics"] else []
(if force_diagnostics then ["--force-syntax-diagnostics"] else []) @
(match storage_uri with
| None -> []
| Some uri -> ["--storage-directory"; Vscode.Uri.fsPath uri])
in
LSP.ServerOptions.create ()
~options ~command ~args
Expand All @@ -93,3 +104,4 @@ let server_needs_restart_after ~config_change =
in
affects "superbol.lsp-path" (* machine setting: no need for a scope *)
|| affects "superbol.forceSyntaxDiagnostics" (* scope? *)
|| affects "superbol.cacheInGlobalStorage"

0 comments on commit d155fae

Please sign in to comment.