You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: documentHighlightProvider support #43
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 ?
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.
Yes, what I mean by "symbol highlighting" is reference highlighting, see the example code in Emacs using fortls with lsp-mode:
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"
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.
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.
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?
Activity
gnikit commentedon Feb 4, 2022
Could you please elaborate a bit about what you mean by "symbol highlighting feature"? From what I understand
documentHighlightProvidershould be nearly identical totextDocument/referenceswhich 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.
see: https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_documentHighlight
gnikit commentedon 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
Could you please post the settings you use for
fortls?nujabse commentedon Feb 4, 2022
Yes, what I mean by "symbol highlighting" is reference highlighting, see the example code in Emacs using

fortlswithlsp-mode:The
distvariables under the curser should have been highlighted, but I can not get it working in Emacs withlsp-mode. However, reference highlighting usingfortlsworks just fine in Vscode.The settings for
fortlsI'm using are"--variable_hover" "--hover_signature" "--lowercase_intrinsics"gnikit commentedon Feb 4, 2022
So I would guess then that
lsp-modedoes not supporttextDocument/references, which is weird. Has that always been the case? Your client should be able to handle bothtextDocument/referencesanddocumentHighlightProvider.nujabse commentedon Feb 4, 2022
Well, it seems that
lsp-modeneedsdocumentHighlightProviderto do the reference highlighting, as discussed in the issue. Maybe I just need to wait forlsp-modeto support it. Thanks anyway for your help!fortlsis very useful.gnikit commentedon May 13, 2022
I don't think there is any harm registering both
referencesanddocumentHighlight.Added `textDocument/documentHighlight`
rcoacci commentedon Jul 23, 2024
Hi, after some time struggling with this problem, I discovered that you missed adding
"documentHighlightProvider": Trueto theserver_capabilitiesdictionary 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?