haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Bad autocomplete in comments

Open santiweight opened this issue 3 years ago • 4 comments

I have recently been receiving autocomplete when pressing enter at the end of a sentence in a comment:

-- foo is a number.
foo = 1

If my cursor is at the full stop after "number", and I press enter, then I normally get {-# ANN annotation #-} inserted, or some random Core variable.

It would be good to only provide autocomplete outside of comments imo...

santiweight avatar Nov 28 '22 23:11 santiweight

Some clients have the ability to turn this off, e.g. https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L1579

It's a little unclear what we should do, but we should probably indeed turn this off if we're in comments.

Note that there are some legitimate uses for it, e.g. if you're writing Haddock you might want to autocomplete a type name to link to it.

michaelpj avatar Nov 29 '22 14:11 michaelpj

My 2c: I can count on one hand the number of times recently where I have wanted to autocomplete a name in a Haddock like this recently, but autocompleting on sentences at the ends of lines when not desired happens extremely frequently. After being annoyed by this for a couple years, I've started writing long comments in a different editor and pasting them back. I'd much rather this be turned off if we are in comments, and configure a keystroke to offer completions if I really want them.

JKTKops avatar Apr 21 '25 06:04 JKTKops

So what we need is something like: do not perform autocompletion in comments after a period (because it is much more likely to be a full stop than a code snippet).

dschrempf avatar Apr 21 '25 07:04 dschrempf

Yeah probably. I am still somewhat confused about why this doesn't seem to work already with the clients that claim to not trigger completion in comments, but I do think just blanket not providing suggestions inside comments would be an improvement.

michaelpj avatar Apr 21 '25 09:04 michaelpj