Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add a custom opener to func_map #45

Closed
przepompownia opened this issue Nov 19, 2021 · 9 comments
Closed

Allow to add a custom opener to func_map #45

przepompownia opened this issue Nov 19, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@przepompownia
Copy link

Feature description

Hi,

it seems for me (i'm fresh in Lua) that the set of allowed keys of func_map is restricted to action_funcref from keymap.

I'd like to attach a custom opener that does an action similar to tab drop (see links below).

Describe the solution you'd like

Please allow to attach a function (as the opener) that get the path, (and, if provided) line and column to allow make a customized jumping.

Additional context

neovim/neovim#14567
https://github.com/przepompownia/vim-arctgx/blob/master/plugin/tab.vim#L11

@przepompownia przepompownia added the enhancement New feature or request label Nov 19, 2021
@kevinhwang91
Copy link
Owner

What's different between drop and tab drop? If they are the same, I can add a drop action.

@kevinhwang91
Copy link
Owner

Oh, my bad. tab drop will open a new tab for target buffer if the buffer is not displayed but drop will switch to target buffer in the current window.

@przepompownia
Copy link
Author

przepompownia commented Nov 19, 2021

Maybe tab drop could be present by default in action_funcref but it is not sufficient for me - I do not use tab drop because of the bug mentioned above (that exist in traditional Vim too).

kevinhwang91 added a commit that referenced this issue Dec 3, 2021
Add tabc, drop and tab drop jump commands
kevinhwang91 added a commit that referenced this issue Dec 3, 2021
Add tabc, drop and tab drop jump commands
@kevinhwang91
Copy link
Owner

I have added three new jump commands. All of them will close qf window, you can wrap the command by yourself.

FYI: #39

@przepompownia
Copy link
Author

I see that

lua require('bqf.qfwin.handler').open(true, 'TabDrop')

works for me when I call it manually from the cmdline, but filetype autocommand

nmap <buffer> <CR> <Cmd>lua require('bqf.qfwin.handler').open(true, 'TabDrop')<CR>

seems to be overwritten by <Cmd>lua require('bqf.qfwin.handler').open(false)<CR>

How to attach such custom funcref? Why not to allow overriding action_funcref from config (if it's currently impossible)?

@kevinhwang91
Copy link
Owner

I see that

lua require('bqf.qfwin.handler').open(true, 'TabDrop')

works for me when I call it manually from the cmdline, but filetype autocommand

No TabDrop but tab drop

nmap <buffer> <CR> <Cmd>lua require('bqf.qfwin.handler').open(true, 'TabDrop')<CR>

seems to be overwritten by <Cmd>lua require('bqf.qfwin.handler').open(false)<CR>

How to attach such custom funcref? Why not to allow overriding action_funcref from config (if it's currently impossible)?

You can, RTFM

@przepompownia
Copy link
Author

No TabDrop but tab drop

tab drop causes unwanted side effects (see links in the initial message) so I need to use such custom replacement.

@kevinhwang91
Copy link
Owner

FYI: #39

@przepompownia
Copy link
Author

require('bqf').setup({
  auto_enable = true,
  func_map = {
    open = '',
  }
})

allows to disable nmap <CR> defined by the plugin so now I can use the mapping mentioned above.

przepompownia added a commit to przepompownia/nvim-bqf that referenced this issue Nov 21, 2023
For example
```lua
local function tabDropHandler()
  require('bqf.qfwin.handler').open(true, function(fname)
    customTabDrop(fname))
  end)
end
local function configureWindow()
  vim.keymap.set({'n'}, '<CR>', tabDropHandler, {buffer = true})
end

local augroup = vim.api.nvim_create_augroup ('BqfMappings', {clear = true })
vim.api.nvim_create_autocmd ('FileType', {
  group = augroup,
  pattern = 'qf',
  callback = configureWindow,
})
```

kevinhwang91#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants