Skip to content

gopls: allow semantic highlighting to work with large files #1387

@hyangah

Description

@hyangah

gopls implements semantic token provider APIs and helps overcoming limitations in TextMate grammars.

https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide

This is currently not enabled by default. One of the concern is the overhead when working with a large go file.
See golang/go#45313 for discussion.

DocumentRangeSemanticTokensProvider can be a way to address this concern and gopls already implements textDocument/semanticTokens/range. Unfortunately, I am seeing VSCode is issuing both range and full queries for a document (Extension version v0.23.3). Investigate if there is a way to avoid full range queries, at least for a large document.

[Trace - 11:01:50.427 AM] Sending request 'textDocument/semanticTokens/range - (6)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/projects/s/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":11,"character":1}}}
 
 
[Trace - 11:01:50.524 AM] Received response 'textDocument/semanticTokens/range - (6)' in 97ms.
Result: {"resultId":"2021-03-31 11:01:50.524046 -0400 EDT m=+1.955781130","data":[0,0,7,15,0,0,8,4,0,0,2,0,6,15,0,1,2,3,0,0,1,2,4,0,0,3,0,4,15,0,0,5,4,12,2,1,1,3,0,0,0,4,7,12,0,0,8,7,18,0,1,1,4,0,0,0,5,5,12,0,0,6,2,19,0,0,2,1,21,0,0,1,4,0,0,0,5,6,8,4,1,1,3,0,0,0,4,7,12,0,0,8,5,18,0]}
 
 
[Trace - 11:01:50.624 AM] Sending request 'textDocument/semanticTokens/full - (7)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/projects/s/main.go"}}
 
 
[Trace - 11:01:50.625 AM] Received response 'textDocument/semanticTokens/full - (7)' in 1ms.
Result: {"resultId":"2021-03-31 11:01:50.625103 -0400 EDT m=+2.056838302","data":[0,0,7,15,0,0,8,4,0,0,2,0,6,15,0,1,2,3,0,0,1,2,4,0,0,3,0,4,15,0,0,5,4,12,2,1,1,3,0,0,0,4,7,12,0,0,8,7,18,0,1,1,4,0,0,0,5,5,12,0,0,6,2,19,0,0,2,1,21,0,0,1,4,0,0,0,5,6,8,4,1,1,3,0,0,0,4,7,12,0,0,8,5,18,0]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions