Skip to content

Syntax highlighting of Svelte components in WebStorm and friends

License

Notifications You must be signed in to change notification settings

alexander-doroshko/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 starting with version 2019.2.

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

  • $ 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.5%
  • Lex 12.1%
  • HTML 2.9%
  • Java 1.5%