Giter Club home page Giter Club logo

tree-sitter-twig's Introduction

tree-sitter-twig's People

Contributors

gbprod avatar clason avatar kaermorchen avatar blinxen avatar

Stargazers

Thanh Trần avatar  avatar Ciprian Paduraru avatar Kaspars Zuks avatar Digiveljet avatar Șerban Robu avatar Tsizehena Sarobidi avatar Ramon Bakker avatar Xavier Laviron avatar Mikhail Gunin avatar Rodrigo Passos avatar Miguel Montalvo avatar Zuruh avatar Jascha van Aalst avatar  avatar  avatar chris montgomery avatar Joohoon Cha avatar Vladislav Shavelskiy avatar Curtis Henson avatar Nicolas Hirsig avatar Kev Sturman avatar Nathan Long avatar Joshua Jackson avatar Eirik avatar yaegassy avatar Bryant avatar Mathias Arlaud avatar Olexander Popov avatar Florian Merle avatar Tommy avatar Khalid H. Ahmed avatar Stéphane P avatar Andreas Sander avatar  avatar

Watchers

Jérémy DECOOL avatar  avatar  avatar Nicolas Hirsig avatar

tree-sitter-twig's Issues

Twig highlighting is removed when using empty double quotes

Describe the bug

Highlighting for the rest of the file is removed/buggy when wrapping empty strings in double quotes. It does not get removed if using single quotes or if the string is not empty.

Empty string with single quotes:
image

Empty string with double quotes:
image

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - OK: `node` found v18.10.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - turtle         ✓ ✓ ✓ ✓ ✓
  - svelte         ✓ . ✓ ✓ ✓
  - beancount      ✓ . ✓ . .
  - gleam          ✓ ✓ ✓ ✓ ✓
  - rnoweb         ✓ . ✓ . ✓
  - eex            ✓ . . . ✓
  - heex           ✓ ✓ ✓ ✓ ✓
  - bibtex         ✓ . ✓ ✓ .
  - python         ✓ ✓ ✓ ✓ ✓
  - ocaml_interface✓ ✓ ✓ . ✓
  - fortran        ✓ . ✓ ✓ .
  - regex          ✓ . . . .
  - menhir         ✓ . . . ✓
  - help           ✓ . . . .
  - org            . . . . .
  - json5          ✓ . . . ✓
  - pioasm         ✓ . . . ✓
  - hjson          ✓ ✓ ✓ ✓ ✓
  - todotxt        ✓ . . . .
  - hocon          ✓ . . . ✓
  - typescript     ✓ ✓ ✓ ✓ ✓
  - llvm           ✓ . . . .
  - meson          ✓ . ✓ . ✓
  - qmljs          ✓ . ✓ . .
  - supercollider  ✓ ✓ ✓ ✓ ✓
  - prisma         ✓ . . . .
  - diff           ✓ . . . .
  - slint          ✓ . . ✓ .
  - rasi           ✓ ✓ ✓ ✓ .
  - haskell        ✓ . ✓ . ✓
  - hack           ✓ . . . .
  - norg           . . . . .
  - embedded_template✓ . . . ✓
  - markdown_inline✓ . . . ✓
  - javascript     ✓ ✓ ✓ ✓ ✓
  - clojure        ✓ ✓ ✓ . ✓
  - tlaplus        ✓ ✓ ✓ . ✓
  - vala           ✓ . ✓ . .
  - bash           ✓ ✓ ✓ . ✓
  - vim            ✓ ✓ ✓ . ✓
  - html           ✓ ✓ ✓ ✓ ✓
  - lalrpop        ✓ ✓ . . .
  - tsx            ✓ ✓ ✓ ✓ ✓
  - cuda           ✓ ✓ ✓ ✓ ✓
  - solidity       ✓ . . . .
  - glimmer        ✓ . . . .
  - pug            ✓ . . . ✓
  - cooklang       ✓ . . . .
  - latex          ✓ . ✓ . ✓
  - v              ✓ ✓ ✓ ✓ ✓
  - dockerfile     ✓ . . . ✓
  - foam           ✓ ✓ ✓ ✓ ✓
  - astro          ✓ ✓ ✓ ✓ ✓
  - markdown       ✓ . ✓ . ✓
  - elm            ✓ . . . ✓
  - wgsl           ✓ . ✓ ✓ .
  - c_sharp        ✓ ✓ ✓ . ✓
  - yang           ✓ . ✓ ✓ .
  - ledger         ✓ . ✓ ✓ ✓
  - agda           ✓ . ✓ . .
  - dart           ✓ ✓ . ✓ ✓
  - tiger          ✓ ✓ ✓ ✓ ✓
  - http           ✓ . . . ✓
  - sxhkdrc        ✓ . ✓ . ✓
  - fennel         ✓ ✓ . . ✓
  - graphql        ✓ . . ✓ ✓
  - nickel         ✓ . . . .
  - ql             ✓ ✓ . ✓ ✓
  - ruby           ✓ ✓ ✓ ✓ ✓
  - perl           ✓ . ✓ . .
  - pascal         ✓ ✓ ✓ ✓ ✓
  - zig            ✓ . ✓ ✓ ✓
  - twig           ✓ . . . ✓
  - phpdoc         ✓ . . . .
  - fish           ✓ ✓ ✓ ✓ ✓
  - php            ✓ ✓ ✓ ✓ ✓
  - jsdoc          ✓ . . . .
  - java           ✓ ✓ . ✓ ✓
  - query          ✓ ✓ ✓ ✓ ✓
  - c              ✓ ✓ ✓ ✓ ✓
  - kotlin         ✓ ✓ ✓ . ✓
  - sparql         ✓ ✓ ✓ ✓ ✓
  - julia          ✓ ✓ ✓ ✓ ✓
  - jsonnet        ✓ . . . .
  - css            ✓ . ✓ ✓ ✓
  - scss           ✓ . . ✓ .
  - erlang         ✓ . ✓ . .
  - elixir         ✓ ✓ ✓ ✓ ✓
  - proto          ✓ . ✓ . .
  - blueprint      ✓ . . . .
  - gitattributes  ✓ . . . ✓
  - cpp            ✓ ✓ ✓ ✓ ✓
  - surface        ✓ . ✓ ✓ ✓
  - cmake          ✓ . ✓ . .
  - json           ✓ ✓ ✓ ✓ .
  - racket         ✓ . ✓ . ✓
  - dot            ✓ . . . ✓
  - vue            ✓ . ✓ ✓ ✓
  - gowork         ✓ . . . ✓
  - gomod          ✓ . . . ✓
  - yaml           ✓ ✓ ✓ ✓ ✓
  - nix            ✓ ✓ ✓ . ✓
  - ninja          ✓ . ✓ ✓ .
  - rst            ✓ ✓ . . ✓
  - commonlisp     ✓ ✓ ✓ . .
  - scheme         ✓ . ✓ . ✓
  - fusion         ✓ ✓ ✓ ✓ .
  - verilog        ✓ ✓ ✓ . ✓
  - rust           ✓ ✓ ✓ ✓ ✓
  - lua            ✓ ✓ ✓ ✓ ✓
  - jsonc          ✓ ✓ ✓ ✓ ✓
  - elvish         ✓ . . . ✓
  - hlsl           ✓ ✓ ✓ ✓ ✓
  - comment        ✓ . . . .
  - glsl           ✓ ✓ ✓ ✓ ✓
  - ocaml          ✓ ✓ ✓ . ✓
  - hcl            ✓ . ✓ ✓ ✓
  - go             ✓ ✓ ✓ ✓ ✓
  - toml           ✓ ✓ ✓ ✓ ✓
  - r              ✓ ✓ . ✓ ✓
  - rego           ✓ . . . ✓
  - sql            ✓ . . . ✓
  - make           ✓ . ✓ . ✓
  - scala          ✓ . ✓ . ✓
  - gdscript       ✓ ✓ . ✓ ✓
  - m68k           ✓ ✓ ✓ . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.8.0-1210-gd367ed9b2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az505-656

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Syntax highlighting breaks on multi-line set statements

Syntax highlighting seems to work fine on single-line set-statements but seems to break when using a set-block. More specifically, it seems to highlight the rest of the code like a string until a new quotation mark follows.

Here's an example:
grafik

But great syntax highlighting otherwise!

Highlighting error on twig functions

When integrating twig functions the highlighting breaks.

Expected behavior

  • Highlighting before and after lines where twig functions are invoked

Actual behavior

  • Highlighting works on some lines, breaks on other lines.
  • Inconsistent behavior across opening and closing tag. See example # 2.

Configuration

Treesitter

local ok, configs = pcall(require, "nvim-treesitter.configs")

if ok then
    configs.setup({
        additional_vim_regex_highlighting = false,
        auto_install = true,
        enable = true,
        ensure_installed = {
            "hcl",
            "astro",
            "bash",
            "css",
            "dockerfile",
            "graphql",
            "go",
            "html",
            "javascript",
            "jsdoc",
            "json",
            "jsonc",
            "lua",
            "markdown",
            "php",
            "python",
            "rust",
            "scss",
            "sql",
            "svelte",
            "toml",
            "tsx",
            "yaml",
            "typescript",
            "twig"
        },
        ignore_install = { "phpdoc" },
        highlight = { enable = true },
        indent = { enable = true },
        autotag = { enable = true },
    })
end

Examples

Installation is flawless and I can get autocompletion for twig macros and stuff. Im using the this boilerplate to test: https://github.com/craftcms/craft (templates/index.twig)

  1. Inside a <style></style> tag

image

image

  1. Inside HTML tag

image

  • I tried changing all single quote to double quote & vice-versa. Also tried mixing double quote with single quote.
  • I tried all type of opening and closing braces ( "{{ }}", "{% %}", "{%- -%}", "{%~ ~%}", etc. Exact same highlighting behavior

Comments

I dont fully understand how queries and stuff works so i'm not able to debug and open a MR. Do you have any idea?

Remove symlinks

The presence of symlinks prevents this parser from being installed on Windows (were symlinks are not supported outside admin/dev mode).

I don't think the node-module directory is even required; you can just use

      - uses: tree-sitter/setup-action/cli@v1

in CI? See https://github.com/tree-sitter-grammars/template for using upstream workflows for parser CI.

You might also wish to regenerate the bindings with the latest tree-sitter CLI (0.22.6); upstream has switched from nan to napi.

> Ping @gbprod, maybe you could bring some context to this issue. Did you look into indenting already? Did you have some issues? Thanks!

          > Ping @gbprod, maybe you could bring some context to this issue. Did you look into indenting already? Did you have some issues? Thanks!

Hi!
I've never tried to make indentation works for twig (mostly because I don't know how to make it works with combined injection).
But it would be awesome to improve this :)
I will make some tests ;)

Originally posted by @gbprod in nvim-treesitter/nvim-treesitter#6124 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.