Skip to content

ruff server: Support a custom TOML configuration file#11140

Merged
snowsignal merged 3 commits intomainfrom
jane/server/settings/custom-configuration-toml
Apr 26, 2024
Merged

ruff server: Support a custom TOML configuration file#11140
snowsignal merged 3 commits intomainfrom
jane/server/settings/custom-configuration-toml

Conversation

@snowsignal
Copy link
Copy Markdown
Contributor

@snowsignal snowsignal commented Apr 25, 2024

Summary

Closes #10985.

The server now supports a custom TOML configuration file as a client setting. The setting must be an absolute path to a file. If the file is called pyproject.toml, the server will attempt to parse it as a pyproject file - otherwise, it will attempt to parse it as a ruff.toml file, even if the file has a name besides ruff.toml.

If an option is set in both the custom TOML configuration file and in the client settings directly, the latter will be used.

Test Plan

  1. Create a ruff.toml file outside of the workspace you are testing. Set an option that is different from the one in the configuration for your test workspace.
  2. Set the path to the configuration in NeoVim:
require('lspconfig').ruff.setup {
    init_options = {
      settings = {
        configuration = "absolute/path/to/your/configuration"
      }
    }
}
  1. Confirm that the option in the configuration file is used, regardless of what the option is set to in the workspace configuration.
  2. Add the same option, with a different value, to the NeoVim configuration directly. For example:
require('lspconfig').ruff.setup {
    init_options = {
      settings = {
        configuration = "absolute/path/to/your/configuration",
        lint = {
          select = []
        }
      }
    }
}
  1. Confirm that the option set in client settings is used, regardless of the value in either the custom configuration file or in the workspace configuration.

@snowsignal snowsignal added configuration Related to settings and configuration server Related to the LSP server labels Apr 25, 2024
@snowsignal snowsignal changed the title ruff server supports a custom TOML configuration file ruff server: support a custom TOML configuration file Apr 25, 2024
@snowsignal snowsignal changed the title ruff server: support a custom TOML configuration file ruff server: Support a custom TOML configuration file Apr 25, 2024
@snowsignal snowsignal force-pushed the jane/server/settings/custom-configuration-toml branch from dc86642 to 39f1905 Compare April 25, 2024 02:40
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 25, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@GaetanLepage
Copy link
Copy Markdown
Contributor

In the absence of a project configuration for ruff, will the LS load the seetings from ~/.config/ruff/ruff.toml like the CLI does ?

@charliermarsh
Copy link
Copy Markdown
Member

It should yes -- not sure if it does yet though @snowsignal?

@snowsignal
Copy link
Copy Markdown
Contributor Author

snowsignal commented Apr 26, 2024

@GaetanLepage @charliermarsh I actually don't think we do this, yet - I've filed an issue to support this.

@snowsignal snowsignal force-pushed the jane/server/settings/custom-configuration-toml branch from 39f1905 to a266d05 Compare April 26, 2024 21:30
@snowsignal snowsignal force-pushed the jane/server/settings/custom-configuration-toml branch from 3a1c00b to 1e944ec Compare April 26, 2024 22:20
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

I have one suggestion to simplify the implementation and semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Related to settings and configuration server Related to the LSP server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ruff server should support an optional TOML configuration file

4 participants