rachartier / tiny-inline-diagnostic.nvim

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

Diagnostics not showing up #9

Closed Davidyz closed 1 week ago

Davidyz commented 1 week ago

Hi, I set up this plugin as follows:

{
    "rachartier/tiny-inline-diagnostic.nvim",
    event = { "LspAttach" }, -- tried "VeryLazy" from the README and it didn't help.
    dependencies = { "folke/tokyonight.nvim", "neovim/nvim-lspconfig" },
    init = function()
      vim.diagnostic.config({
        virtual_text = false,
      })
    end,
    main = "tiny-inline-diagnostic",
    cond = utils.no_vscode,
    opts = {},
  }

and the diagnostics rarely show up (sometimes they do, mostly not. I wasn't able to identify the reason) when I move the cursor to a location with a diagnostic. It works as intended when I remove buffer = event.buf from here and here. I'm not sure how to further debug. Is this a bug or is there something else in my config that might be messing up with the autocmd?

rachartier commented 1 week ago

Hello,

What languages and LSP are you using ? Did you try for exemple in Lua?

Maybe try to do a minimal config (a .lua with only lazy and the plugin, then execute nvim -U minimal.lua) to see if the bug is here ?

Davidyz commented 1 week ago

I tried lua with lua_ls and python with basedpyright and ruff. The same issue happened in both cases. I also tried manually setting diagnostics without any language servers and it still doesn't work properly.

Here's the minimal init.lua used for the testing:

local diagnostic = {
  {
    lnum = 2,
    col = 0,
    message = "This is a custom diagnostic message.",
    severity = vim.diagnostic.severity.ERROR,
    source = "my_linter",
  },
  {
    lnum = 3,
    col = 0,
    message = "This is a custom diagnostic message.",
    severity = vim.diagnostic.severity.ERROR,
    source = "my_linter",
  },
}

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup(
  {
    {
      "rachartier/tiny-inline-diagnostic.nvim",
      init = function()
        vim.diagnostic.config({
          virtual_text = false,
        })
      end,
      main = "tiny-inline-diagnostic",
      opts = {},
      lazy = false,
    },
  },
  { lazy = false }
)

vim.api.nvim_create_autocmd("CursorHold", {
  callback = function()
    vim.diagnostic.set(vim.api.nvim_create_namespace("test"), 0, diagnostic, {})
  end,
})
rachartier commented 1 week ago

Hello,

It's correct that it won't work with this minimal example, as I use LspAttach autocmd to attach to the correct buffer. In your example, no LSP is attached so it can't work. If you replace LspAttach in diagnostic.lua with something like BufEnter, it works as intended.

image

I think the problem could be on your side. I use BasedPyright at work, and I have never had these issues. If you can send me your dotfiles repository, I could check it out!

rachartier commented 1 week ago

Can you try to update the plugin ? I think maybe fix #12 can resolves your issue.

Davidyz commented 1 week ago

unfortunately it doesn't fix the issue. So far the only way I've found that can fix the problem is to remove buffer = event.buf as mentioned earlier in the issue. My current setup is here using my own fork that implements my fix (or hack) and it actually works as intended.

rachartier commented 1 week ago

I don't really know what to say, i'm sorry... I've cloned your config, changed your fork by this repo, and all worked fine with basedpyright:

image

image

image

You need to make sure that you've correctly deleted the plugin (after changing the repo), by pressing x on the plugin name in lazy.nvim, then reopen neovim to make it install the latest version.

Davidyz commented 1 week ago

Thanks for your help anyways. I'll close this issue for now since it's not reproducible. I'll come back if I ever figure this out. Thanks.

rachartier commented 1 week ago

I'm sorry that I can't help you more... Do not hesitate to tell me if you've found something !

Have a nice day