mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.98k stars 209 forks source link

[QUESTION] No pop-up window when using keybinding for `vim.diagnostic.open_float()` #373

Closed mar4th3 closed 1 year ago

mar4th3 commented 1 year ago

Hi, first of all thanks for this cool plugin.

I use lsp-zero to set up the LSP and added a minimal configuration for nvim-lint with vale using lazy.nvim:

  {
    "mfussenegger/nvim-lint",
    init = function()
      vim.api.nvim_create_autocmd({ "BufWritePost" }, {
        callback = function()
          require("lint").try_lint()
        end,
      })

      local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")

      local function get_cur_file_extension(bufnr)
        bufnr = bufnr or 0
        return "." .. vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ':e')
      end

      local vale = require('lint').linters.vale
      vale.cmd = mason_path .. "packages/vale/vale"
      vale.args = {
        "--config", os.getenv("HOME") .. "/.config/vale/vale.ini",
        '--no-exit',
        '--output',
        'JSON',
        '--ext', get_cur_file_extension
      }

      require('lint').linters_by_ft = {
        latex = { 'vale' },
        markdown = { 'vale' },
        sh = { 'shellcheck' }
      }
    end,
  }

When trying on this sentence:

So good is writing which is relatively nice.

Everything worsk flawlessly besides one minor thing.

In lsp-zero the keybinding gl is mapped to vim.diagnostic.open_float (see here).

If I use the keybinding however no floating window pops up. If I insted position the cursor on the offending line and type in the command bar vim.diagnostic.open_float() the window does pop up.

I would appreciate very much if you could please help me sort this out. The question is: is this stemming from nvim-lint or lsp-zero. If the first, could you please provide any pointers on how to solve the issue?

Thank you!

arnevm123 commented 1 year ago

I think the issue can be that lsp-zero is only setting it's keymaps on buffer where there's an LSP active. Does this issue also happen when you're in a buffer where you have lsp active?

If this is the case you can just add a keymap for gl to vim.diagnostic.open_float() in your config, this should not interfere with the lsp-zero behaviour.

mar4th3 commented 1 year ago

That was indeed the culprit. Thank you very much for helping me out.