nvim-ts-rainbow icon indicating copy to clipboard operation
nvim-ts-rainbow copied to clipboard

Vue, treesitter and rainbow colors?

Open zetashift opened this issue 3 years ago • 19 comments

How can I make Vue work with this plugin?

Current look:

image

But other treesitter langs work fine, e.g. Fennel:

image

I have this one installed https://github.com/ikatyang/tree-sitter-vue

zetashift avatar Jul 10 '21 10:07 zetashift

The code inside <script> is always js and the code inside <style> is always css, correct? Can you paste an example file here?

p00f avatar Jul 10 '21 12:07 p00f

But the code in the <script> tag can also be typescript, and the style can also be scss if one wants too, for example:

<template>
  <div>Hello Hello </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'

@Component
export default class HelloWorld extends Vue {
}

</script>

<style lang="scss">
$color: red;
</style>

Here is the normal example:

<template>
  <img alt="Vue logo" src="./assets/logo.png">
  <HelloWorld msg="Welcome to Your Vue.js App"/>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components: {
    HelloWorld
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

I'm also using this theme by the way: https://github.com/elianiva/gruvy.nvim

zetashift avatar Jul 10 '21 14:07 zetashift

Atleast the curly braces in <style> and <script> should work :/

p00f avatar Jul 10 '21 14:07 p00f

image graphql inside js works, I don't know why this doesn't

Atleast the curly braces in <style> and <script> should work :/

p00f avatar Jul 10 '21 14:07 p00f

Should be fixed now

p00f avatar Jul 10 '21 14:07 p00f

Yup it works, thanks a lot, it's a very fun plugin!

zetashift avatar Jul 10 '21 14:07 zetashift

Currently though the TSTagDelimiters aren't matching correctly:

image

zetashift avatar Jul 10 '21 17:07 zetashift

I've removed vue tags for now because of the wrong highlighting The vue query file is now empty, so that atleast the js/ts/css/scss inside is rainbow

p00f avatar Jul 13 '21 05:07 p00f

I'm not sure what happened, but in Vue files the highlighting is fine and everything works, but in regular html files I see this:

https://user-images.githubusercontent.com/1857826/126076556-91033d74-1685-4fb1-aea4-97d74b4ca1f1.png

If I disable rainbow the highlighting returns to regular, which is:

image

zetashift avatar Jul 18 '21 18:07 zetashift

html should be fixed now, after 32c53d0999046076eac0660ad93e38a446840369

p00f avatar Jul 23 '21 05:07 p00f

I still have the problem:

image

I ran PackerSync, so AFAIK I should be on latest. Maybe it's a config then?

zetashift avatar Jul 26 '21 14:07 zetashift

That is intended, turn off extended mode for html if you don't want to highlight tag text

p00f avatar Jul 26 '21 14:07 p00f

Ah yup! thanks works great, thank you

EDIT: well except for the <!DOCTYPE html> part haaha

zetashift avatar Jul 26 '21 16:07 zetashift

This issue should be kept open as Vue end tags don't work

p00f avatar Jul 26 '21 16:07 p00f

My bad, it worked good enough for me :P

zetashift avatar Jul 26 '21 16:07 zetashift

Stale issue message

github-actions[bot] avatar Sep 25 '21 02:09 github-actions[bot]

Should not have used this bot

p00f avatar Oct 03 '21 04:10 p00f

I expect everything inside template tag should parse like a HTML file, will this support in the future? @p00f

Alexie7777 avatar Jul 27 '22 11:07 Alexie7777

I don't understand, can you give an example?

p00f avatar Jul 27 '22 12:07 p00f

the code inside <template> tag can be treated as a regular HTML file with {{}} template sytax, so it'll be better to have HTML rainbow color inside the <template> tag. @p00f

image

Vue Template Tag

image

regular HTML file

Alexie7777 avatar Aug 10 '22 08:08 Alexie7777

@Alexie7777 That is done using injections, you have to take this up with nvim-treesitter

p00f avatar Aug 10 '22 09:08 p00f

@p00f BTW in my experence the Vue <script> end tag is now working. Thanks for the great work 🫡 image

Alexie7777 avatar Aug 10 '22 13:08 Alexie7777

Huh nice, thanks

p00f avatar Aug 10 '22 13:08 p00f