kevinhwang91 / nvim-bqf

Better quickfix window in Neovim, polish old quickfix window.
BSD 3-Clause "New" or "Revised" License
1.69k stars 30 forks source link

Don't show preview for folded lines #106

Closed n0bra1n3r closed 1 year ago

n0bra1n3r commented 1 year ago

Feature description

I'm using foldexpr to fold messages in the quickfix window. Currently, moving the cursor over the folds shows a preview window for the first/last entries in the fold (depending on which direction the cursor came from). It would be good if there was a way to disable showing the preview window if the current line is a fold.

image

Describe the solution you'd like

Add a configuration to disable preview for folded lines. Optionally, allow showing a preview for only the first line contained in the fold, if that's possible.

Additional context

No response

rockyzhang24 commented 1 year ago

Here is a feasible workaround. Create a file ~/.config/nvim/ftplugin/qf.lua with the code below

local bqf = require('bqf')
local preview_enabled = true

vim.api.nvim_create_autocmd({ "CursorMoved" }, {
  buffer = vim.fn.bufnr(),
  callback = function()
    if vim.fn.foldlevel('.') > 0 and preview_enabled then
      preview_enabled = bqf.hidePreviewWindow()
    elseif not preview_enabled then
      preview_enabled = bqf.showPreviewWindow()
    end
  end
})
kevinhwang91 commented 1 year ago

From the default keymap, you will be aware of bqf doesn't suggest users use fold in qf window. However, users can change the keymap and fold lines by themselves. Back to this issue, I think @rockyzhang24 's script should work for you, bqf doesn't support this feature until finding a workflow combined with the fold feature.