Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete showing errors for the member of an object or not showing at all #177

Open
jmgomez opened this issue Sep 23, 2020 · 3 comments

Comments

@jmgomez
Copy link

jmgomez commented Sep 23, 2020

Most of the time intellisense does not list the properties of an object (name and age), in this case it does show it up but listed as an error.

The example is taken from the second part of the tutorial (https://nim-lang.org/docs/tut2.html) on the official webpage.

Screenshot 2020-09-23 at 16 46 10

@RSDuck
Copy link
Contributor

RSDuck commented Sep 23, 2020

that's likely nimsuggest

@jmgomez
Copy link
Author

jmgomez commented Sep 23, 2020

Din't know about it. The repo seems to be abandoned. Im a little bit worry because Im considering on investing a lot of time in Nim (making bindings for a huge cpp project) but seeing something as basic as this to fail, makes me wonder if the tooling isn't mature enough (no offense, I know time is a limited resource).

Did it work in the past? Is there something that can be done to get it working?

@RSDuck
Copy link
Contributor

RSDuck commented Sep 23, 2020

Nim is a pretty complex language. Due to the macro system if you want to reliably provide intellisense you basically need the entire Nim compiler for the nimscript interpreter, etc. For this reason the decision to put the majority of work into an unified tool to which the individual editors talk (an idea which became recently popular for other languages as well in the form of language servers) and which utilises compiler code was made, it's called nimsuggest.

Because nimsuggest utilises the compiler it stays up to date with latest language changes without much maintance (it's also in the compiler repository included). But it has some severe drawbacks. It's known for consuming huge amounts of memory, getting stuck in endless loops and generally getting more sluggish with greater project size. It's suggestion quality is like you noticed not always perfect.

Additionally this plugin has it's weaknesses as well. Earlier versions of nimsuggest were unable to handle files which weren't part of the dependency graph of a "project file" which was specified at the start. As a workaround this plugin starts a nimsuggest instance for every file, which considering the memory and processor draw I already talked about, it got a bit infamous for. Other people like this behaviour, because their projects can't be handled by a single nimsuggest instance alone. The plugin also has some half working attempts included (some of which I contribude myself 😞), for example the import suggestions. Or e.g. nimsuggest doesn't tell you which parameter of a signature you're currently filling in, I tried to implement that (it again only works for basic cases), but like with the import suggestions, it doesn't really belong here.

From my personal experience working with medium sized projects I can say that it works okay 1. if you specify a project file for this project (it's one of the plugin settings combine that with workspace specific settings in VSC) and 2. if you put back your expectation to only hovering, goto definiton, basic symbol suggestion and symbol overview. That works most of the time well enough.

There's also an attempt to implement Microsoft's language server protocol for Nim (https://github.com/PMunch/nimlsp) using nimsuggest. From what it seems to be a lot faster but that's probably because it completely ignores all code in the current workspace and suggestions, etc. only work for libraries (the last time I tried it, though there was no big progress inbetween).

Concluding intellisense for Nim is pretty neglected for several reasons. The compiler authors already have enough to do with the compiler itself. Compare that to say Java which is not only less complex, but there's also an entire team at Jetbrains working fulltime, creating tools specialised for fast response time compare to Nim where our tools utilise the compiler itself. So yeah, it's pretty sad. Things work somewhat, but it's almost not comparable to what other languages have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants