#vue #highlight #parser #incremental

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

#259 in Text editors

Download history 68/week @ 2023-11-27 46/week @ 2023-12-04 35/week @ 2023-12-11 38/week @ 2023-12-18 43/week @ 2023-12-25 63/week @ 2024-01-01 51/week @ 2024-01-08 30/week @ 2024-01-15 39/week @ 2024-01-22 36/week @ 2024-01-29 653/week @ 2024-02-05 47/week @ 2024-02-12 58/week @ 2024-02-19 95/week @ 2024-02-26 80/week @ 2024-03-04 33/week @ 2024-03-11

271 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
~71K SLoC