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

Features from Atom: Improve hints and search while typing #5457

Closed
Digitalone1 opened this issue Jun 20, 2022 · 8 comments
Closed

Features from Atom: Improve hints and search while typing #5457

Digitalone1 opened this issue Jun 20, 2022 · 8 comments

Comments

@Digitalone1
Copy link

Problem description

Since Atom sunset, I'm looking for an alternative. Unfortunately there's none at the moment. Anyway as I shared on vscode issue tracker, I'd like to report here what can be implemented in Sublime to get it better and maybe be an option for me and others in the future.

Sublime does not:

  • Suggest php tags
    Schermata del 2022-06-20 18-24-56

  • Suggest php contidional syntax. Not the simple if (), but the conditional statements that can mixed with HTML code.
    Schermata del 2022-06-20 18-25-25

  • Hint words from any part of the code, like comments, not only variables and function names.
    Schermata del 2022-06-20 18-28-10

  • Suggest class syntax for Javascript
    Schermata del 2022-06-20 18-31-02

  • Search also in other opened files, not only in the current one. Maybe also in other languages, but just showing hints from other opened files of the same language would be a good starting point. VS Code is supposed to have an option to do that, but it's currently broken and don't work. When I gave a look into Sublime configurations, didn't find something similar.
    Schermata del 2022-06-20 18-37-27

Preferred solution

Implement the features shown above already available in Atom, if they're really missing.

If I'm wrong and the same result can be achieved in Sublime, please explain. Thanks.

Alternatives

Using Atom at the moment.

Additional Information

No response

@jfcherng
Copy link

jfcherng commented Jun 20, 2022

Suggest php tags
Suggest php contidional syntax. Not the simple if (), but the conditional statements that can mixed with HTML code.

ST has those completion but somehow they have to be triggered manually in your provided context.

Update: Oh... it turns out that when the view is empty, the top scope is not embedding.php text.html but only embedding.php so when you type, ST uses embedding.php to search for auto completions. This looks like a syntax definition bug to me.

@deathaxe
Copy link
Collaborator

Suggest php tags

Just typing php and hitting tab works great on my end. (ST4126 & ST4134)

Animation

ST just doesn't bother you with a completion panel with just one item.

Suggest php contidional syntax. Not the simple if (), but the conditional statements that can mixed with HTML code.

Same here, just type if and hit tab key.

Animation

Whether auto-completion panel is triggered while typing or not depends on auto_complete_selector setting, which doesn't include text scopes such as text.html by default. It's enabled within tags (meta.tag) only. HTML tag completions are triggered by typing < (via auto_complete_triggers setting)

Animation

Completion panel can be enabled in HTML code by ...

"auto_complete_selector": "meta.tag, text.html, source - comment - string",

... which ends up with

Animation

Suggest class syntax for Javascript

ST shipps various snippets out of the box, but as those are often part of personal taste with mixed feedback about their presence its unlikely more of them will be added.

You can always and easily add more if needed by either looking for snippet related packages on https://packagecontrol.io/ or crafing your own. (HOWTO: https://docs.sublimetext.io/guide/extensibility/snippets.html)

Search also in other opened files, not only in the current one ...

Auto completions use indexed variables to add kind info, but only for tokens which already exist in current buffer. It's controlled via auto_complete_use_index setting.

The main argument for not doing more (listing all relevant tokens from index, ...) have always been performance.

The best option to get well IntelliSense like completions is LSP and corresponding language specific helper packages (e.g. LSP-typescript at the moment.

@Digitalone1
Copy link
Author

Digitalone1 commented Jun 21, 2022

Good to know that Sublime makes the completion hitting the tab, but this is not very user friendly. One have to be aware early that the editor has such suggestions. For new users who does not know, it's more like a trial and error. I prefer the panel is always shown, even with one item.

You can always and easily add more if needed by either looking for snippet related packages on https://packagecontrol.io/ or crafing your own.

Crafting my own snippet is a very good feature I'd like to try.

Auto completions use indexed variables to add kind info, but only for tokens which already exist in current buffer. It's controlled via auto_complete_use_index setting.

The main argument for not doing more (listing all relevant tokens from index, ...) have always been performance.

I don't get it. Are you saying the search is limited to variables and functions in the current file only because of performance reasons? That's unfortunate because Atom can search everything out of the box even if it's an IDE written in Javascript on Electron.

Anyway if I set

"auto_complete_selector": "meta.tag, text.html, source - comment - string"

I suppose I would be able to search in comments, but it's still not working.

@deathaxe
Copy link
Collaborator

deathaxe commented Jun 21, 2022

Are you saying the search is limited to variables and functions in the current file only because of performance reasons?

I can't remember of any discussions about gathering completions from different open files, but core devs argued not to use indexed symbols is for performance reasons, yes. It has to do with the quite generic approach of indexing tokens and the lag of deep knowledge about semantics. Lists of completions would therefore probably be huge in larger projects with lots of false positives and/or noice.

I am not too happy with it, too, but LSP is a good alternative most of the time.

That's unfortunate because Atom can search everything out of the box even if it's an IDE written in Javascript on Electron.

Sublime Text users have much higher expectations with regards to speed and snappiness than any Electron app could ever deliver. Waiting more than 100ms for results is often unnaccepted and ends up in heavy discussions. ST is not an IDE either. It calls itself a code editor.

I suppose I would be able to search in comments

Nope. It just controls when auto completion panel is displayed automatically while typing. What words are picked up from buffer is fully up to ST. I am not aware of any possibility to tweak that behavior, but comments and strings are handled special in many ways.

@BenjaminSchaaf
Copy link
Member

Hint words from any part of the code, like comments, not only variables and function names.

Word completions can be used by disabling index-based completions, see the "auto_complete_use_index" setting.

Search also in other opened files, not only in the current one. Maybe also in other languages, but just showing hints from other opened files of the same language would be a good starting point. VS Code is supposed to have an option to do that, but it's currently broken and don't work. When I gave a look into Sublime configurations, didn't find something similar.

Index-based completions provide this feature. It works on a project-basis by indexing all your files in order to provide context-relevant completions.

We use issues for tracking specific features, so this kind of "wishlist" issue hampers that. As such I'm going to close it. If you have any more specific feature requests please post them as separate issues.

@deathaxe
Copy link
Collaborator

deathaxe commented Jun 29, 2022

Index-based completions provide this feature. It works on a project-basis by indexing all your files in order to provide context-relevant completions.

My every day experience with index based completions is the following:

Completions pickup kind info from index, but I haven't seen any words being provided by index unless that word already exists in current buffer. Means, "my_func" is only provided as completion if it already exists in current view/buffer (like word completions). If it is found in index, completions also display kind info.

I've never seen ST suggesting words from other open files (or index), which don't already exist in current buffer. I am pretty sure jps called that working as expected due to performance considerations at some point during ST4 dev cycle.

The way ST currently seems to pick random completions from index is one of the biggest show stoppers of this function, IMHO.

Note: I rely on ST's completions/goto.../ in my every day work as there are no other tools which support the CNC/PLC sources I work with. So I am faced with its limitations often.

To proof that, have a look at the following screencast.

  1. The variable PALNO is indexed (so can navigate to it via Goto Symbol in Project).
  2. Opening a new source file and start typing PAL returns static completions only. Even re-triggering completions via ctrl+space doesn't fix it. (Note: I even keep the source it is defined in open!)
  3. Once PALNO exists in current file, it is provided via completions including kind info.

Animation

Depending on size of source and already used tokens it results in a pretty random picking completions experience!

Related with #5041

@BenjaminSchaaf
Copy link
Member

@deathaxe I can't reproduce this, I'm definitely getting suggestions from other files in the project in a new unsaved file.

@deathaxe
Copy link
Collaborator

deathaxe commented Oct 14, 2024

Certainly not until the same word exists in current file. (Actually, current view being unsaved or representing a file doesn't really matter)

Maybe there's something wrong with my package, but I've seen exact same behavior in other languages as well.

Steps to reproduce:

  1. setup vanilla ST4183

  2. install CNC Sinumerik

  3. Open debug_completions folder from attached ZIP file
    debug_completions.zip

  4. create a new file

  5. Hit ctrl+shift+P to learn about a list of globally available symbols (some macros and variables defined in files located in def.dir) We can't even assign kind symbols to variables in symbol lists, so it looks a bit broken due to missing icons.

  6. return to empty file

  7. start typing one of the symbols (e.g. start with _WMM)

    If index based completions would work as anyone expected, completion panel should list all symbols starting with _WMM.

    It does however not display anyhting.

  8. Paste e.g. _WMM_TH_DIAM into the view

  9. start typing _WMM again

    Now _WMM_TH_DIAM is suggested including its kind info.

And this is what everyone calls a bug, because it is expected to see suggestions for all global symbols, not just those which already exist in current buffer.

It should probably be posible to specify selectors for which symbols to suggest from index, because in a multi-language project I probably don't want to see suggestions from JavaScript in a PLC cylce, but maybe CSS classes in HTML or vice versa.

At least an API end point to query index for various aspects such as selectors, kinds, etc. to be able to write custom completion plugins leveraging ST's index.

A build-in configuration based solution would however perform way more performant, I guess. We'd just need a wy to express relationships.

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

4 participants