CSS Navigation - VSCode ExtensionProvides CSS Completion, Finding Definition, Finding References, Hover, Workspace Symbols services for HTML, JS, TS, JSX, Vue and more languages across whole workspace. FeaturesNew Feature in v2.2.0: CSS Variable ServicesSince v2.2.0, this plugin provides full CSS Variable service include Definition / Completion / Reference / Hover. And it provides color preview besides color type css variables, recently supported color formats: hex, rgb, rgba, hsl, hsla. Go to Definition and Peek DefinitionChoose Go to definition or Peek definition, the extension will search related CSS & Scss & Less selectors in current workspace folder. The places you can goto definitions:
Class Name and ID Hover Info - New in V2.0When mouse hover at a Class Name / Id / CSS Variable, will show it's description (leading comment) and first several style properties.
You may configure Class Name, CSS Variable and ID CompletionProvides Class Name/ Id / CSS Variable completion for your HTML files, and if you have specified some class name or id in HTML files, can also complete them in CSS files. Find All References and Peek ReferencesSupports looking for CSS selector references across all HTML & CSS files of workspace folder. When your workspace folder having too much HTML like files, parsing them all may cause stuck, so it limits to read at most 500 files. Workspace symbolsAllows to search workspace symbols from CSS & Scss & Less files across all activated workspace folders. Miscellaneous Features
Note about JSXNote that the JSX template doesn't provide completion for attribute value by default, you may trigger it manually by clicking
Configuration
Why started this projectI'm a heavy CSS developer, I have tried vscode-css-peek in 2019, but I found it eats so much CPU & memory. E.g., one of my project has 280 CSS files, includes 6 MB codes. On my MacBook Pro, it needs 7s to load (1.3s to search files and 6s to parse), and uses 700 MB memory. Otherwise it keeps parsing files every time you input a character, if CSS document is more than 100 KB, CPU usage will keep high when inputting. Later on my vocation I decided to implement a new css parser, as a result I created a new extension. The CSS parser is very simple and cares about only the plugin should care, it's fast and very easy to extend. Now it costs about 0.8s to search files, and 0.5s to parse them. Memory usage in caching parsed results is only about 40 MB. By the same parser, finding definitions, completions, references, hover are simply implemented. Stress Test & PerformanceI loaded 100 MB (0.9 M declarations, 2.8 M lines) CSS files for stress test, it took 8s to parse them, and used about 850 MB memory. After 1 minute, the memory usage fell back to 550 MB. Searching definitions across all 0.9 M declarations cost about 50ms, searching workspace symbols cost about 500ms, and searching completions cost about 230ms. My environment is Win10, MacBook Pro 2014 version, with power on. Plans & MoreThis plugin has simple and clean codes after version 2.0, I hope it can grow and serve more frontend developers. So please give your feedback, thanks. FAQI get repetitive completion itemsThis plugin itself will never generate repetitive completion items, but it would be normal that completions items generated by other plugins repeat with this plugin. A frequently happened problem is css variable completion repetition -- vscode has provided css variable completion within each single css files, so you will found they get repetitive with current plugin provided.
But this can be avoid by simply set Can I change definition order to make sass files always before the css files?No, VSCode always sort the definition results, seems in name order. If you don't like duplicate css definitions, you can remove the There is a I get only partial of all definitionsFirstly this plugin will search definitions within current document and all imported files, if found, will stop searching; if nothing found, will search across whole workspace folder. Can't get definitions across all workspace foldersBy default, definition searching is limited in the same workspace folder, that means when you choose If you have more than one folders in your workspace, and you definitely need to find definitions across them, set Missed some workspace symbolsWorkspace symbols are always come from multiple workspace folders, but for each workspace folder, you need to open at least one HTML or CSS file to activate it, then will return results belong to it. Set How the extension find selectors?This extension only compare the last class / id / tag part of the selector. So when you are trying to find definitions for LicenseMIT |