microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.48k stars 28.64k forks source link

Definition Completion is not invoked for non-word tokens (like ++ operators) when ctrl-hovering #202024

Open LordOfDragons opened 8 months ago

LordOfDragons commented 8 months ago

See https://github.com/microsoft/vscode-languageserver-node/issues/1383 .

In language server onDefinition() is not called. According to the above issue this is because VS-Code does only call definition completion on word tokens. I would like though to also show definition completion for operators like "++" and so forth.

Would it be possible to add somehow the support to call onDefinition also on non-operators?

It would be fine enough if there is added a new language server property which allows to declare a list of tokens that should trigger definition completion although they are not text tokens. Maybe something like:

additionalDefinitionTokens = ['++', '--', '+', ... ]

RedCMD commented 8 months ago

are you talking about ctrl+hover? or ctrl+click? the ctrl+hover underline (and hover) is only invoked when the language-configuration.json setting "wordPattern" matches which by default is \w+

LordOfDragons commented 8 months ago

Yes, I mean ctrl+hover

RedCMD commented 8 months ago

currently cpp specifically ignores all non-word chars https://github.com/microsoft/vscode/blob/0a284dde183e8f15b1938714e18615b1ec41831d/extensions/cpp/language-configuration.json#L27 changing it would fix this but "wordPattern" is also used for symbol highlighting, basic intellisense and a few others

maybe VSCode could add a triggerRegex to the definitionProvider(), that would overwrite the default "wordPattern" regex same as how the completionProvider() has triggerCharacters