astral-sh/ruff-lsp

kickstart.nvim code action difficulties

jturner116 opened this issue · 3 comments

Apologies if I have missed something obvious, I am trying to use Ruff more regularly but am not super experienced.

I've successfully installed ruff-lsp with Mason in kickstart neovim and am getting correct highlighting in Python files, but my Fix All code action does not seem to do anything. It doesn't remove trailing whitespace or address any of the other warnings. I have tried modifications to my init.lua found in other issues but haven't had any success with those either.

running Ubuntu 22.04 WSL
Ruff version: 0.1.7
Mason setup from kickstart

require('mason').setup()
require('mason-lspconfig').setup()

-- Enable the following language servers
--  Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
--  Add any additional override configuration in the following tables. They will be passed to
--  the `settings` field of the server config. You must look up that documentation yourself.
--
--  If you want to override the default filetypes that your language server will attach to you can
--  define the property 'filetypes' to the map in question.
local servers = {
  -- clangd = {},
  -- gopls = {},
  -- pyright = {},
  rust_analyzer = {},
  ruff_lsp = {},
  -- tsserver = {},
  -- html = { filetypes = { 'html', 'twig', 'hbs'} },

  lua_ls = {
    Lua = {
      workspace = { checkThirdParty = false },
      telemetry = { enable = false },
      -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
      diagnostics = { disable = { 'missing-fields' } },
    },
  },
}

Hey, if possible can you please provide some additional context? Like, Ruff configuration if any, Python code, the rule whose diagnostic is not being fixed (what diagnostic do you see?), etc.

Of course, thanks for the quick response!

No ruff configuration, working from barebones install with kickstart.

Here's the example I'm testing
image

If I run ruff from command line, I can get it to fix the trailing whitespace, but the code action doesn't. The imports code action is working though, do I need to alter the config to allow Fix All to address whitespace?

Thanks for the context! How are you running it from the command-line? You might be selecting the W291 rule manually as it isn't enabled by default. This is the reason that the "Fix All" code action doesn't fix it. You can refer to the default configuration here: https://github.com/astral-sh/ruff#configuration.

I hope this answers your question. I'll close the issue, but feel free to ask any other questions if required.