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

feature: disable code lens by default #1134

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

rgrinberg
Copy link
Member

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 [email protected]

@rgrinberg rgrinberg force-pushed the ps/rr/feature__disable_code_lens_by_default branch from 56838b1 to c7f6ed8 Compare June 11, 2023 18:07
@rgrinberg rgrinberg requested a review from 3Rafal June 11, 2023 18:07
@rgrinberg rgrinberg added this to the 1.16.0 milestone Jun 11, 2023
@aspeddro
Copy link
Contributor

Update the config.md

/**
* Enable/Disable CodeLens
* @default true
* @since 1.16
*/
codelens: { enable : boolean }
}

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 <[email protected]>

<!-- ps-id: 4dd3b3fc-5f88-48df-b6a9-8792dde164b4 -->
@rgrinberg rgrinberg force-pushed the ps/rr/feature__disable_code_lens_by_default branch from c7f6ed8 to 772062a Compare June 12, 2023 14:07
@coveralls
Copy link

coveralls commented Jun 12, 2023

Pull Request Test Coverage Report for Build 3852

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 1 of 2 (50.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 17.353%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ocaml-lsp-server/src/ocaml_lsp_server.ml 1 2 50.0%
Totals Coverage Status
Change from base Build 3848: 0.004%
Covered Lines: 4073
Relevant Lines: 23471

💛 - Coveralls

@rgrinberg rgrinberg merged commit 60fcf3f into master Jun 12, 2023
@rgrinberg rgrinberg deleted the ps/rr/feature__disable_code_lens_by_default branch June 12, 2023 20:07
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Jun 18, 2023
CHANGES:

## Fixes

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

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

- Kill unnecessary `$ dune ocaml-merlin` with SIGTERM rather than SIGKILL
  (ocaml/ocaml-lsp#1124)

- Refactor comment parsing to use `odoc-parser` and `cmarkit` instead of
  `octavius` and `omd` (ocaml/ocaml-lsp#1088)

  This allows users who migrated to omd 2.X to install ocaml-lsp-server in the
  same opam switch.

  We also slightly improved markdown generation support and fixed a couple in
  the generation of inline heading and module types.

- Allow opening documents that were already open. This is a workaround for
  neovim's lsp client (ocaml/ocaml-lsp#1067)

- Disable type annotation for functions (ocaml/ocaml-lsp#1054)

- Respect codeActionLiteralSupport capability (ocaml/ocaml-lsp#1046)

- Fix a document syncing issue when utf-16 is the position encoding (ocaml/ocaml-lsp#1004)

- Disable "Type-annotate" action for code that is already annotated.
  ([ocaml/ocaml-lsp#1037](ocaml/ocaml-lsp#1037)), fixes
  [ocaml/ocaml-lsp#1036](ocaml/ocaml-lsp#1036)

- Fix semantic highlighting of long identifiers when using preprocessors
  ([ocaml/ocaml-lsp#1049](ocaml/ocaml-lsp#1049), fixes
  [ocaml/ocaml-lsp#1034](ocaml/ocaml-lsp#1034))

- Fix the type of DocumentSelector in cram document registration (ocaml/ocaml-lsp#1068)

- Accept the `--clientProcessId` command line argument. (ocaml/ocaml-lsp#1074)

- Accept `--port` as a synonym for `--socket`. (ocaml/ocaml-lsp#1075)

- Fix connecting to dune rpc on Windows. (ocaml/ocaml-lsp#1080)

## Features

- Add "Remove type annotation" code action. (ocaml/ocaml-lsp#1039)

- Support settings through `didChangeConfiguration` notification (ocaml/ocaml-lsp#1103)

- Add "Extract local" and "Extract function" code actions. (ocaml/ocaml-lsp#870)

- Depend directly on `merlin-lib` 4.9 (ocaml/ocaml-lsp#1070)
@Khady
Copy link
Collaborator

Khady commented Jun 30, 2023

FWIW, this is a terrible user experience for anyone not very comfortable with their editor and the ocaml environment. This is definitely something that is expected to work by default. And the fix is completely non obvious.

@beajeanm
Copy link

This feature seems to annoy quite a few users

It's the first time I've heard of this being an issue, what problem were they seeing with code lense enabled by default?

so we disable it by default

Default is king, this mean most user will assume ocaml tooling doesn't support code lens because they'll won't be aware of the config switch, or how to configure their particular flavor of editor/lsp-plugin to have that switch forwarded to ocaml-lsp.

@3Rafal
Copy link
Collaborator

3Rafal commented Jun 30, 2023

I have approved this PR because it was technically correct, but considering above arguments I'd say that we should bring back default code lenses.

@rgrinberg
Copy link
Member Author

There's just as many users who complained about this feature to me personally as there are people in here that are in favor of it. There can only be one default so unfortunately, we will need to upset one group.

I suggest that we play it conservatively with controversial features and disable them by default. If we didn't make it easy enough to re-enable this feature, that's a very valid complaint.

As a side note, @jfeser is adding inlay hints which are going to be strictly superior to this feature anyway and we'll definitely enable that by default.

@tmattio
Copy link
Collaborator

tmattio commented Jun 30, 2023

There's just as many users who complained about this feature to me personally as there are people in here that are in favor of it. There can only be one default so unfortunately, we will need to upset one group.

It would be nice to move these complains to the issue tracker, so there's an opportunity to have a discussion. What is the reason they are annoyed by the feature?

@rgrinberg
Copy link
Member Author

rgrinberg commented Jun 30, 2023

The complaint is fairly simple: they take up a lot of vertical real estate and provide little value. The problem is compounded when other plugins want to provide code lenses. They aren't actionable, so they don't even fulfill their original spec.

@ddickstein @hackwaly @aspeddro can expand as well. These are just the names I remember who complained about this feature.

@tmattio
Copy link
Collaborator

tmattio commented Jun 30, 2023

Thanks!

I suggest that we play it conservatively with controversial features and disable them by default. If we didn't make it easy enough to re-enable this feature, that's a very valid complaint.

My opinion on this is that when choosing which defaults to use, we should prioritise new users since users who are advanced enough to know what they want are able to configure their editors to match that. That's also the opinion of @Khady above IIUC.

  • Do new OCaml users find the code lens valuable? (I have a strong intuition that it is valuable to understand code, especially as a beginner. I've personally found it useful on many occasions)
  • Are the people you tagged happy to have a configuration option to disable code lense instead of changing the default? (implemented in Support lsp server settings ocamllabs/vscode-ocaml-platform#1157 for vscode)

@hackwaly
Copy link

I would accept that given an config option to disable it rather than make disable as default. Since newcomes may not know if there is codelens for types

@rgrinberg
Copy link
Member Author

Okay, you guys can bring it back if you want. Heads up, it's still going away in favor of inlay hints as those are designed for type annotations unlike the code lens.

@tmattio
Copy link
Collaborator

tmattio commented Jun 30, 2023

Will the inlay hints provide type annotations for top-level values/functions? It does seem to be the case in the screenshot on #1159. If it does, then the information is duplicated and I would agree that code lens can be replaced with inlay hints, otherwise it seems useful to have both

@rgrinberg
Copy link
Member Author

Yes, they will work for top-level functions and values. Although they are not that intrusive so we can enable them everywhere.

@tmattio
Copy link
Collaborator

tmattio commented Jun 30, 2023

Ok, if the information is duplicated, then I'm siding with you and I don't think it's useful to bring the code lens back (as the default). Would be nice to introduce the inlay hints at the same time as the removal of code lens (as the default) so we don't have a release with neither.

@beajeanm
Copy link

Indeed it looks like inlay hints will be the way to good, thanks for the information.

@dyedgreen
Copy link

Some context on why I raised this with @rgrinberg originally:

  • It already duplicates information (even before inlay type annotations are introduced) since the same information is available in the provided document symbols
  • Inlay type annotations solve this problem better (since they look like the source could would look rather than having special styling, eg in VSCode the code lens actions are not in a monospaced font)
  • The type code lens was also confusing, because it’s not actionable (eg we have some code lenses for running inline tests, which are effectively inline buttons in the code)

@Khady
Copy link
Collaborator

Khady commented Jul 3, 2023

  • being able to see types directly isn't the same as having to rely on more complicated mechanisms which require an action from the developer
  • Indeed inlay look great, but so far the feature hasn't been developed so this is not a valid replacement
  • It is not clickable but it is definitely actionable, for example I can write code based on the types I see

Sure I'm happy to replace the codelens with inlay when the latter lands. But in the meantime a useful feature was (relatively silently) dropped with no replacement and no quickfix but forking ocamllsp. Maybe for such breaking changes if there isn't a good support in all major editors ocamllsp should provide a workaround. It could be a CLI argument to the ocamllsp binary or an environment variable for example.

we have some code lenses for running inline tests, which are effectively inline buttons in the code

the name of the config option to disable the codelens is probably too generic then? As one might want to disable the type codelens but keep the other kind of codelens?

@cemerick
Copy link

Big 👍 on this being a poor change, absent an obvious alternative. I was sure either the vscode extension or ocamllsp were borked (as I've always used the presence of the codelenses as the primary indication that the extension and lsp server were talking properly), and was about to write up something equivalent to #1164 before I thankfully saw it waiting for me.

(I'm also far from sold on "inlays" as being obviously superior based on what I see in #1159, but perhaps that's a separate topic.)

Could someone please ELI5 how to restore the codelens functionality? Getting hints from trawling through various issues and commits, I've tried these configuration, with no results:

"ocaml.codelens.enable": true,
"[ocaml]": {
    "editor.codeLens": true
}

@aspeddro
Copy link
Contributor

@cemerick, the config is "ocaml.server.codelens": true

@beajeanm
Copy link

beajeanm commented Jul 21, 2023

For anyone coming here looking for the solution for neovim, if you are using lsp-config, you will need to add to your ocamllsp setup something like:

require('lspconfig').ocamllsp.setup {
  settings = {
    codelens = { enable = true },
 },
}

@EduardoRFS
Copy link
Contributor

So, this was disabled by default, there is a bug which makes it not enabled in VSCode for a while and inlay hints hasn't been merged yet. Can we enable it by default again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.