Comments (7)
Maaaaaaaayyyyyyybe. 😊
from vim-css-color.
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.
Hopefully.
Thanks.
from vim-css-color.
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.
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.
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.
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)
- E121: Undefined variable: b:css_color_pat in netrw
- Neovim tree sitter support HOT 20
- support for svelte files HOT 2
- Plugin is not compatible with nvim-treesitter HOT 1
- No colors in .h files in neovim
- It would be nice to support SVG files HOT 2
- create_matches function takes 1.4 s on large nix files
- NeoVim tree sitter support HOT 1
- Error with files with no highlightable targets in Vim9 HOT 4
- Erroring in java file HOT 2
- Add support for LaTeX? HOT 1
- Add support for template strings
- Does not work HOT 5
- incompatible with nvim-treesitter HOT 2
- [Feature request]: provide a command to make it asynchronous.
- truecolor terminals and termguicolors HOT 5
- Incorrect Highlighting of C Macros
- How to enable color highlighting for strings in CSS
- Error in C comments
- Support CSS Color Module Level 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-css-color.