Skip to content

Syntax highlighting of Svelte components in WebStorm and friends

License

Notifications You must be signed in to change notification settings

vcicmanec/svelte-intellij

 
 

Repository files navigation

Header of svelte-intellij repository

svelte-intellij

Support for Svelte in your IDE of choice. Works in JetBrains products that support JavaScript.

Work in progress, pretty usable already.

Installation

Features

  • Syntax highlighting
  • Code formatting
  • Typing assistance
  • Completions of components and props
  • Auto import of components
  • Navigation from components to their definition

Known issues

  • $ subscriptions and labels aren't recognised properly
  • Directives are treated as plain attributes
  • ...

Support

This project is run by one person. Please leave a star and spread the word.

Contributing

Contributions are very much welcome!

IntelliJ Platform runs on JVM, so this can seem like a huge limitation, but don't worry. Kotlin feels a lot like TypeScript. Bigger issue is scarce documentation for their API.

Building and running the plugin

You'll need IntelliJ IDEA. Community edition is free and sufficient, you can also use Ultimate edition if you have one.

Clone the repository and run ./gradlew :runIde (There are also other intermediate tasks).

IntelliJ Ultimate will download in a bit and you'll be prompted with license dialog - choose evaluation mode. After 30 days delete build/idea-sandbox and start again.

Ready to share .zip archive can be found in build/distributions after running ./gradlew :buildPlugin.

Running tests

Tests can be run with ./gradlew :test command or even better or by using run action in IntelliJ IDEA.

Writing Tests

Some of the tests in IntelliJ Platform (notably lexer and parser ones) are similar to Jest snapshots.

You need to create a .svelte file in scr/test/resources directory and add function composed of the word test and file name to appropriate class. Then run the test. File with expected results will be created and you need to commit it. When updating test simply delete expected file and rerun test.

Lexer tests use .tokens.txt extensions, while Parser tests use .txt.

About

Syntax highlighting of Svelte components in WebStorm and friends

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 83.4%
  • Lex 12.2%
  • HTML 2.9%
  • Java 1.5%