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 request: documentHighlightProvider support #43

Closed
nujabse opened this issue Feb 4, 2022 · 7 comments
Closed

Feature request: documentHighlightProvider support #43

nujabse opened this issue Feb 4, 2022 · 7 comments
Assignees

Comments

@nujabse
Copy link

nujabse commented Feb 4, 2022

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 ?

@gnikit
Copy link
Member

gnikit commented Feb 4, 2022

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

@gnikit
Copy link
Member

gnikit commented Feb 4, 2022

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?

@nujabse
Copy link
Author

nujabse commented Feb 4, 2022

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"

@gnikit
Copy link
Member

gnikit commented Feb 4, 2022

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.

@nujabse
Copy link
Author

nujabse commented Feb 4, 2022

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.

@nujabse nujabse closed this as completed Feb 4, 2022
@gnikit gnikit reopened this May 13, 2022
@gnikit
Copy link
Member

gnikit commented May 13, 2022

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

@gnikit gnikit self-assigned this May 13, 2022
@gnikit gnikit added this to the v2.5.0 - Backlog milestone May 13, 2022
gnikit added a commit that referenced this issue May 13, 2022
Fixes Feature request:  documentHighlightProvider support #43
@gnikit gnikit closed this as completed May 13, 2022
@rcoacci
Copy link

rcoacci commented Jul 23, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants