nvim-treesitter-context
nvim-treesitter-context copied to clipboard
it not support vue
it not support vue
it need more details
Is there a treesitter vue language? What is its name? More details means easier for us to provide an answer.
it need more details
Is there a treesitter vue language? What is its name? More details means easier for us to provide an answer.
yes.it has treesitter vue language.tree-sitter-vue
it not work make sad
In VueJS Single File Components, you can put your HTML markup inside <template>
tags and your code inside <script>
tags:
<template>
<div class="text-big">
<p>Counter number is: {{ type }}</p>
<button @click="getTypeAndIncrement()">Increment</button>
</div>
</template>
<script>
export default {
data: function() {
return {
counter: 0,
type: '',
};
},
methods: {
getTypeAndIncrement: function() {
if (this.counter % 2 === 0) {
this.type = 'even';
} else {
this.type = 'odd';
}
this.counter += 1;
},
},
}
</script>
For the <template>
section, this pattern works:
vue = {
'element',
'start_tag',
},
However, nothing inside the <script>
tag is really recognized. I've tried this pattern, but it doesn't recognize functions or if statements:
vue = {
'element',
'start_tag',
'script_element',
'raw_text',
'export_statement',
'pair',
'method_definition',
'property_identifier',
'if_statement',
'else_clause',
},
Does the Vue TreeSitter grammar only describe the <template>
section and nothing else?
Here are the nodes for TreeSitter Playground, starting at the export default
statement:
export_statement [8, 0] - [25, 1]
value: object [8, 15] - [25, 1]
pair [9, 2] - [14, 3]
key: property_identifier [9, 2] - [9, 6]
value: function [9, 8] - [14, 3]
parameters: formal_parameters [9, 16] - [9, 18]
body: statement_block [9, 19] - [14, 3]
return_statement [10, 4] - [13, 6]
object [10, 11] - [13, 5]
pair [11, 6] - [11, 16]
key: property_identifier [11, 6] - [11, 13]
value: number [11, 15] - [11, 16]
pair [12, 6] - [12, 14]
key: property_identifier [12, 6] - [12, 10]
value: string [12, 12] - [12, 14]
pair [15, 2] - [24, 3]
key: property_identifier [15, 2] - [15, 9]
value: object [15, 11] - [24, 3]
pair [16, 4] - [23, 5]
key: property_identifier [16, 4] - [16, 23]
value: function [16, 25] - [23, 5]
parameters: formal_parameters [16, 33] - [16, 35]
body: statement_block [16, 36] - [23, 5]
if_statement [17, 6] - [21, 7]
condition: parenthesized_expression [17, 9] - [17, 33]
binary_expression [17, 10] - [17, 32]
left: binary_expression [17, 10] - [17, 26]
left: member_expression [17, 10] - [17, 22]
object: this [17, 10] - [17, 14]
property: property_identifier [17, 15] - [17, 22]
right: number [17, 25] - [17, 26]
right: number [17, 31] - [17, 32]
consequence: statement_block [17, 34] - [19, 7]
expression_statement [18, 8] - [18, 27]
assignment_expression [18, 8] - [18, 26]
left: member_expression [18, 8] - [18, 17]
object: this [18, 8] - [18, 12]
property: property_identifier [18, 13] - [18, 17]
right: string [18, 20] - [18, 26]
string_fragment [18, 21] - [18, 25]
alternative: else_clause [19, 8] - [21, 7]
statement_block [19, 13] - [21, 7]
expression_statement [20, 8] - [20, 26]
assignment_expression [20, 8] - [20, 25]
left: member_expression [20, 8] - [20, 17]
object: this [20, 8] - [20, 12]
property: property_identifier [20, 13] - [20, 17]
right: string [20, 20] - [20, 25]
string_fragment [20, 21] - [20, 24]
expression_statement [22, 6] - [22, 24]
augmented_assignment_expression [22, 6] - [22, 23]
left: member_expression [22, 6] - [22, 18]
object: this [22, 6] - [22, 10]
property: property_identifier [22, 11] - [22, 18]
right: number [22, 22] - [22, 23]
Needs queries/vue/context.scm
. I don't plan to explicitly add this but will accept a PR.