stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.58k stars 136 forks source link

bug: ruff showing as unavailable #413

Closed EdmundsEcho closed 1 month ago

EdmundsEcho commented 1 month ago

Neovim version (nvim -v)

0.10.0

Operating system/version

MacOs 14.4

Add the debug logs

Log file

16:53:39[INFO] Run stylua on /Users/edmund/dotfiles/nvim-plugins.lua 16:53:39[DEBUG] Run command: { "stylua", "--config-path", "/Users/edmund/.stylua.toml", "--search-parent-directories", "--stdin-filepath", "/Users/edmund/dotfiles/nvim-plugins.lua", "-" } 16:53:39[DEBUG] Run CWD: /Users/edmund 16:53:39[DEBUG] stylua exited with code 0 16:55:20[DEBUG] Running formatters on /Volumes/active-etl/tnc-py/tnc/www/routes/inspection.py: {} 16:55:20[DEBUG] Running LSP formatter on /Volumes/active-etl/tnc-py/tnc/www/routes/inspection.py

Describe the bug

The :checkhealth reports that ruff-lsp is unavailable. It is true that ruff-lsp does not have a configuration file like prettier, however it is configured and seems to be working (it formats the py file.

============================================================================== conform: require("conform.health").check()

conform.nvim report ~

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

run checkhealth

Expected Behavior

rust-lsp should be OK despite not having a configuration file.

Minimal example file

xx

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/conform.nvim",
    config = function()
      require("conform").setup({
        log_level = vim.log.levels.DEBUG,
        -- add your config here
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

    {
      "stevearc/conform.nvim",
      lazy = false,
      event = { "BufWritePre", "BufNewFile" },
      cmd = { "ConformInfo" },
      config = function() 
        return {
        log_level = vim.log.levels.DEBUG,
        -- Conform will notify you when a formatter errors
        notify_on_error = true,
        format_on_save = conform_format_params,
        formatters = {
            stylua = {
                autosave = 1,
                prepend_args = { "--config-path", stylua_cfg_file },
            },

            ruff_lsp = {
                autosave = 1,
            },
        },
        formatters_by_ft = {
            javascript = { { "prettierd", "prettier" } }, -- first available

            lua = { "stylua" },
            python = {
                "ruff-lsp", 
            },

        },
}

 end,
      dependencies = {
        "nvim-lua/plenary.nvim",
      },
    }

Additional context

xx

stevearc commented 1 month ago

This is because ruff-lsp or ruff_lsp are not built-in formatters. You're attempting to use a formatter with no definition.

Also, if you want to use ruff-lsp for formatting, you should set it up as a LSP server and then conform will automatically use it if you format with lsp_fallback = true. There's no need to do any conform-specific configuration to format with a LSP