Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeSitter indent for .yuck files doesn't seem correct #7

Open
squishram opened this issue Feb 3, 2024 · 9 comments · Fixed by nvim-treesitter/nvim-treesitter#6091

Comments

@squishram
Copy link

Auto-indentation on .yuck files using treesitter misplaces the first piece of content in (e.g.) a widget or window, and all the closing brackets are also misplaced (as a result?). It gives this kind of situation:

(defwidget name
  :widget parameter
(box one
  :box1 parameter
  (box two
    :box2 parameter
    )
  )
)

So line containing box one is under-indented, and the brackets that close box one and box two are over-indented. I hope this makes sense. It's still a lot better than non-TS indenting but I'd really appreciate a fix as these files are a nightmare to work with already. Thanks!

@Philipp-M
Copy link
Collaborator

@amaanq do you have an idea how to fix this?
(I have not much insight into how neovim or in general indents in tree-sitter work, I'm not using that part of the implementation currently)

@amaanq
Copy link
Member

amaanq commented Feb 13, 2024

Hey sorry I just saw this, I can take a look in a bit, and maybe it'd be better to open an issue there, ik @lucario387 is pretty good with the indent stuff

@lucario387
Copy link

lucario387 commented Feb 13, 2024

Will look at it someday :)

That's all I can confirm. This isn't a parser issue (yet).

@amaanq
Copy link
Member

amaanq commented Feb 13, 2024

Can you try updating nvim-ts and see how that fares @squishram

@squishram
Copy link
Author

A problem seems to persist even after updating TreeSitter. I'll try and explain the issue more concisely, I hope that helps. Sorry, I am not all that much of a programmer and don't think I'd be an effective crontibutor, but if you are struggling to see the issue and could use some help I'd be happy to clone the repo and have a look.

Currently, auto-indent looks like this:

(defwindow bar
  :arg1 "value1"
(box
    :arg2 "value2"
  (item)
  )
)

When what we presumably want is this:

(defwindow bar
  :arg1 "value1"
  (box
    :arg2 "value2"
    (item)
  )
)

So box, the first object in the bar window, is under-indented, which leads to a cascading effect of under-indented objects, which in this case, includes item. Interestingly, the closing brackets and the arguments for each item seem to be in the right place. It's just the declaration of the objects themselves that seem to be the problem.

I know this probably seems like quite a small problem, but over a long widget, this can really impact legibility as it's unclear "what belongs to what", which is a pretty essential piece of information in this context. As I say, let me know if you need another pair of eyes on it.

@lucario387
Copy link

Does it work correctly after inputting =ab?

@lucario387
Copy link

lucario387 commented Feb 14, 2024

Because if it's supposed to work like lisp, i.e all parens are done after all the contents are typed in, I will have to do a bit more tweaking for that

@squishram
Copy link
Author

Does it work correctly after inputting =ab?

I'm not really sure what you mean by this I'm afraid & I'm not familiar with Lisp syntax. Do you think my recommendation for how .yuck indentation should work might be wrong/ misguided?

@lucario387
Copy link

As in I have no idea what you and others expect of Yuck indent. Should it be "I won't close any parentheses until the end", or "I will close the parens and then fill the content inside it".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants