livestyle / issues

Report all your LivesStyle issues here
24 stars 1 forks source link

Think about auto-scanning dependencies #28

Open sergeche opened 9 years ago

sergeche commented 9 years ago

Providing explicit preprocessor dependencies might be a bit cumbersome for lazy people (like me). Think about a way how to automatically scan possible sources of mixins and variables for currently opened project/folder in Sublime Text

xzyfer commented 9 years ago

By dependencies do you mean @imports?

sergeche commented 9 years ago

No, @import are already scanned.

I mean this use case:

// global.css
@import bourbon;
@import "./layout";
// layout.css
div {
    @include size(100px, 200px);
}

In layout.css, @include size() assumes that this mixin lib(Bourbon) is added somewhere in parent stylesheet but since layout.css doesn’t have explicit @import bourbon; LiveStyle can’t find size() mixin and simply ignores it.

I want to create a scanner that automatically find all stylesheets used (like Bourbon) and use their mixins.

xzyfer commented 9 years ago

I want to create a scanner that automatically find all stylesheets used

Apologies if I'm missing something, but doesn't this mean parsing and following all @imports?

sergeche commented 9 years ago

Scanning all stylesheets in project/folder. LS already follows @imports in edited stylesheet

xzyfer commented 9 years ago

Wouldn't that cause false positives though? Presumable LS should ignore mixins/functions that part of the current files import chain since less/Sass wouldn't be aware of the mixins (and likely error).

This is doubly for functions which, in the case of Sass, just get output as is with the expectation that it's a native css function.

sergeche commented 9 years ago

Yes, it can potentially introduce errors and wrong mixin matches. I want create a possible solution for issue described above so I just wrote a note to myself :)

xzyfer commented 9 years ago

Sorry for hijacking :) I write lots of Sass tooling and am following this project closely. This issue got me curious about a possible https://github.com/xzyfer/sass-graph tie in.

sergeche commented 9 years ago

Yeah, something like that. The main problem is how to determine a starting point for scanning, assuming you may just open a single stylesheet file in editor (e.g. you don’t know the project root).

sergeche commented 9 years ago

Or maybe just make a solution for quickly adding a custom file as global dependency for all stylesheets in current project. Say, a right-click on it in sidebar and picking “Add to LiveStyle global dependencies”.

xzyfer commented 9 years ago

I expect you could (relatively?) safely walk up the directory tree until you don't see any more preprocessor files for N directories.

sergeche commented 9 years ago

I have to parse those stylesheets into LS object model and keep them in memory. So parsing all stylesheets found under parent directories could lead to massive memory and CPU usage

xzyfer commented 9 years ago

I agree. Doing so using @imports as a sort of whitelist could help. In the case of Sass, there isn't any kind of import path magic (yet), so you can (relatively?) safely match file path suffixes.