Coder Social home page Coder Social logo

Comments (7)

ap avatar ap commented on August 17, 2024 1

Maaaaaaaayyyyyyybe. 😊

from vim-css-color.

ap avatar ap commented on August 17, 2024

It appears that colors for variables in .less files are not propagated.

That’s correct. It would just be too expensive to try.

The plugin already bogs down noticeably on some files (e.g. try opening the plugin’s code under itself and paging down to the hardcoded highlights) but fortunately its impact is bounded by the fact that only the visible portion of the file needs to be parsed per keystroke.

Variable support would require lifting the cap and parsing the entire file on every keystroke, and the parsing would also be more complex.

It’s not necessary to parse the entire file in principle, mind you – it’s just not practical to do better in Vim. If a script could know not just when the buffer has been modified but also which region, and if VimL were expressive and fast enough to write a proper parser, and someone took the effort to write one for Less that had solid error recovery… then the plugin could support variables and be even snappier.

Maybe someday in Neovim?

from vim-css-color.

F1LT3R avatar F1LT3R commented on August 17, 2024

Hopefully.

Thanks.

from vim-css-color.

ap avatar ap commented on August 17, 2024

NP. Another point, btw, is where it gets really problematic, and I don’t know how even a sufficiently powerfully programmable editor would be enough for it: handling @import. Particularly if the imported file is open in another buffer… But it might be reasonable to draw the line at “only variables local to this file, sorry”.

from vim-css-color.

F1LT3R avatar F1LT3R commented on August 17, 2024

ColorHighlighter fro SublimeText does allow highlighting colors via chained
@import flies. It's pretty useful for larger projects.

I'm looking forward to seeing where Neovim goes.

from vim-css-color.

Blackskyliner avatar Blackskyliner commented on August 17, 2024

For the @import you could, maybe, just cache all @color variables in the imports once, so you would not have the speed impact. No need to refresh after initial parsing. But idk if something like that is (easily) possible in viml.

If a cache is possible I would create a lookup table to know where the color gets defined. Thus, when you are in a file which defines a color, within the line where it gets defined you reparse this line for the color, if it gets changed (or on every keystroke, but only this one) Thus updating the color for all other places. Which would eliminate the "if open in other buffer" as we only have globally stored colors we visited.

Or another approach would be creating a tags like cache file which could be regenerated via command, thus letting the user the choice when to do reparsing of color codes (like on save .less files) Then reading this cache file to know what variable to color how.

But maybe it's out of scope for this project?

from vim-css-color.

shmargum avatar shmargum commented on August 17, 2024

just wanna chime in and say that I have made plugin that also handles imports:
https://github.com/shmargum/vim-sass-colors

from vim-css-color.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.