Skip to content

Added formatting requirements using with StyLua#36

Closed
rcampos2029 wants to merge 3 commits intoaaronik:mainfrom
rcampos2029:format
Closed

Added formatting requirements using with StyLua#36
rcampos2029 wants to merge 3 commits intoaaronik:mainfrom
rcampos2029:format

Conversation

@rcampos2029
Copy link
Copy Markdown

  • Lua files were formatted using stylua, with the formatting defined in stylua.toml
  • Two make targets were added: check-fmt which checks the formatting of lua files and fmt which formats the file
  • Steps were added to the existing CI to check the formatting of the luafiles in the codebase.

This pr is similar to that filed in GPTModels

Running CI locally fails with the following error:

 No handler for set-lang-from-info-string

This appears to be due to using a newer version of treesitter. I'll dig into this more, but the githiub CI may pass without additional changes needed.

sudo apt-get install lua-check -y --no-install-recommends
make check

- name: Check formatting
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this second block

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I meant to separate the "Install Stylua" stage from the "Check formatting" stage, but I accidently left the make check-fmt call in the first block. Do you want these two put together? I thought they may be better separated so that it would be easier to debug if it is the stylua installation that fails.

@aaronik
Copy link
Copy Markdown
Owner

aaronik commented May 15, 2025

The tests are still passing on the main branch, so I don't think there's some weird treesitter difference. I think these changes actually broke something

@rcampos2029
Copy link
Copy Markdown
Author

Ack. I'll take a look later today

@rcampos2029
Copy link
Copy Markdown
Author

Ah I found the issue: stylua updated the lua files in the fixture/ directory as well, which caused the lua-specific checks to fail. I get a bunch of errors with the markdown spec when I run the tests locally, even though I do have the markdown parser installed. How does the CI install the parsers needed by the tests?

We had an unexpected error:     { {
    descriptions = { "Movement in a markdown file" },
    msg = "/usr/share/nvim/runtime/lua/vim/treesitter/query.lua:906: No handler for set-lang-from-info-string!\n\nstack traceback:\n\t/usr/share/n
vim/runtime/lua/vim/treesitter/query.lua:906: in function '_apply_directives'\n\t/usr/share/nvim/runtime/lua/vim/treesitter/query.lua:1106: in fun
ction '(for generator)'\n\t/usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:1012: in function '_get_injections'\n\t/usr/share/nvim/runt
ime/lua/vim/treesitter/languagetree.lua:623: in function '_parse'\n\t/usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:572: in function 
'parse'\n\t./tests/load_fixture.lua:35: in function 'load_fixture'\n\t...start/treewalker.nvim/tests/treewalker/markdown_spec.lua:9: in function '
w'\n\t...te/pack/packer/start/plenary.nvim/lua/plenary/busted.lua:167: in function 'run_each'\n\t...te/pack/packer/start/plenary.nvim/lua/plenary/
busted.lua:174: in function 'it'\n\t./tests/treewalker/helpers.lua:62: in function 'ensure_has_parser'\n\t...start/treewalker.nvim/tests/treewalke
r/markdown_spec.lua:12: in function <...start/treewalker.nvim/tests/treewalker/markdown_spec.lua:7>\n"
  }, 

@aaronik
Copy link
Copy Markdown
Owner

aaronik commented May 15, 2025

Oo I do not know what that No handler for set-lang-from-info-string thing is - I've never seen it before.

Hey listen I'm going through these stylua changes and am feeling uncomfortable with the changes. TBH I don't think it's cleaning up the code at all, I think the code is going from quite clean and expressive, to often cases much less so. Some of the ternaries that are on one line are on one line for a reason - it reads better to me. The indentation of the comments is to help it read better. The multiline if statements help it read better - a lot of times this stylua is turning clean one lined things into multiple lines, but then turning clean multiple line things into very hard to read one line things.

I like the idea of a style guide, but what this is doing to my code here, not really comfortable with it.

I know I asked for you to add this to this repository, and I was excited about it, but then when I saw what it was doing... I got uncomfortable with it. So I think I need to just nix this from this repo.

Really sorry to lead you on on this, and I really, really appreciate you taking the time to add it here, especially since it required some trouble shooting. Thank you @rcampos2029, I appreciate your contribution!

@rcampos2029
Copy link
Copy Markdown
Author

Oo I do not know what that No handler for set-lang-from-info-string thing is - I've never seen it before.

Hey listen I'm going through these stylua changes and am feeling uncomfortable with the changes. TBH I don't think it's cleaning up the code at all, I think the code is going from quite clean and expressive, to often cases much less so. Some of the ternaries that are on one line are on one line for a reason - it reads better to me. The indentation of the comments is to help it read better. The multiline if statements help it read better - a lot of times this stylua is turning clean one lined things into multiple lines, but then turning clean multiple line things into very hard to read one line things.

I like the idea of a style guide, but what this is doing to my code here, not really comfortable with it.

I know I asked for you to add this to this repository, and I was excited about it, but then when I saw what it was doing... I got uncomfortable with it. So I think I need to just nix this from this repo.

Really sorry to lead you on on this, and I really, really appreciate you taking the time to add it here, especially since it required some trouble shooting. Thank you @rcampos2029, I appreciate your contribution!

No worries! Thanks for showing me this plugin. I've only been using it a couple of days and it's already made navigating through code a lot easier.

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.

2 participants