Monnoroch / ColorHighlighter

ColorHighlighter - is a plugin for the Sublime text 2 and 3, which underlays selected hexadecimal colorcodes (like "#FFFFFF", "rgb(255,255,255)", "white", etc.) with their real color. Also, plugin adds color picker to easily modify colors. Documentation: https://monnoroch.github.io/ColorHighlighter.
https://sublime.wbond.net/packages/Color%20Highlighter
1.31k stars 130 forks source link

color_variables_files does not work #296

Open HughxDev opened 8 years ago

HughxDev commented 8 years ago

Using:

.sublime-project:

{
  "color_variables_files":
  [
    "/path/to/_colors.scss"
  ],
  "folders":
  [
    {
      "path": "/path/to/project"
    }
  ]
}

_colors.scss:

$FACEBOOK_BLUE: #3b579d;

facebook-blue

app.scss:

$foo: $FACEBOOK_BLUE;

color-highlighter

Monnoroch commented 8 years ago

The path must be incorrect. Currently it only supports absolute paths.

HughxDev commented 8 years ago

I triple-checked and it's the correct path, as well as being absolute. I actually copied the exact location from the file properties dialog box, pasted it into the .sublime-project, and then changed all slashes from Windows-style (C:\...) to UNIX-style (/C/...), which seems to be the format that Sublime Text expects. Not only that, but I also tried several variations, including keeping them as backslashes and escaping them. I even tried renaming a folder that had spaces in it in case that was causing any problems, but it didn't make a difference. It has to be something else.

akazorg commented 8 years ago

It's working fine using absolute path, on windows 7 64bit.

Try this on your .sublime-project file

{
  "color_variables_files": "/path/to/_colors.scss", 

  "folders": [{
      "path": "/path/to/project"
    }]
}

Hope it works!

mikehdt commented 8 years ago

If you're on Windows, the pathing will be a little different from what I understand. In a project I'm working on, it looks a little like this:

"color_variables_files": [ "D:\\code\\website-project.local\\client\\scss\\variables\\_colors.scss" ],

Does that help?

treechime commented 8 years ago

+1 same issue.

Tried the filepath a string and an array.

Tried using color_variables_file instead of color_variables_files.

Tried Windows style and unix style file paths (using Windows 10).

lisajwells commented 7 years ago

I got this to work on a mac by using the absolute path thus:

{
    "folders":
    [
        {
                      "path": "."
                }
    ],
       "color_variables_files": "/Users/myusername/path/to/_colors.scss",
}
Romainpetit commented 7 years ago

Unable to get this working, ST3 macOS sierra. Can we have a log in the ST console telling us what's the deal ? File not found, syntax error ...

jonsuh commented 7 years ago

I can confirm that color_variables_files does not work even when using absolute paths.

{
  "folders": [{
    "path": "."
  }],
  "color_variables_files": "/Users/username/project/assets/_sass/settings/_colors.scss"
}

macOS Sierra 10.12.14 Sublime Text 3 build 3126

jonsuh commented 7 years ago

I figured out what’s going on.

For color_variables_files to work in the .sublime-project file, you need to save your directory as a “Sublime project” (From the menu, Project > Save Project As) (it creates a *.sublime-workspace file) and always open projects as a “Sublime project.”

However, I think the whole “Sublime project” thing is useless. So my forked version https://github.com/jonsuh/ColorHighlighter uses a .colorhighlighter file that’s structured like this:

{
  "color_variables_files": [
    "/absolute/path/to/project/assets/_sass/settings/_colors.scss"
  ]
}

It doesn’t require you to save and open a folder as a “Sublime project” and color highlighting for Sass variables work again (!!!) even if your variables are in a separate file and you’re not @importing color variables in every Sass file (I use one manifest file so it’s redundant to @import in every file).

image

Romainpetit commented 7 years ago

Amazing job @jonsuh !

Finally got it working using your fork. I think you solution deserves a PR in this repo instead. 🙌 Kudos to you !

jonsuh commented 7 years ago

@Romainpetit Great to hear that it’s working for you! Thanks for letting me know.

I opened up a PR for the added feature https://github.com/Monnoroch/ColorHighlighter/pull/355. This is only the 2nd time that I’ve ever written anything in Python, so it may need improvement from more experienced devs, but hopefully we can get the feature added.

johny-gog commented 7 years ago

At first I was putting "color_variables_files" inside of "folders" key for some reason...

The default .sublime-project (in the project root, didn't check other locations of .sublime-project) worked for me:

{
    "color_variables_files": [
        "/Users/myuser/project/styles/_variablesFilename.scss"
    ],
    "folders": [{