Autocomplete Plus Snippets: How to set leftLabel, leftLabelHTML, etc


#1

hello,

I added custom snippets and it’s working fine for the most part.
However, I can’t get to work some optional parameters, namely: leftLabel, leftLabelHTML, rightLabelHTML

description works fine.

Here is the section that describes what I try to do: https://github.com/atom/snippets#optional-parameters

Thanks


#2

That functionality isn’t in Atom stable yet. It was just added as part of:

It should be available in v1.8 (as long as @Pier does the promised autocomplete-snippets PR in time :grinning:).


#3

I will do the PR today, I promise.

BTW @leedohm when is the 1.8 release planned?


#4

@Pier there is currently no ETA for v1.8 reaching either Beta or Stable.


#5

First, thanks for the quick responses.
Is there any way I can use these features once Pier has pushed them?

(I would love to use them as soon as possible)


#6

You would have to build Atom from source:


#7

@frameland another way would be to download the 2 modified packages locally and use apm to enable them as dev packages. Since those modifications are simple it should work fine. I have it working on my machine right now.

The snippets package you can get from the official repo, and my version of autocomplete-snippets will be available in a few hours from my Github. I will post the link once it’s available.

Here is a proof it’s alive!


#8

So here’s the PR: https://github.com/atom/autocomplete-snippets/pull/71

@frameland here is the modified package: https://github.com/PierBover/autocomplete-snippets


#9

@Pier
cool. how do i properly replace atomcpomplete snippets with this version?
I tried cloning, then running apm install, apm link but it seems that doesn’t work.


#10

Have you started Atom in dev mode?

atom -d

I’m not an expert, but I think you should also run apm develop autocomplete-snippets before apm install.

Edit: You can check if Atom has successfully loaded those dev packages in Setting > Packages. Scroll down to the bottom and there is a section called Development Packages.

I don’t have any in my current machine so it looks like this:

The red mark at the bottom indicates this Atom window is in dev mode.


#11

I started atom in dev mode, it shows the package under Development Packages,
but the snippet popup still looks the same.

This is my snippet:

'.source.monkey':
	'AddWidget':
		'prefix': 'AddWidget(Widget)'
		'body': 'AddWidget(${1:widget:Widget}, ${2:name:String = ""})$0'
		'rightLabelHTML': '<span style="color:#ff0">Method</span>'

#12

I’m not sure that the snippet system supports non-word characters in the prefix. Have you tried something like addw?


#13

Yes, that makes no difference.


#14

Are you sure you have the scope correct then? Can you make that snippet work in any grammar?


#15

Everything works, the popup shows up correctly and everything. But setting the leftLabel, etc. properties has no effect.
Maybe I installed the package wrong?

edit: I also tried it with other languages with the same result.


#16

Have you also enabled the snippets package in dev mode?


#17

Yes, it shows up under dev packages as enabled.


#18

Well, if you are using the correct packages I really don’t know what could be the problem.

As you can see both rightLabelHTML and leftLabelHTML do work:

This is the snippet:

	'v-text':
		'leftLabelHTML':'<span style="color:#41b883">VUE</span>'
		'rightLabelHTML':'<span style="color:#41b883">VUE</span>'
		'description':'Vue.js v-text directive'
		'prefix': 'vtext'
		'body': 'v-text="$1"$0'

Remember that whenever you change something in a package you have to reload the Atom dev window for changes to take effect.

Here are my dev packages. Since those are local don’t mind the version number.

The packages that you should be using are:


#19

If you’re suggesting that people use https://github.com/PierBover/autocomplete-snippets, then the suggested command of apm develop autocomplete-snippets won’t work out of the box. The apm develop command only clones from the registered repo for the package in https://atom.io. In this case, that would be https://github.com/atom/autocomplete-snippets.


#20

Ok, sorry for that.

I thought apm develop autocomplete-snippets enabled the package residing in ~/github/ in dev mode…