stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.84k stars 110 forks source link

Feature: add action to open quickfixlist #365

Closed kevintraver closed 5 months ago

kevintraver commented 5 months ago

Add action which also opens the quickfix list after sending items to it.

stevearc commented 5 months ago

The proposed addition doesn't scale well. There are already 4 different actions for behavior that could be parameterized (send_to_qflist, add_to_qflist, send_to_loclist, add_to_loclist). If we add another boolean open then logically we would need to double this number to add a _and_open variant to each. Arguably I shouldn't have even split it as much as it currently is, but I definitely don't want to split it out further. The preferred way of doing this would be to define your own keymap that leverages the built-in action. Something like:

require("oil").setup({
  keymaps = {
    ["<C-q>"] = {
      callback = function()
        require("oil.actions").send_to_qflist.callback()
        vim.cmd.copen()
      end,
      desc = "Send items to quickfix and open the quickfix"
    }
  }
})
kevintraver commented 4 months ago

That makes sense. Thank you for the explanation and keymap example!