eclipse-corrosion / corrosion

Eclipse Corrosion - Rust edition in Eclipse IDE
Eclipse Public License 2.0
219 stars 31 forks source link

auto complete isn't working right #399

Closed ghost closed 2 years ago

ghost commented 2 years ago

to_owned isn't coming up, don't know whats going on image

akurtakov commented 2 years ago

I don't understand what the exact issue is. Would you please share a reproducer with clear explanation what is expected, link to docs if 3rd party API and etc?

ghost commented 2 years ago

uh... the autocomplete is not serving the purpose it was intended to serve? I mean I don't think it could be anymore plain than that do you see "to_owned" appearing in the auto complete list despite having been mostly spelled out that would be the point. If I have to type out the whole entire word "to_owned" why did I even bother trying to use intellisense? Sure if "to_owned" wasn't a valid function call but it actually is in this case but this is not the only time I've seen intellisense fall short. Why?

ghost commented 2 years ago

it obviously knows its valid if you hover over it (had to type it out manually) so why is it not auto-completing Screenshot_20220302_011009 ?

akurtakov commented 2 years ago

I get that part but in order to analyze why it happens in this case it would be easier if you share code that reproduces it so no time is lost trying to come up with example you already have.

ghost commented 2 years ago

in order to analyze what happens you can simply go call 'to_owned' on a string, when you start typing to_owned if it does not appear in your autocomplete, you have successfully reproduced the issue.

akurtakov commented 2 years ago

I just tried and the entry is there but there is no filtering so it's far far down in the list.

ghost commented 2 years ago

@akurtakov do you guys have a matrix chat or something where we could discuss a little more off topic? I'd actually be willing to dedicate as much as 40-60 hours a week of development towards getting this project working as seemlessly as what you would expect with Visual Studio or intellij. It really needs to be done. It's really going to make rust in general a more attractive option for adoption, but it's vital to me to have tools that are on par like monodevelop was until Microsoft bought Xamarin and sabotaged it because they want people to pay money for visual studio. Understandably given that I can't ever go back to C#, realistically I can't because I'm not going to pay money for tools that I've already paid thousands for over the last decade and a half.

I need tools that work is the bottom line though, rust is a much more modern language choice and eclipse-corrosion isn't a bad start and that's what I'd like to be using. I have another option which is I could start trying to fix this nightmare:

https://github.com/dotdevelop/dotdevelop

Since I know that I could probably be just as productive with it in most of all of my development cases; there's like a really small margin of cases in which using a language like golang or even rust specifically is vital because of its executable portability or memory management characteristics (whatever the case may be.) In a perfect world I would much prefer something like rust as a general purpose language in the sense that I have used C# as a general purpose language for years.

That being said I have pretty high expectations for an IDE and I can possibly offer you a lot of insight as to how it can help me work faster and more efficiently.

EDIT

More specifically I have things like visual studio and intellij rider here both working and I could draw a lot on the intellisense point and show you some specific things done better with corrosion. It'd be easier if we could chat on Matrix or something

mickaelistria commented 2 years ago

@clandestinenetworks Eclipse LSP4E (client support for Language Server Protocol, that rust-analyzer and Corrosion are using to communicate) does not apply any form of filtering when the Language Server returns a comptetion result that sets isImcomplete=false like rust-analyzer does. From the spec and the various language servers, it's not obvious what should be done in the case of isIncomplete=false. Most language server do apply filtering and sorting on their end and it works great. rust-analyzer is a bit alien here, that doesn't mean it's incorrect though (I sincerely don't know whether it is or not). I suggest that in parallel, you report the issue to rust-analyzer returning too much results for this case. About organizational discussion that are not focused on a particular technical issue or enhancement, the best channel is to use this mailing-list: https://accounts.eclipse.org/mailing-list/corrosion-dev . This can be used to communicate the various efforts, goals and project challenges and opportunities.

ghost commented 2 years ago

@mickaelistria

Thanks, you reminded me to look at how intellij rust's completion works and it looks like their native rust analysis is proprietary and I found this:

https://github.com/intellij-rust/intellij-rust/issues/964#issuecomment-627987541

If anybody could say definitively whether LSP4E is a stretch from working correctly with rust-analyzer it would probably be @matklad and I'll reach out to him to see if he could offer any insight in a moment.

I actually forgot that RLS was something different from rust-analyzer. Does RLS work better? From what I can gather from that post RLS doesn't offer completion for macros and rust-analyzer does. Moreover, as @matklad pointed out it for intellij that it could be potentially useful for intellij to use it's own native completion and to additionally use rust-anaylzer for macros.. so perhaps both RLS and rust-analyzer could be used for corrosion?

mickaelistria commented 2 years ago

Does RLS work better?

No. RLS is kind of deprecated.

mickaelistria commented 2 years ago

I think LSP4E is faulty here as it simply skips filtering when isIncomplete=false and the spec doesn't make a difference about filtering for that case, so it should behave consistently independently of isIncomplete. I'm working on a fix at https://github.com/eclipse/lsp4e/pull/85

matklad commented 2 years ago

Specific reponses:

General thoughts:

It looks like what is happening here is that indeed the server (rust-analyzer) expects the client to do the filtering based on filterText and that the client doesn't do that. Haven't looked in details though.

mickaelistria commented 2 years ago

@matklad thanks, particularly for the link to https://github.com/rust-analyzer/rust-analyzer/issues/7935 . I'm glad to see that corrosion and rust-analyzer share the same feelings regarding this issue. My comment earlier was wrong, I was talking about the case of isIncomplete=true, that makes LSP4E skip filtering. https://github.com/eclipse/lsp4e/pull/85 is supposed to fix that and make LSP4E behave closer to other clients here.

matklad commented 2 years ago

@clandestinenetworks a better place to ask general Rust dev-tooling questions would be the IDE topic on the Rust forum: https://users.rust-lang.org/c/ide/14. Regarding debugging, yes, at the moment for Rust that is only available in paid products like CLion or IntelliJ Ultimate.

mickaelistria commented 2 years ago

I'm removing all the messages that discuss IJ or other products strategies, as they are not really helpful for resolution of this issue, nor for Corrosion development in general.

mickaelistria commented 2 years ago

@clandestinenetworks Try installing latest LSP4E build from http://download.eclipse.org/lsp4e/snapshots/ which should include a fix for this issue.

ghost commented 2 years ago

@mickaelistria looks good and thank you. Also I spent this morning figuring out how to build corrosion on my dev box. I just installed the plugin directly as you suggested but just so that I understand is LSP4E included in the build for corrosion? I have a couple of other points I'd like to bring up here about completion and I'll try to show you what I mean.

Screenshot_20220302_142958

You'll have to bare with me on this because this example is taken from a C# IDE but:

Screenshot_20220302_144755

all of the standard members of IDictionary are shown first, I believe it does have an order of precedence in which members of a class are shown first (before interface members.)

And then as you scroll down the list to the bottom you will see all of the short options (for expanding it to a for loop and so forth) are all the way at the bottom:

Screenshot_20220302_145010

Screenshot_20220302_150835

can it not make a recommendation based on that? Often times in intellij rider for C# it will make recommendations for things like anonymous functions:

Screenshot_20220302_150416

which is insanely helpful when generics are involved because rather than just looking at just a generic signature, it shows the applicable parameters for the usage

The other thing I notice with intellij that really helps the readability is the use of text emphasis (bold, italic, etc.) Also not entirely unlike rust, it's common to create instances with the new keyword which the IDE has a shortcut for when using the access operator on the class in the static context:

Screenshot_20220302_151045

although this does not complete a method call to a method new() but rather inserts a new keyword and constructor call. I'm wondering though if there's something to be said for the rust IDE to do the reverse (where when you type new before a name like new String or new Box to get an autocomplete list of names that support ::new?

ghost commented 2 years ago

Another thing I've been noticing that is screwing me up is when you do new like from this list: Screenshot_20220302_152124

it throws in this arbitrary variable 'x' which isn't even defined anywhere in my scope: Screenshot_20220302_152230

Here's what I would do, rather than inserting variables, get the signature of the fn new and show a hint:

Screenshot_20220302_152425

that's really useful to me, it's saved my adhd mind a ton of time.

Another one that goes hand in hand with that is it would be nice to have a shortcut like /// which when typed automatically inserts a skeleton docblock. For C# the autogenerated docstring you get might look something like:

Screenshot_20220302_152932

and when you enter a description for the params, that description will actually show up in the function variable hint when attempting to make a function call, for example if you have

Screenshot_20220302_153148

then: Screenshot_20220302_153245

ghost commented 2 years ago

@mickaelistria sorry if that was too much but I really want to try to figure out what your guys plan for improvements are and whether or not you have any interest. Given the complexity that I know is involved in building expression evaluators and code generators I'd probably also like to run this by @matklad and see what he thinks about it since rust-analyzer seems to be the thing to do but I have to wonder how he feels about it given that 2 years ago he didn't seem entirely confident that rust-analyzer would amount to anything more than something experimental. And that's totally fair, I just want to make sure.

I'm 99% sure myself that if this isn't in anybody's interest that I (really don't want to) but will fork whatever I need to in order to accomplish what I would like to see done. I think there really needs to be a long term, reliable IDE for rust that I can always use productively and that I can teach others how to use productively that doesn't get completely derailed by having to search out and install a dozen different packages, just a sane set of tools in one single distribution that (within reason) are always the same that work the way that I expect them to (best effort.)

VS.code has proven to be the one editor for everything for which nothing works consistently and the things that people say works don't. I don't want to mess with a market place or an app store. I want to install rust-ide and that's it. I'm a really big fan that you added the ability to install rust / rust up and to install rust-analyzer from within the ide itself; that's good because I don't want to install those things or remember how to. In fact I would much prefer if it just automatically did it, and left the option open to change to using some other toolchain somewhere else in the userland manually if the case needs to be.

If you're not interested, can you at least understand? Is that not inherently what integrated development environment means? I don't think too many people do and I should know because I've used everything from Turbo C, Metrowerks Codewarrior, Visual Studio.. uh I can't even imagine how you would emulate the kind of modality that you need to render the kind of intellisense I've shown you so far..

I do have trouble recalling key bindings when I'm actually writing code so it's nice to have a visual representation of a start / stop / step debugging / set breakpoints too that I still am not seeing in spacemacs. More importantly though spacemacs isn't something that I can teach people how to use or that I can reliably use collaboratively.

ghost commented 2 years ago

I can definitely appreciate but I can't take it seriously.. for a number of reasons. I wish people would stop telling me that they use neovim and that it's "good enough" because I don't care Screenshot_20220302_160316

I will point out though that this one actually expands the list to better fit some of the wider options some as you scroll down:

Screenshot_20220302_160938

corrosion could also probably show a lot more in terms of autocomplete:

Screenshot_20220302_161229

mickaelistria commented 2 years ago

@clandestinenetworks What gets returned and inserted by the completion is part of rust-analyzer and issues should be reported there. Corrosion just uses rust-analyzer and doesn't own nor maintain the content of completion. The only thing that are on the client side is mostly filtering and sorting, that can still be improved; and the "snippets" which would actually also probably more useful on server-side (I'm about to open a PR to at least reduce their priority). For those issues on client-side, please open separate dedicated issues and we'll investigate. But really, it looks like most of the issues you face would require development and contribution to rust-analyzer, which should be a more comfortable project for you to work with if you're familiar with Rust, and also a more "profitable" project as improvements in rust-analyzer would cascade to all IDEs/Editors at once.