-
-
Notifications
You must be signed in to change notification settings - Fork 210
Open
Description
just helping to pick up issues from #83
go to definition
- go to definition from class in template to cssgo to definition from class in template moustache tags like class to cssgo to definition from css to templateTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
i have no knowledge of how to do this but happy to give it a try
BigBoulard, LexRiver and matubuampcpmgp and lukaszpolowczyk
Activity
dummdidumm commentedon Jun 6, 2020
Here are my quick thoughts about it:
General things
This is the interface
DefinitionsProvider
(method name isgetDefinitions
). It gets a position (line, column) of the current cursor position from which the definition info has to be computed.I would leave out the "class in template moustache tags" (
class="{bla ? 'class1' : 'class2'}"
) out for now and first see if the solution works out well.From template to css
Step 1 - get name at position
Option 1: Use the svelte compiler/parser output. The AST contains info about where classes are used I think. Drawback: Will not work if the code is in a state where svelte parser will throw an error.
Option 2: Do some kind of backwards regex matching like "is there a
class="
to the left of me? If yes, get full name".Step 2 - Find name in css
Don't know if we can leverage the existing CSS language service inside
CSSPlugin
here, I don't think it provides such methods. So a regex might have to do it. After that, the target position has to be computed from the match.From css to template
Step 1 - get name at position
I think the CSS language service inside
CSSPlugin
can help us here withnodeAtPosition
or sth like that.Step 2 - find name in template
Option 1: traverse svelte compiler/parser AST
Option 2: Regex or
parse5
Architectural considerations
CSSPlugin
.SveltePlugin
. So that would need to get extracted one level up into theDocument
so other plugins can use that, too.swyxio commentedon Jun 6, 2020
thanks for the great thoughts - this seems a bit bigger than i can handle right now i think. i may hunt around for something smaller to try tackling, maybe someone else can tackle this (or me in future)
ampcpmgp commentedon Oct 22, 2021
I would like this feature very much!
CSS Peek didn't do it for me.
(by DeepL translation)
Jojoshua commentedon Aug 25, 2022
Linking #1518
LexRiver commentedon Jan 21, 2024
I don't know why, but for me moving style tag to custom
css
orscss
file works for me.In bottom of
MyComponent.svelte
:Now I can navigate from
svelte
file onclass="my-style"
to definition of css class inscss
file bygo to definition
(F12) in vscode.IcyFoxe commentedon Feb 13, 2025
Any progress on this? In Vue I found this feature very helpful.