#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

#289 in Text editors

Download history 56/week @ 2024-03-13 52/week @ 2024-03-20 84/week @ 2024-03-27 108/week @ 2024-04-03 82/week @ 2024-04-10 49/week @ 2024-04-17 62/week @ 2024-04-24 68/week @ 2024-05-01 67/week @ 2024-05-08 52/week @ 2024-05-15 46/week @ 2024-05-22 78/week @ 2024-05-29 77/week @ 2024-06-05 74/week @ 2024-06-12 56/week @ 2024-06-19 46/week @ 2024-06-26

263 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