Giter Site home page Giter Site logo

panekj / tree-sitter-svelte Goto Github PK

View Code? Open in Web Editor NEW

This project forked from himujjal/tree-sitter-svelte

0.0 0.0 0.0 285 KB

Tree sitter grammar for Svelte

License: MIT License

JavaScript 6.75% C++ 0.36% Scheme 0.90% Python 0.26% C 89.35% Rust 1.28% Svelte 1.10%

tree-sitter-svelte's Introduction

Tree-sitter-svelte

Tree-sitter grammar for svelte

Install

npm i tree-sitter-svelte tree-sitter

Tree-sitter also requires nodemon to run, so also install that if you don’t already have it:

npm i -g nodemon

Finally, you will need pnpm. If you’re running Node 16.13 or later, it comes as part of Node so you can simply run the following to activate it:

corepack enable

Dev

After installation (npm i),

npm run dev

Usage

To get started with exploring the grammar in a web-ui. Run:

NOTE: emcc must be installed and in your path

npm run ui

To use the grammar from javascript:

const Parser = require("tree-sitter");
const Svelte = require("tree-sitter-svelte");

const parser = new Parser();
parser.setLanguage(Svelte);

const sourceCode = `
<script context="module">
    let name = 'world';
</script>
<h1>Hello {name'<>{}``"\\''""``{}}!</h1>
`;

const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());

// (document
//    (script_element
//        (start_tag (tag_name)
//            (attribute (attribute_name) (quoted_attribute_value (attribute_value))))
//        (raw_text)
//        (end_tag (tag_name))
//    )
//    (element
//        (start_tag (tag_name))
//        (text) (raw_text_expr) (text)
//        (end_tag (tag_name)
//    )
//  )
//)

For Neovim peeps

Install :TSInstall typescript scss for the plugin to work everywhere in Neovim (TypeScript/SCSS/LESS/PostCSS)

Languages supported:

  • JavaScript/TypeScript
  • Rust
  • Go
  • Nim
  • Python

LICENSE

MIT

tree-sitter-svelte's People

Contributors

himujjal avatar elianiva avatar aral avatar himuspz avatar eduardomosko avatar kazatsuyu avatar ajuvercr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.