rachartier / tiny-inline-diagnostic.nvim

A Neovim plugin that display prettier diagnostic messages. Display diagnostic messages where the cursor is, with icons and colors.
MIT License
435 stars 10 forks source link

Diagnostics not shown from nvim-lint #40

Closed danielyrovas closed 2 months ago

danielyrovas commented 2 months ago

I've set this plugin up alongside nvim-lint. I have had no issue getting the (excellent) UI popping up for the errors from lua_lsp, however, I can't seem to get diagnostics from nvim-lint to appear. I believe they should work :tm: because nvim-lint is supposed to report the warnings to vim.diagnostic. I can see the diagnostics from nvim-lint in the normal neovim popup if I use vim.diagnostic.open_float()

I'm using no config:

{
    "rachartier/tiny-inline-diagnostic.nvim",
    event = "VeryLazy",
    opts = {},
},
rachartier commented 2 months ago

Hello,

Could you please provide me with a code example where the linting issue occur with the plugin?

It would make debugging easier!

Thanks.

danielyrovas commented 2 months ago

Yeah sure, here is a setup that shows the issue - this config doesn't have LSP setup, only nvim-lint.

ruby.rb ```ruby def stomp("literal") end ```

rubocop: 1.62.1

nvim --version ``` NVIM v0.11.0-nightly+0346666 Build type: Release LuaJIT 2.1.1713773202 system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/nix/store/qi698aa2xcsg6jk2s1jw5fdz64fq3ild-neovim-unwrapped-nightly/share/nvim" ```
NVIM_APPNAME=nvd nvim -u config.lua ruby.rb ```lua -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) vim.g.mapleader = " " vim.g.maplocalleader = "\\" vim.diagnostic.config({ virtual_text = false }) require("lazy").setup({ spec = { { "rachartier/tiny-inline-diagnostic.nvim", event = "VeryLazy", opts = {}, }, { "mfussenegger/nvim-lint", event = "VeryLazy", opts = {}, config = function(_, opts) local lint = require("lint") -- lint.linters_by_ft = {} vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, { callback = function() lint.try_lint(nil, { ignore_errors = true }) end, }) end, }, }, }) ```

here is a screenshot with the diagnostics: image

rachartier commented 2 months ago

I don't have the same linting messages as you, but it seems to be working (no LSP on Ruby here): image

Maybe it comes from your linter configuration?

danielyrovas commented 2 months ago

Idk what nvim-lint was picking up before, but if I set nvim-lint to only use rubocop I get the same lint messages as you, but still no diagnostic from tiny-inline :(

lint.linters_by_ft = {
    ruby = { "rubocop" },
}

thanks for the great project btw

rachartier commented 2 months ago

Thanks!

Just to be sure, can you try setting opts like so:

require("tiny-inline-diagnostic").setup({
    options = {
        multilines = true,
    },
})
danielyrovas commented 2 months ago

Thanks, but same result unfortunately: image

I also tried nvim v10 and same result.

rachartier commented 2 months ago

Are you lazy loading nvim-lint ? If so, just try to disable it, to check if it comes from here

danielyrovas commented 2 months ago

It persists if I use this config with lazy=false

config ```lua -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) vim.g.mapleader = " " vim.g.maplocalleader = "\\" vim.diagnostic.config({ virtual_text = false }) require("lazy").setup({ spec = { { "rachartier/tiny-inline-diagnostic.nvim", event = "VeryLazy", lazy = false, opts = { options = { multilines = true, }, }, }, { "mfussenegger/nvim-lint", event = "VeryLazy", lazy = false, opts = {}, config = function(_, opts) local lint = require("lint") lint.linters_by_ft = { ruby = { "rubocop" }, } vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, { callback = function() lint.try_lint(nil, { ignore_errors = true }) end, }) end, }, }, }) ```
rachartier commented 2 months ago

Thank you very much for this minimal config.

I've found the issue: inside the plugin, I create an autocmd for the LspEvent, which never triggers in your case.

So, I've added options.overwrite_events, which ideally shouldn't be modified, but in your case, it's the only solution.

What you need to do is set options.overwrite_events = { "BufWritePre" }, and it should work.

007pig commented 2 months ago

The optimal set of overwrite_events appears to be { "DiagnosticChanged" }.