racer
racer copied to clipboard
Do not complete in comments outside code tags
I'm not sure whether this is a racer or a plugin issue.
If you use the Emacs plugin, you need to set (setq racer-complete-in-comments t)
@marsam thanks for your help, but I'm having this issue in 1) Atom and 2) VSC while the latter one recently got rls support
VSCode-Rust seems to have fixed this problem in both racer and RLS modes.
As a user, my perspective on this issue is mixed:
- I really don't like getting completions after typing
.
in a comment outside a code-block. Trying to end a comment line with a period is especially annoying, since the Enter key inserts the highlighted suggestion. - I like getting completions after typing
::
- that doesn't appear in my comments unless I'm writing a path, even if it's outside a code block. - I really like getting completions within inline or block code.
As a racer maintainer, I'd be interested to hear from @nrc, @KalitaAlexey and @qzed on this point. It would be easier for racer if the editor plugins handled deciding whether or not to request completions, but there may be a compelling reason that's infeasible or undesirable that I'm not seeing.
I agree this seems like an editor issue.
Hmm; I'm not convinced this is an editor issue. For something like VSCode which is just a text editor, it seems strange for it to require semantic knowledge of the file being edited. Handling this complexity in Racer means editor plugins could simply trigger completions on ::
and .
, without having to do any parsing, and Racer could yield an empty response in cases where they are in a comment. Should probably be configurable, though.
OK, on consideration, perhaps this should not be a client issue. My thinking was that the RLS already has to do some of this work in other cases, but most clients are not going to have the kind of resources the RLS has so won't be able to do that. It is also nice that if Racer does this, the RLS can let Racer start a little bit earlier.
So I think the desired behavior is:
- Calling
complete
outside a single or triple backtick should find nothing - Calling
complete
inside a single backtick should complete as normal - Calling
complete
inside a triple backtick with no language annotation or annotated withrust
as the language should complete as normal - Calling
complete
inside a triple backtick with any other language annotation should find nothing
Unfortunately, I don't see a good way of doing this other than trying to parse the whole comment block; the fact that open and closing marks are the same probably precludes a naive solution.