solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Neovim won't auto-complete at end of file

Open kputnam opened this issue 7 years ago • 2 comments

class Foo
  def bar; end
  def foo; end
end

Foo.new.<autocomplete works here>
Foo.new.<autocomplete has no suggestions here>

kputnam avatar Dec 29 '18 20:12 kputnam

This could be a separate or related issue. It seems autocomplete acts strangely when trying to complete a partially-entered method name. For example

[].<autocomplete works here>
[].a<autocomplete doesn't suggest any?, assoc, at but suggests bsearch, clear, rotate, rotate!, to_a, to_ary, is_a?, untaint, equal?>
[].as<autocomplete fails, an exception is caught and console shows "Skipping invalid offset at line 2 character 5">

kputnam avatar Dec 29 '18 20:12 kputnam

This seems related to a neovim issue that I saw a while ago, but I can't find it anymore. From what I remember, it has to do with how LSP clients synchronize open documents.

When a client sends a textDocument/didChange message to a server, the message can be as specific as "add a dot to this line of code" or as broad as "replace the entire document with this new version". In the best case scenario, the client sends a message that only touches a specific location in the document. But the LSP is a lot more forgiving. The client can send an entire document to replace the current version, even if the only change is a dot on one line. My understanding is that neovim does the latter, always replacing the entire document at once. In the former case, Solargraph can correct for parsing errors when it knows where the change occurred. In the latter, all bets are off...

...to a point.

I think there's a way to make changes work the same way with full syncs as incremental syncs, but it'll take some effort. Also, if my understanding of syncs in neovim is incorrect, someone please let me know. As I've mentioned elsewhere, I'm not a neovim expert.

castwide avatar Dec 30 '18 03:12 castwide

This should be resolved as of support for diffs in full syncs. If it's still a problem, please feel free to open a new issue.

castwide avatar Aug 14 '22 07:08 castwide