mrcjkb / haskell-tools.nvim

🦥 Supercharge your Haskell experience in neovim!
GNU General Public License v2.0
475 stars 19 forks source link

how can I change warnings/errors not to report inline but on hover? #236

Closed MaciekFlis closed 1 year ago

MaciekFlis commented 1 year ago

Question

I don't want my warnings or errors to show inline, I'm never able to read full text.

reported_warning

how can I make it display in a hover window, like in this gif in readme:

docu_gif

mrcjkb commented 1 year ago

Check out the vim.diagnostic API (:h diagnotic in neovim).

For floating windows, you want [vim.diagnostic.open_float()](https://neovim.io/doc/user/diagnostic.html#vim.diagnostic.open_float()), and possibly goto_prev and goto_next to navigate them.

Personally, I have the following keymaps:

local diagnostic= vim.diagnostic
local keymap = vim.keymap
local severity = diagnostic.severity

local opts = { noremap = true, silent = true }
keymap.set('n', '<space>e', function()
  local _, winid = diagnostic.open_float(nil, { scope = 'line' })
  vim.api.nvim_win_set_config(winid or 0, { focusable = true })
end, opts)
keymap.set('n', '[d', diagnostic.goto_prev, opts)
keymap.set('n', ']d', diagnostic.goto_next, opts)
keymap.set('n', '[e', function()
  diagnostic.goto_prev {
    severity = severity.ERROR,
  }
end, opts)
keymap.set('n', ']e', function()
  diagnostic.goto_next {
    severity = severity.ERROR,
  }
end, opts)
keymap.set('n', '[w', function()
  diagnostic.goto_prev {
    severity = severity.WARN,
  }
end, opts)
keymap.set('n', ']w', function()
  diagnostic.goto_next {
    severity = severity.WARN,
  }
end, opts)
keymap.set('n', '[h', function()
  diagnostic.goto_prev {
    severity = severity.HINT,
  }
end, opts)
keymap.set('n', ']h', function()
  diagnostic.goto_next {
    severity = severity.HINT,
  }
end, opts)

You may also want to check out this plugin.

MaciekFlis commented 1 year ago

this is exactly what I needed, thank you! do you know how to hide the current inline diagnostic?

mrcjkb commented 1 year ago

Thanks for the donation ☺️

Yes, you can disable them with

vim.diagnostic.config({
  virtual_text = false,
})
mrcjkb commented 1 year ago

@all-contributors please add @MaciekFlis for financial

allcontributors[bot] commented 1 year ago

@mrcjkb

I've put up a pull request to add @MaciekFlis! :tada:

MaciekFlis commented 1 year ago

works like a charm, thank you