LSP client: Non-alphanumeric characters in the middle of completions

Hi!

Again, thanks for your great work on the editor!

I’m looking for a bit of guidance. I am getting completions back from an LSP server, where the language grammar allows special characters in the middle of a word. For instance, array:length is a function name, in which : is part of the name. It should be treated as a single word.

I can make CodeMirror highlight the whole array:length on double click by including : in wordChars in my language definition. This works fine.

However, if I type array:, the autocompletion window closes when typing :. As far as I can see this is because the completions in the LSP client have this line:

validFor: prefixRegexp(result.items),

The prefixRegexp function has generated a regexp of special prefix characters allowed. But if no prefixes are detected, it falls back to the default pattern /^\w*$/ here.

So, for my question: Is there some way to use another pattern for validFor in the LSP client completion config? Or instead allow special characters in the whole word somehow?

Thanks!

Does this patch look like it solves your problem?

I just tested it. Works great! Thank you!

Would it be possible to tag a release of the LSP client within the coming days?

Of course. I’ve tagged a 6.2.0.

1 Like