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!: remove --preview flag from Ruff server #3241

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

dhruvmanila
Copy link
Contributor

@dhruvmanila dhruvmanila commented Jul 18, 2024

Now that the server is stabilized, the --preview flag isn't required to run it from v0.5.3.

This PR removes the need of the --preview flag, update the documentation.

Question

This is a breaking change because without the --preview flag, ruff will throw an error for previous versions. It's only from 0.5.3 that the flag isn't required.

Now, the reason the flag needs to be removed is because the flag itself would turn on preview features from both the linter and the formatter, as it should.

Can the maintainers guide me on how to go about making this kind of change? Is this ok to do so?

In our VS Code extension, we check the ruff version and only then use the --preview flag (reference).

@dhruvmanila dhruvmanila requested a review from glepnir as a code owner July 18, 2024 18:27
@glepnir glepnir merged commit 70d1c2c into neovim:master Jul 19, 2024
9 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/ruff-stable branch July 20, 2024 04:38
@jdhao
Copy link

jdhao commented Nov 5, 2024

@dhruvmanila hi, I am following config from this change, but it does not work anymore. With config in the doc, i see following error when I open python file:

LSP[ruff] Ruff received invalid client settings - falling back to default client settings.

My ruff version is 0.7.1, and instead the following config works

require('lspconfig').ruff.setup({
  settings = {
    -- Ruff language server settings go here
  },
})

@dhruvmanila
Copy link
Contributor Author

@jdhao You only need to pass in the table if you want to add any client settings. For example,

require('lspconfig').ruff.setup({
  init_options = {
    settings = {
      lineLength = 100
    },
  }
})

Otherwise, you can just call setup without any arguments:

require('lspconfig').ruff.setup()

The example in the docs is mentioned to highlight where should the client settings go. Now, if it's empty, Neovim will serialize that into an empty array (not an empty dictionary) and that's where the error is being raised. This is related to astral-sh/ruff#11566 which solved it for an empty dictionary.

The config that you've provided works but if you include any client settings in it, they won't be considered because the server won't see it. Currently, the Ruff server supports reading settings only from init_options.settings field as the example states.

@jdhao
Copy link

jdhao commented Nov 6, 2024

Okay, thanks for the explanation. But I think the general convention in neovim is that if empty Lua table is provided, the default setting will be used. So I am surprised that an empty table leads to errors. After providing some settings, I don't see the error anymore 👍

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.

3 participants