#parser #vue #tree-sitter #incremental #highlight

tree-sitter-vue

vue grammar for the tree-sitter parsing library

3 releases

0.0.3 Sep 24, 2022
0.0.2 Sep 23, 2022
0.0.1 Sep 23, 2022

#315 in Text editors

Download history 31/week @ 2024-07-22 62/week @ 2024-07-29 53/week @ 2024-08-05 43/week @ 2024-08-12 23/week @ 2024-08-19 56/week @ 2024-08-26 54/week @ 2024-09-02 55/week @ 2024-09-09 45/week @ 2024-09-16 85/week @ 2024-09-23 78/week @ 2024-09-30 69/week @ 2024-10-07 15/week @ 2024-10-14 13/week @ 2024-10-21 10/week @ 2024-10-28 23/week @ 2024-11-04

69 downloads per month

MIT license

225KB
7.5K SLoC

C 7K SLoC C++ 315 SLoC // 0.0% comments JavaScript 210 SLoC Scheme 107 SLoC // 0.1% comments Rust 43 SLoC // 0.1% comments

tree-sitter-vue

npm build

Vue (Vue v2.6.0 Template Syntax) grammar for tree-sitter

Note: This grammar is not responsible for parsing embedded languages, see Multi-language Documents for more info.

Changelog

Install

npm install tree-sitter-vue tree-sitter

Usage

const Parser = require("tree-sitter");
const Vue = require("tree-sitter-vue");

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

const sourceCode = `
<template>
  Hello, <a :[key]="url">{{ name }}</a>!
</template>
`;

const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
// (component
//   (template_element
//     (start_tag
//       (tag_name))
//       (text)
//       (element
//         (start_tag
//           (tag_name)
//           (directive_attribute
//             (directive_name)
//             (directive_dynamic_argument
//               (directive_dynamic_argument_value))
//             (quoted_attribute_value
//               (attribute_value))))
//         (interpolation
//           (raw_text))
//         (end_tag
//           (tag_name)))
//       (text)
//     (end_tag
//       (tag_name))))

License

MIT © Ika

Dependencies

~2.7–4MB
~75K SLoC