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

feat: code document format #53

Closed
wants to merge 1 commit into from

Conversation

WillLillis
Copy link
Collaborator

This PR adds some very basic document formatting as described in #42. Trailing whitespace and newlines are trimmed according to params communicated by the LSP client (with reasonable defaults provided as well). Labels (e.g. main:) are un-indented as needed, and anything else is given a single indent as needed.

I initially tried using tree-sitter for this, but ran into too many errors with the existing asm grammar and ended up using regexes instead. In the future it may make sense to switch over to using tree-sitter for this feature once the existing grammar is better, or if we write our own.

Closes #42

misc cleanup

Remove unecessary clone

Fix logic bug for file word grab
@WillLillis
Copy link
Collaborator Author

Looking at this again, I don't think it's a good idea to tackle this with regexes. Going to hold off on formatting until we have a more accurate tree-sitter grammar (or some other equivalent tool that understands the code at more than a textual level).

One promising lead is amanq's WIP parser described in this comment.

@WillLillis WillLillis closed this Jun 29, 2024
@WillLillis WillLillis mentioned this pull request Jun 29, 2024
13 tasks
@WillLillis WillLillis deleted the format branch July 7, 2024 22:15
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 this pull request may close these issues.

[feature] Enable asm-lsp to format the assembly file code
1 participant