Skip to content

Commit

Permalink
feature: disable code lens by default
Browse files Browse the repository at this point in the history
This feature seems to annoy quite a few users so we disable it by
default. It can be enabled through configuration.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 4dd3b3fc-5f88-48df-b6a9-8792dde164b4 -->
  • Loading branch information
rgrinberg committed Jun 12, 2023
1 parent 11cc2ef commit 772062a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Fixes

- Disable code lens by default. The support can be re-enabled by explicitly
setting it in the configuration. (#1134)

- Fix initilization of `ocamlformat-rpc` in some edge cases when ocamlformat is
initialized concurrently (#1132)

Expand Down
10 changes: 7 additions & 3 deletions ocaml-lsp-server/docs/ocamllsp/config.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Configuration

The ocamllsp support the folowing configuration. These configurations are sent through the [`didChangeConfiguration`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeConfiguration) notification.
The ocamllsp support the folowing configurations.

These configurations are sent through the
[`didChangeConfiguration`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeConfiguration)
notification.

```ts
interface config {
/**
* Enable/Disabe Extended Hover
* Enable/Disable Extended Hover
* @default false
* @since 1.16
*/
extendedHover: { enable : boolean }

/**
* Enable/Disable CodeLens
* @default true
* @default false
* @since 1.16
*/
codelens: { enable : boolean }
Expand Down
2 changes: 1 addition & 1 deletion ocaml-lsp-server/src/config_data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,6 @@ let _ = yojson_of_t
[@@@end]

let default =
{ codelens = Some { enable = true }
{ codelens = Some { enable = false }
; extended_hover = Some { enable = false }
}
4 changes: 2 additions & 2 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ let on_request :
| TextDocumentCodeLensResolve codeLens -> now codeLens
| TextDocumentCodeLens req -> (
match state.configuration.data.codelens with
| Some { enable = true } | None -> later text_document_lens req
| Some _ -> now [])
| Some { enable = true } -> later text_document_lens req
| _ -> now [])
| TextDocumentHighlight req -> later highlight req
| DocumentSymbol { textDocument = { uri }; _ } -> later document_symbol uri
| TextDocumentDeclaration { textDocument = { uri }; position } ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ describe("textDocument/references", () => {

beforeEach(async () => {
languageServer = await LanguageServer.startAndInitialize();
languageServer.sendNotification("workspace/didChangeConfiguration", {
settings: {
codelens: { enable: true },
},
});
});

afterEach(async () => {
Expand Down

0 comments on commit 772062a

Please sign in to comment.