neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.44k stars 954 forks source link

CodeLens has stopped working with the OCaml LSP #4594

Closed rbjorklin closed 1 year ago

rbjorklin commented 1 year ago

Result from CocInfo

## versions

vim version: NVIM v0.8.3
node version: v18.15.0
coc.nvim version: 0.0.82-a49628ab 2022-11-22 01:54:34 +0800
coc.nvim directory: /home/rbjorklin/.local/share/nvim/site/pack/packer/start/coc.nvim
term: screen-256color
platform: linux

## Log of coc.nvim

2023-03-30T22:34:26.562 INFO (pid:69530) [plugin] - coc.nvim initialized with node: v18.15.0 after 130
2023-03-30T22:34:26.682 INFO (pid:69530) [attach] - receive notification: highlight []
2023-03-30T22:34:26.687 INFO (pid:69530) [attach] - Request action: ensureDocument []
2023-03-30T22:34:26.689 INFO (pid:69530) [attach] - Request action: hasProvider [ 'documentSymbol' ]

Describe the bug

Starting with commit 668e854c49b71fc1a0498e018832f4d237812c3b on the release branch CodeLens has stopped working, and it is just a blank line.

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't reproduce it

coc-settings.json

{
  "coc.preferences.formatOnSaveFiletypes": [
    "ocaml"
  ],
  "suggest.noselect": true,
  "suggest.enablePreselect": false,
  "codeLens.enable": true,
  "semanticTokens.enable": true,
  "inlayHint.enable": true,
  "suggest.floatConfig.border": true,
  "signature.floatConfig.border": true,
  "hover.floatConfig.border": true,
  "diagnostic.floatConfig.border": true,
  "languageserver": {
    "ocaml-lsp": {
      "command": "opam",
      "args": [
        "exec",
        "--",
        "ocamllsp"
      ],
      "filetypes": [
        "ocaml",
        "reason"
      ]
    },
    "golang": {
      "command": "gopls",
      "rootPatterns": [
        "go.mod"
      ],
      "filetypes": [
        "go"
      ]
    }
  }
}

Screenshots (optional)

While creating this issue, I noticed that syntax highlighting differs between these two commits. Not sure if that's relevant.

7330319e1f68cb9f5ea1ab31a984680be493ea85 Screenshot from 2023-03-30 22-41-22

668e854c49b71fc1a0498e018832f4d237812c3b Screenshot from 2023-03-30 22-41-38

fannheyward commented 1 year ago

We need to verbose logs to check whether language server response or not https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

For the highlighting, check :h coc-semantic-highlights.

rbjorklin commented 1 year ago

Thanks for the prompt response.

broken-668e854c49b71fc1a0498e018832f4d237812c3b.txt working-7330319e1f68cb9f5ea1ab31a984680be493ea85.txt

fannheyward commented 1 year ago

Sorry for the delay.

You can search textDocument/codeLens in the logs, from the logs, I found codeLens request and response successfully. For example, broken-668e854c49b71fc1a0498e018832f4d237812c3b.txt has 6 requests, and 6 responses.

[Trace - 7:53:19 a.m.] Sending request 'textDocument/codeLens - (11)'.
Params: {
    "textDocument": {
        "uri": "file:///home/rbjorklin/git/trader-ocaml/src/lib/trader/trade.ml"
    }
}

[Trace - 7:53:19 a.m.] Received response 'textDocument/codeLens - (11)' in 26ms.
Result: [
    {
        "command": {
            "command": "",
            "title": "((module Caqti_lwt.CONNECTION),\n [< Caqti_error.t\n  > `Decode_rejected `Encode_failed `Encode_rejected `Request_failed\n    `Request_rejected `Response_failed `Response_rejected ])\nCaqti_lwt.Pool.t -> unit Lwt.t"
        },
        "range": {
            "end": {
                "character": 17,
                "line": 405
            },
            "start": {
                "character": 0,
                "line": 347
            }
        }
    },
...

And in the working-7330319e1f68cb9f5ea1ab31a984680be493ea85.txt, same request and response.

[Trace - 7:49:28 a.m.] Sending request 'textDocument/codeLens - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///home/rbjorklin/git/trader-ocaml/src/lib/trader/trade.ml"
    }
}

[Trace - 7:49:29 a.m.] Received response 'textDocument/codeLens - (1)' in 78ms.
Result: [
    {
        "command": {
            "command": "",
            "title": "((module Caqti_lwt.CONNECTION),\n [< Caqti_error.t\n  > `Decode_rejected `Encode_failed `Encode_rejected `Request_failed\n    `Request_rejected `Response_failed `Response_rejected ])\nCaqti_lwt.Pool.t -> unit Lwt.t"
        },
        "range": {
            "end": {
                "character": 17,
                "line": 405
            },
            "start": {
                "character": 0,
                "line": 347
            }
        }
    },
    ....

From the logs, coc sends the requests, and language server response to client. What do you mean stopped working? Any screenshots please.

rbjorklin commented 1 year ago

Hello @fannheyward, thanks for your response.

I attached screenshots in the initial post, notice how the type signature is missing above the function declaration for commit 668e854c49b71fc1a0498e018832f4d237812c3b and onwards.

fannheyward commented 1 year ago

Sorry I didn't notice that your screenshot had been include the codeLens issue, just thought that was semantic highlighting issue.

From the logs, codeLens requests and responses as expected. The codeLens related changes in 668e854c49b71fc1a0498e018832f4d237812c3b in https://github.com/neoclide/coc.nvim/commit/254b6d85be45f9983e2e1c6417a8d90678399f47, I'm checking this.

I don't use OCaml, with gopls/rust-analyzer/tsserver, codeLens works.

rbjorklin commented 1 year ago

Can I provide any more information that might help? For example, :call CocActionAsync('doHover') still behaves correctly on the latest commit on release while CodeLens doesn't.

fannheyward commented 1 year ago

@rbjorklin there was nothing new yet, do you have any Error on handler logs in :CocOpenLog?

And, does :CocCommand document.toggleCodeLens toggle it?

rbjorklin commented 1 year ago

Working 7330319e1f68cb9f5ea1ab31a984680be493ea85:

2023-04-22T11:31:31.725 INFO (pid:11859) [plugin] - coc.nvim initialized with node: v18.15.0 after ^[[33m140^[[39m
2023-04-22T11:31:31.729 INFO (pid:11859) [services] - LanguageClient ocaml-lsp state change: stopped => starting
2023-04-22T11:31:31.738 INFO (pid:11859) [language-client-index] - Language server "languageserver.ocaml-lsp" started with 11874
2023-04-22T11:31:31.758 INFO (pid:11859) [services] - LanguageClient ocaml-lsp state change: starting => running
2023-04-22T11:31:31.765 INFO (pid:11859) [services] - service languageserver.ocaml-lsp started
2023-04-22T11:31:31.911 INFO (pid:11859) [attach] - receive notification: highlight []
2023-04-22T11:31:31.916 INFO (pid:11859) [attach] - Request action: ensureDocument []
2023-04-22T11:31:31.939 INFO (pid:11859) [attach] - Request action: hasProvider [ ^[[32m'documentSymbol'^[[39m ]
2023-04-22T11:31:45.680 INFO (pid:11859) [attach] - receive notification: openLog []

Broken 668e854c49b71fc1a0498e018832f4d237812c3b:

2023-04-22T11:32:56.674 INFO (pid:14008) [plugin] - coc.nvim initialized with node: v18.15.0 after ^[[33m138^[[39m
2023-04-22T11:32:56.679 INFO (pid:14008) [services] - LanguageClient ocaml-lsp state change: stopped => starting
2023-04-22T11:32:56.687 INFO (pid:14008) [language-client-index] - Language server "languageserver.ocaml-lsp" started with 14023
2023-04-22T11:32:56.707 INFO (pid:14008) [services] - LanguageClient ocaml-lsp state change: starting => running
2023-04-22T11:32:56.714 INFO (pid:14008) [services] - service languageserver.ocaml-lsp started
2023-04-22T11:32:56.864 INFO (pid:14008) [attach] - receive notification: highlight []
2023-04-22T11:32:56.871 INFO (pid:14008) [attach] - Request action: ensureDocument []
2023-04-22T11:32:56.895 INFO (pid:14008) [attach] - Request action: hasProvider [ ^[[32m'documentSymbol'^[[39m ]
2023-04-22T11:33:17.247 INFO (pid:14008) [attach] - receive notification: openLog []

:CocCommand document.toggleCodeLens toggles a blank line in the broken version.

rbjorklin commented 1 year ago

I no longer use coc.nvim. Closing.

chemzqm commented 1 year ago

Could be not enabled, see :h coc-code-lens and :h coc-config-codeLens-enable