SublimeAllAutocomplete
SublimeAllAutocomplete copied to clipboard
Autocomplete for Sass variables (and CSS classes) with dashes doesn't work
We've split our Sass into multiple files; one of the files contains all our variables. The variables look like this $variable-name-example
. Unfortunately dashes seam to be a problem currently.
Testcase:
$button-color-secondary: #f00 /* will auto complete only the word $button */
$button_color_main: #0f0 /* works as expected */
Thank you for your plugin, Adrian. Keep up the good work.
I can confirm the problem: removed dash from word_separators preference, tested with version 2.0.2, build 2221. As you reported, the word never shows up in the autocomplete list of another view.
Unfortunately, this is a bug in the Sublime API implementation (extract_completions method).
It's also weird that I sometimes do get a completion in the same view. But if I try again it doesn't show up anymore. However, I always get a completion if I type past the first dash, i.e., "$button-". So, it seems not only the API is broken but also the built in autocomplete is behaving strangely with words containing dashes (and probably other chars).
NB, best thing you can probably do is open a bug report for Sublime, but I don't know what the chances are that it gets fixed (someone reported a related problem some time ago but it didn't even get a response...).
Done: http://sublimetext.userecho.com/topic/222861-/
thanks
On Thu, Aug 1, 2013 at 1:13 PM, wrndl [email protected] wrote:
Done: http://sublimetext.userecho.com/topic/222861-/
— Reply to this email directly or view it on GitHubhttps://github.com/alienhard/SublimeAllAutocomplete/issues/18#issuecomment-21966223 .
www.adrian-lienhard.ch
twitter.com/adrianlienhard
Just created temporary hack to make possible dash separated suggestions usage: https://github.com/andruhon/SublimeAllAutocomplete
I can confirm that bug
We'll we see solution in original master branch?
Thanks
I've just experienced the same thing and written it up on the forum:
http://www.sublimetext.com/forum/viewtopic.php?f=3&t=14773
Was a little confused that this fix didn't seem to have landed until I realised this is a fork and needs installing seperately. For anyone else landing here, see the install instructions: https://github.com/andruhon/SublimeAllAutocomplete
Thank you so much for the fix!
I'm still having an issue surrounding this matter. It works when auto completing a class from CSS into HTML, but when you try it the other way around; auto completing a class name from HTML to CSS it doesn't work? I've tried adding "source.html" to "apply_with_dash_hack_syntaxes" with no luck.
Thanks for all the work done to date!
@dntz ,to fix that because ST is ridiculously DUMB
- the html source is
"text.html"
even ifsource.html
works in snippets scops.
Thanks for your help @ctf0, when I bring up the autocomplete box using Ctrl+Space outside a rule set, the classes from my HTML document are now visible. Is there any way to display this autocomplete box automatically? Similar to how it works for properties and values within declarations.
if i understand u right ,i believe what u r after is that u want the same trick but for css ,well its the same thing ,open any css,less,sass ,etc.. and go to settings-more > syntax specific and add the same thing u add to the html.
I also don't see this working for SCSS variables. I create a variable in one file that is open:
$myVariable: 'Helvetica', sans-serif;
and in another SCSS file that is open, $myVariable
does not show up as an auto complete word.
It simply doesn't work at all.
Any update on this? I also found that SCSS variables don't work (in that it only suggests the first part of the name and clips off the dash):
Example: $one-two-three (expected) $one (actual)
Both the "-" and "$" have been removed form word_separators.
Seems like this is still an issue with ST3
+1 doesn't work with hyphens in ST3. But, @andruhon fork seems to work. @alienhard please merge this hack into your version?
Same problem here, Brackets do that and even show the variable value on the suggested options
any updates here? @andruhon solution not working for me...
hey guys, I solved it for me based on hacked version https://github.com/petermac-/SublimeAllAutocomplete repo
https://github.com/inomoz/SublimeAllAutocomplete - fixed for me
changed only word_regions variable
if DEBUG: print("SAA: extracting words with dashes") word_regions = v.find_all("\\" + prefix + "\w+(-\w+)+",0)
wow, thx @inomoz , you save my life.
@inomoz looks like this not working after I upgrade to the newest sublime version.
@inomoz, your repo works for me, but I had to remove -
and $
from the word separators.
This is using Sublime Text 3, build 3114.
Since the instructions are kind of all over the place, here are the steps I went through (this is on a Mac, so keystrokes might be different on your machine).
-
CMD + SHIFT + P
to open Command Palette and type "Package Control: Add Repository" and select it. -
Paste in "https://github.com/inomoz/SublimeAllAutocomplete" in the input box at the bottom and press Enter.
-
Again,
CMD + SHIFT + P
and enter "Package Control: Install Package". -
Start typing "All Autocomplete" and look for the one that specifically mentions the repo we just linked, aka, inomoz/SublimeAllAutocomplete. Select that one to install.
-
After installation, open any Sass file (I use the SCSS extension), and navigate to
Preferences
>Settings - More
>Syntax Specific - User
. In my case, this opened up a new file titled SCSS.sublime-settings. -
I copied the default
word_separators
fromPreferences
>Settings - Default
and removed the-
and$
characters. So at the end of the day, my SCSS.sublime-settings file looked like:{ "word_separators": "./\\()\"':,.;<>~!@#%^&*|+=[]{}`~?" }
-
Save that file, quit and relaunch Sublime. Everything worked after that!
You may have to do this twice if you use both .scss
and .sass
, and your final .sublime-settings
file may be different if you have further settings set within that file. Either way, the instructions should be close.
@romellem { "word_separators": "./()"':,.;<>~!@#%^&*|+=[]{}`~?" }
wow~ this works for me, thx!
@inomoz this doesn't work any more with the latest build v3120 , any chance u can update ur fork ? here are the settings
{
"apply_with_dash_hack_syntaxes": [
"source.scss",
"source.sass",
"source.css",
"text.html.basic",
"text.blade",
"source.php",
"embedding.php",
"source.js",
"source.json"
],
"return_nothing_on_empty_prefix": true,
"do_not_search_in_current_view": false
}
user-setting
{"word_separators": "./\()\"':,.;<>~!@#%^&*|+=[]{}`~?"}
I use standard version of ST3 build 3114 with word_separators
preference mentioned above and it fixed the problem for me.
@mahish only in the same view, not across open files.
Using build 3131, not seeing this in action. I don't see any SCSS completions with variables.
I have 3126 build, word seperator:
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}
~?",`
plugin All Autocomplete from PackageControl
then, if scss file with variables open, autocomplete FROM IT in other files is working
offtop: in Jetbrains IDE autocomplete working even if files not opened (I tried use ctags & plugins for this feature, no success...)
Based on this issue discussion, for some reason didn't get this in the right place. So if someone misread the whole thing like I did, here's what I did to bypass this problem.
In Preferences > Settings, add on any line:
"word_separators": "./\\()\"':,.;<>~!@#%^&*|+=[]{}`~?",
After this, it works.
Thanks @ronilaukkarinen, works great!
Thanks guys, @ronilaukkarinen instruction works great :)
The repo linked above is offline by now.