#vue #tree-sitter #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

#349 in Text editors

Download history 54/week @ 2024-09-07 46/week @ 2024-09-14 84/week @ 2024-09-21 77/week @ 2024-09-28 68/week @ 2024-10-05 29/week @ 2024-10-12 12/week @ 2024-10-19 11/week @ 2024-10-26 21/week @ 2024-11-02 15/week @ 2024-11-09 18/week @ 2024-11-16 16/week @ 2024-11-23 87/week @ 2024-11-30 64/week @ 2024-12-07 64/week @ 2024-12-14 27/week @ 2024-12-21

245 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.8–4MB
~77K SLoC