Giter VIP home page Giter VIP logo

Comments (18)

bb010g avatar bb010g commented on July 17, 2024 1

@justinmk For #trim! to address this, would it need to not just trim empty lines, but also whitespace from the beginning & end of (all lines in the) region?

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024 1

No thanks, I have a PR otw

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024

hopefully will be addressed when #trim! is upstreamed. offset! also is worth noting.

nvim-treesitter/nvim-treesitter#2850

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

As is, #trim! would not help here as you noticed. We'd need a new variant that works horizontally (only), or add a keyword that controls the mode.

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024

proposed workaround: #28

from tree-sitter-vimdoc.

bb010g avatar bb010g commented on July 17, 2024

metadata[capture_id].range isn't working like I'd expect on v0.8.0, at least given the #offset! examples I've seen. Here's some debug output from nvim-treesitter-playground using this in highlights.scm (all other (#set! conceal "") directives commented out):

(tag
  text: (_) @label)
(tag
  "*" @conceal (#set! conceal "")
  (#match? @conceal "^\\*$")
  text: (_))
(tag
  "*" @conceal.left (#set! conceal "")
  (#offset! @conceal.left 0 0 0 -2)
  (#match? @conceal.left "^\\s+\\*$")
  text: (_))

Screen Shot 2022-10-05 at 09 11 38
You can see that the modified range for the "*" anonymous node should cause all but * (column range 49–51) to be concealed, but the whole node range is still concealed.

I attempted to do this without match, but there seems to be some interesting behavior with sibling ordering & anonymous nodes:

(tag
  text: (_) @label)
(tag
  text: (_)
  "*" @conceal.right (#set! conceal "")
) ; @mytest
; (tag
;   "*" @conceal (#set! conceal "")
;   (#match? @conceal "^\\*$")
;   text: (_)
; )
(tag
  "*" @conceal.left (#set! conceal "")
  ; (#offset! @conceal.left 0 0 0 -2)
  ; (#match? @conceal.left "^\\s+\\*$")
  text: (_)
)

Screen Shot 2022-10-05 at 09 20 04
@conceal.right is properly applied only after a sibling text: (_), but @conceal.left applies to both.

Also, for some bonus fun, if I uncomment that ; @mytest capture on the pattern containing @conceal.right:
Screen Shot 2022-10-05 at 09 22 59
@mytest is now a capture that has metadata.conceal set! This feels pretty wrong and I'm worried it's a tree-sitter problem.

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

@vigoux

from tree-sitter-vimdoc.

Bekaboo avatar Bekaboo commented on July 17, 2024

Also have this bug.

from tree-sitter-vimdoc.

numToStr avatar numToStr commented on July 17, 2024

Some cases are still not fixed. For example, Whitespace is still getting trimmed when you only have tags on a line like

							*:setl* *:setlocal*

Becomes

:setl :setlocal

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024

Yes, seems like whitespace is included in the first node of a line. Not sure why.

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

Also happens with links; see, e.g., api.txt, line 1547f (and many other places).

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024

Links that are the first node in the line..?

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

Yes.

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

This actually happens for all nodes as far as I can see: check line 22 of api.txt with hi link @text.uri Underlined -- the underline extends to the beginning of the line.

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024

Even with current HEAD? Is the issue fixed with 31fcaca ?

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

Is that in core?

from tree-sitter-vimdoc.

justinmk avatar justinmk commented on July 17, 2024

not yet

from tree-sitter-vimdoc.

clason avatar clason commented on July 17, 2024

Ah, OK. Want me to bump the parser and queries, or is there something you'd like to hold out for?

from tree-sitter-vimdoc.

Related Issues (20)

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.