Comments (5)
The result of the process should be patterns to search for and their corresponding color.
That is already how it works: the plugin scans the screen for colour literals and sets up highlights for them.
But yeah, I forgot that variables can be defined in other files (which, to complicate matters further, may or may not be currently opened for editing in another buffer, as well).
(The Principle of Least Power is rather relevant here.)
I'm not sure I'd like this feature anyway.
Those concerns donāt bother me so much. If the highlighting of variables could be toggled on and off then you could still get the benefits you described.
from vim-css-color.
All the colour literals are highlighted, are they not? š
Resolving variables would require running the whole thing through a Sass preprocessor on the fly on every keystroke (and understanding incompletely typed syntax). Not gonna happen in this plugin, sorry.
(Iād be curious if anything can do that in Emacs.)
from vim-css-color.
Ok thanks for the reply. Thought it could be solved with a variable <-> color mapping...
"Emacs"? Never heard of that š š
from vim-css-color.
The mapping itself is the easy part. This plugin doesnāt even do that itself, strictly speaking. Once you know which variables exist and what values they have, you just tell Vimās syntax highlighter about them, and the rest just happens, all by itself. (Thatās the pluginās job for colour literals. It doesnāt actively highlight anything itself.)
But to do that you have to find out which variables exist, and what values they have. And thatās a problem because any single keypress can change the meaning of the entire file. (Almost no keypress ever does. But keypresses that do change the meaning of at least a couple lines around the cursor are common.)
For colour literals, thatās also true, but itās not really too terrible: you can scan just the current screen and ignore the rest of the file. Even if a keypress changed the meaning of the whole file, the user can never see anything more than whatās on screen anyway (by definitionā¦). So as long as the current screen is always highlighted correctly, the user will never encounter incorrect highlighting.
But to deal with variables you cannot take any such shortcut. You have to scan the whole file on every keypress. And Vimās scripting language is just too slow for that, for even moderately sized files. Just scanning the current screen alone can bog Vim down badly if there are a lot of colour literals.
That said ā who knows. Maybe there is some other kind of shortcut. A different angle on the problem might reveal a feasible solution; maybe someday such an angle will occur to me. All I can say for sure is this feature is not doable in the obvious way.
from vim-css-color.
I'm not sure I'd like this feature anyway. At the moment the plugin shows me where I can go to modify a color. Highlighting variables as well would make it harder to find the line where the color was actually defined. Also, currently if I see the same color in multiple places, this is an indication that I have duplicated the color code, and should probably clean it up (into a variable). That indication would not be possible if we highlight variables as well.
That said, I can see the value in the idea. And I want to suggest that it is not impossible to achieve, under the following conditions:
- The sass processing should be run in the background, perhaps using vimproc to call an external tool in a different language. This won't lock up/lag Vim, and we could reuse existing libraries to parse the SASS code (sass has implementations in Ruby and in NodeJS).
- The result of the process should be patterns to search for and their corresponding color. That will be much more lenient towards buffer edits than, say, line+column regions and their corresponding colors. So while we are waiting for the background process to complete, the highlighting will still be (reasonably) accurate.
But a complication:
- I'm not super familiar with SASS, but I fear to get a truly accurate value for every variable, we would need to process more than one file! And we might need to know which is the entry-point file to start from, which might only be known by your current
%random_build_tool%
's configuration file/script. So good luck with that!
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.