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

Snippets not working as expected in 4107 #4254

Open
schuette opened this issue May 26, 2021 · 16 comments
Open

Snippets not working as expected in 4107 #4254

schuette opened this issue May 26, 2021 · 16 comments

Comments

@schuette
Copy link

Description

After updating to new version, snippets with the same tabTrigger are being ignored except for the last one alphabetically.

Steps to reproduce

  1. Install these 4 snippets - https://share.getcloudapp.com/jkuPg97Q
  2. Type div and hit tab key

Expected behavior

<div class="name"></div>

Actual behavior

<div id="name"></div>

Environment

  • Build: 4107
  • Operating system and version: [macOS 10.15.7
@deathaxe
Copy link
Collaborator

They are still there:

Animation

Two things have changed:

  1. Auto completion now respects "auto_complete_selector" under all circumstances. Normal text.html scope (as part of text) is not part of the completion selector. Thus auto completion popup doesn't show up automatically while typing.
  2. The functions insert_best_completion and replace_completion_with_next_completion (the latter one is triggered when hitting tab after a word in html) no longer exist. Those were condenced into normal auto-completion functionality.

So hitting tab right after div just inserts the whatever ST condsiders the best candidate. To display the completion panel you'd need to hit ctrl+space

The following settings also control whether snippets are sugessted in auto completion at all or only when explicitly requesting them.

	// Snippets will not be included in the auto complete when this is
	// false. They can still be triggered by typing their tab trigger in, and
	// pressing tab when auto complete is not showing.
	"auto_complete_include_snippets": true,

	// When this is set to false, snippets won't be present in the auto
	// complete dialog when typing, instead they'll only be shown in the auto
	// complete dialog when it's explicitly triggered
	"auto_complete_include_snippets_when_typing": true,

If you want auto completion panel being displayed while typing you might want to tweak auto_complete_selector by adding text.html like so:

	"auto_complete_selector": "meta.tag, text.html, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",

@schuette
Copy link
Author

Brilliant. Thank you!

@PierBover
Copy link

I've set both settings to true but still some snippets don't appear in the suggestions.

"auto_complete_include_snippets": true,
"auto_complete_include_snippets_when_typing": true

I have this snippet with the log tab trigger:

<snippet>
	<content><![CDATA[
console.log(${1:something});
]]></content>
	<tabTrigger>log</tabTrigger>
	<scope>source.js, source.jsx, source.ts, source.vue</scope>
	<description>console.log()</description>
</snippet>

But it's nowhere to be found:

image

To actually trigger the snipper I have to close the autocompletions with ESC and then press tab. This is really annoying.

@deathaxe
Copy link
Collaborator

The amount of completion items which are added to the popup has been limited. My hunch is that those snippets popably haven't been selected due to several other candidates being judged more relevant. Not to call it a solution but hitting ctrl+space in exactly the situation of the screenshot should add the snippet as a snippet whose trigger exactly matches the typed word has maximum relevance.

@PierBover
Copy link

Not to call it a solution but hitting ctrl+space in exactly the situation of the screenshot should add the snippet as a snippet whose trigger exactly matches the typed word has maximum relevance.

The snippet doesn't appear either when using ctrl+space. In fact, nothing happens when doing that.

I've explicitly added this to my key bindings to test this out, but nothing.

{ "keys": ["ctrl+space"], "command": "auto_complete" }

These are my key bindings:

[
	{ "keys": ["super+v"], "command": "paste_and_indent" },
	{ "keys": ["super+shift+v"], "command": "paste" },
	{ "keys": ["super+alt+down"], "command": "duplicate_lines" },
	{ "keys": ["super+alt+up"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
	{ "keys": ["alt+space"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
	{ "keys": ["super+shift+a"], "command": "find_all_under" },
	{ "keys": ["alt+minus"], "command": "jump_back" },
	{ "keys": ["alt+shift+minus"], "command": "jump_forward" },
	{ "keys": ["super+f"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
	{ "keys": ["super+ctrl+left"], "command": "fold" },
	{ "keys": ["super+ctrl+right"], "command": "unfold" }
]

@rchl
Copy link

rchl commented May 26, 2021

Does it appear in the list if just type lo instead of log?
(thinking of possibility that this is somewhat related to #4084)

@PierBover
Copy link

Does it appear in the list if just type lo instead of log?
(thinking of possibility that this is somewhat related to #4084)

Hmmm no, it doesn't appear either.

image

So I decided to remove a bunch of packages and it's working now:

image

After reinstalling some of the packages it seems the culprit was the TypeScript package.

@deathaxe
Copy link
Collaborator

Keep that package away from ST. It's bloated bullshit.

JSX / TS syntax is supported out of the box. Completions may be accomplished via LSP and LSP-typescript.

@deathaxe
Copy link
Collaborator

Not sure if at least https://forum.sublimetext.com/t/user-snippets-not-working-properly/57942 is to be treated as bug.

@deathaxe
Copy link
Collaborator

@vovkkk
Copy link

vovkkk commented Jun 3, 2021

Command expand_snippet does not work in 4107 at all, although default keybindings bind it to the tab key.

Command auto_complete ignores settings auto_complete_include_snippets and auto_complete_include_snippets_when_typing.

Over all, it seems like snippets support is broken.

@shaunmichaelwalker
Copy link

Removing the TS package solved this for me!

@theodorebear
Copy link

@shaunmichaelwalker yes! removing TypeScript package immediately brought back my snippets into autocomplete.

I even removed my previous attempt adding:
"auto_complete_include_snippets": true,
"auto_complete_include_snippets_when_typing": true,
"auto_complete_selector": "meta.tag, text.html, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
to User Preferences json and it still worked.

In 4107, missing snippets in autocomplete seems very linked to TypeScript package.

I added "TypeScript Syntax" package instead, and i get my syntax highlighting working with my snippets! All is well.

@rchl
Copy link

rchl commented Jun 28, 2021

ST 4xxx includes built-in typescript syntax. You should remove the TypeScript Syntax package also.

@burt202
Copy link

burt202 commented Aug 16, 2021

Had a similar problem with my snippets and replacing the Typescript package with LSP and LSP-typescript did the trick. Thanks for the suggestion @deathaxe

@nychang
Copy link

nychang commented Sep 23, 2021

Thank you @deathaxe! Removing the TypeScript package also brought back my snippets. 🙌 🏆

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

No branches or pull requests

9 participants