Skip to content

Conversation

@joedevivo
Copy link

What does this PR do?

prettier wasn't respecting my .editorconfig. This PR creates an option format.editorConfig, and when it's true, will pass that into prettier, respecting those settings if you opt in.

What issues does this PR fix or reference?

Is it tested? How?

Built locally, tested in neovim with nvim-lspconfig.

opts = {
  servers = {
    yamlls = {
      cmd = "path/to/local/yaml-language-server",
      settings = {
        yaml = {
          format = {
            enable = true,
            editorConfig = true,
          },
        },
      },
    },
  },
}

@coveralls
Copy link

Coverage Status

coverage: 83.961%. remained the same
when pulling 6b1b261 on joedevivo:editorconfig
into d17039f on redhat-developer:main.

@datho7561
Copy link
Contributor

In the current configuration, what does this setting default to? I think it would be helpful to enable it by default, unless you think that will be annoying (if someone has configured formatting settings in an .editorconfig they probably want them respected)

const prettierOptions: Options = {
parser: 'yaml',
plugins: [yamlPlugin, estreePlugin],
editorConfig: options.editorConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this works (I've tested manually in VS Code and it doesn't seem to work). I don't see editorConfig as a parameter in the documentation. To get it to work, you'll need to fetch the config for the file using https://prettier.io/docs/api#prettierresolveconfigfileurlorpath--options, then use the result from that as the config in the call to format instead of the prettierOptions defined here. (or, somehow handle merging the fetched prettier/editorconfig with what the language server has been told).

@datho7561 datho7561 moved this from Todo to In Progress in Java Tooling Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants