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

Autocomplete for Sass variables (and CSS classes) with dashes doesn't work #18

Open
woerndl opened this issue Jul 30, 2013 · 32 comments
Open
Labels

Comments

@woerndl
Copy link

woerndl commented Jul 30, 2013

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.

@alienhard
Copy link
Owner

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...).

@woerndl
Copy link
Author

woerndl commented Aug 1, 2013

@alienhard
Copy link
Owner

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//issues/18#issuecomment-21966223
.


www.adrian-lienhard.ch

twitter.com/adrianlienhard

@andruhon
Copy link

andruhon commented Nov 5, 2013

Just created temporary hack to make possible dash separated suggestions usage:
https://github.com/andruhon/SublimeAllAutocomplete

@ArmorDarks
Copy link

I can confirm that bug

We'll we see solution in original master branch?

Thanks

@charlesroper
Copy link

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!

@dentz
Copy link

dentz commented Jan 10, 2014

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!

@ctf0
Copy link

ctf0 commented Sep 24, 2014

@dntz ,to fix that because ST is ridiculously DUMB

  • the html source is "text.html" even if source.html works in snippets scops.

@dentz
Copy link

dentz commented Oct 29, 2014

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.

@ctf0
Copy link

ctf0 commented Oct 29, 2014

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.

@Jakobud
Copy link

Jakobud commented Dec 18, 2014

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.

@ghost
Copy link

ghost commented Feb 26, 2015

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.

petermac- added a commit to petermac-/SublimeAllAutocomplete that referenced this issue Mar 8, 2015
@tsi
Copy link

tsi commented Jun 28, 2015

Seems like this is still an issue with ST3

@importnil
Copy link

+1 doesn't work with hyphens in ST3.
But, @andruhon fork seems to work.
@alienhard please merge this hack into your version?

@RAFA3L
Copy link

RAFA3L commented Sep 13, 2015

Same problem here, Brackets do that and even show the variable value on the suggested options

@iturdikulov
Copy link

any updates here? @andruhon solution not working for me...

@iturdikulov
Copy link

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)

@jackyon
Copy link

jackyon commented Jun 7, 2016

wow, thx @inomoz , you save my life.

@jackyon
Copy link

jackyon commented Jun 14, 2016

@inomoz looks like this not working after I upgrade to the newest sublime version.

@romellem
Copy link

romellem commented Jul 7, 2016

@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).

  1. CMD + SHIFT + P to open Command Palette and type "Package Control: Add Repository" and select it.

  2. Paste in "https://github.com/inomoz/SublimeAllAutocomplete" in the input box at the bottom and press Enter.

  3. Again, CMD + SHIFT + P and enter "Package Control: Install Package".

  4. 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.

  5. 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.

  6. I copied the default word_separators from Preferences > Settings - Default and removed the - and $ characters. So at the end of the day, my SCSS.sublime-settings file looked like:

    {
        "word_separators": "./\\()\"':,.;<>~!@#%^&*|+=[]{}`~?"
    }
    
  7. 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.

@jackyon
Copy link

jackyon commented Jul 13, 2016

@romellem
{
"word_separators": "./()"':,.;<>!@#%^&*|+=[]{}`?"
}

wow~ this works for me, thx!

@ctf0
Copy link

ctf0 commented Aug 7, 2016

@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": "./\()\"':,.;<>~!@#%^&*|+=[]{}`~?"}

@mahish
Copy link

mahish commented Aug 17, 2016

I use standard version of ST3 build 3114 with word_separators preference mentioned above and it fixed the problem for me.

@ctf0
Copy link

ctf0 commented Aug 17, 2016

@mahish only in the same view, not across open files.

@ronilaukkarinen
Copy link

Using build 3131, not seeing this in action. I don't see any SCSS completions with variables.

@iturdikulov
Copy link

iturdikulov commented Apr 26, 2017

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

@iturdikulov
Copy link

offtop: in Jetbrains IDE autocomplete working even if files not opened (I tried use ctags & plugins for this feature, no success...)

@ronilaukkarinen
Copy link

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.

@kjunggithub
Copy link

Thanks @ronilaukkarinen, works great!

@simonvomeyser
Copy link

Thanks guys, @ronilaukkarinen instruction works great :)

The repo linked above is offline by now.

@hao-lee
Copy link

hao-lee commented Jan 17, 2018

@ronilaukkarinen Thanks. It works!

@r1mm
Copy link

r1mm commented Jan 14, 2019

After this - "word_separators": "./\()"':,.;<>!@#%^&*|+=[]{}`?",
Dont work((

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

No branches or pull requests