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

[Question | Help] Stylua does not use stylua.toml configuration to format #145

Closed
hankertrix opened this issue Dec 4, 2024 · 2 comments
Closed

Comments

@hankertrix
Copy link

I am not using this plugin to configure efm-language-server, and I am instead using the config.yaml file to configure the language server. However, I copied my configurations from the defaults in this repository, and they work just fine.

For some strange reason, stylua called by the efm-language-server is not reading the stylua.toml or .stylua.toml files in my project directories. Here is the stylua part of my config.yaml:

tools:
  lua-stylua: &lua-stylua
    format-command: >
       stylua --color Never \
         ${--range-start:charStart} ${--range-end:charEnd} -
    format-can-range: true
    format-stdin: true
    root-markers:
      - "stylua.toml"
      - ".stylua.toml"

I have no idea why this is happening, especially since prettierd works just fine and does properly read the .prettierrc file.

I am also currently using stylua version v2.0.1, but I don't think that is an issue, since running stylua in the Neovim terminal works just fine, and null-ls also works just fine.

@creativenull
Copy link
Owner

creativenull commented Dec 4, 2024

I've been having the same issue as well with stylua v2. Looks like there also needs to be a --stdin-filepath to the included in the cli.

I've updated the plugin with this inclusion.

For your config.yaml it would be:

    format-command: >
       stylua --color Never \
         ${--range-start:charStart} ${--range-end:charEnd} --stdin-filepath ${INPUT} -

@hankertrix
Copy link
Author

The command works perfectly! Thank you!

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

No branches or pull requests

2 participants