Skip to content

How do I keep indent of a node’s actual start and not of its line? #163

Answered by Wansmer
gregorias asked this question in Q&A
Discussion options

You must be logged in to vote

Sadly, I don’t see how both options help here.

E.g:

        haskell = {
          list = {
            both = {
              separator = ",",
            },
            split = {
              format_tree = function(tsj)
                local len = tsj:child(1):range()[2] -- index of first character of first node
                for child in tsj:iter_children() do
                  if not (child:is_first() or child:is_omit()) then
                    local indent = not child:is_last() and (" "):rep(len + vim.fn.shiftwidth()) or (" "):rep(len)
                    child:update_text(indent .. child:text())
                  end
                end
              end,
            },
       …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gregorias
Comment options

@Wansmer
Comment options

Answer selected by gregorias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants