Skip to content

Feature request: documentHighlightProvider support #43

Closed

Description

@nujabse

Currently fortls does not implement the documentHighlightProvider language server feature, which makes emacs lsp-mode do not have symbol highlighting feature. Can you implement this feature ?

Activity

  1. gnikit commented on Feb 4, 2022

    @gnikit
    Member

    Could you please elaborate a bit about what you mean by "symbol highlighting feature"? From what I understand documentHighlightProvider should be nearly identical to textDocument/references which is already implemented.
    If by any chance you mean syntax highlighting, that is usually provided by the extension and not the language server since it is a big task of its own.

    Document Highlights Request (:leftwards_arrow_with_hook:)
    The document highlight request is sent from the client to the server to resolve a document highlights for a given text document position. For programming languages this usually highlights all references to the symbol scoped to this file. However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. Symbol matches usually have a DocumentHighlightKind of Read or Write whereas fuzzy or textual matches use Textas the kind.

    see: https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_documentHighlight

  2. gnikit commented on Feb 4, 2022

    @gnikit
    Member

    Further elaborating on my previous comments, this is the current status of the reference highlighting, which I suspect is what you are asking

    image

    Could you please post the settings you use for fortls?

  3. nujabse commented on Feb 4, 2022

    @nujabse
    Author

    Yes, what I mean by "symbol highlighting" is reference highlighting, see the example code in Emacs using fortls with lsp-mode:
    image
    The dist variables under the curser should have been highlighted, but I can not get it working in Emacs with lsp-mode. However, reference highlighting usingfortls works just fine in Vscode.
    The settings for fortls I'm using are "--variable_hover" "--hover_signature" "--lowercase_intrinsics"

  4. gnikit commented on Feb 4, 2022

    @gnikit
    Member

    So I would guess then that lsp-mode does not support textDocument/references, which is weird. Has that always been the case? Your client should be able to handle both textDocument/references and documentHighlightProvider.

  5. nujabse commented on Feb 4, 2022

    @nujabse
    Author

    Well, it seems that lsp-mode needs documentHighlightProvider to do the reference highlighting, as discussed in the issue. Maybe I just need to wait for lsp-mode to support it. Thanks anyway for your help! fortls is very useful.

  6. reopened this on May 13, 2022
  7. gnikit commented on May 13, 2022

    @gnikit
    Member

    I don't think there is any harm registering both references and documentHighlight.

  8. self-assigned this
    on May 13, 2022
  9. added this to the v2.5.0 - Backlog milestone on May 13, 2022
  10. added a commit that references this issue on May 13, 2022
  11. rcoacci commented on Jul 23, 2024

    @rcoacci

    Hi, after some time struggling with this problem, I discovered that you missed adding "documentHighlightProvider": True to the server_capabilities dictionary in langserver.py::serve_initialize. Without it, LSP clients don't request the documentHighlight and the symbol highlight doesn't work. After adding it in a local copy of fortls, Emacs' lsp-mode does symbol highlight correctly. Should I open a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions