danielfalk / smart-open.nvim

Neovim plugin for fast file-finding
MIT License
498 stars 25 forks source link

Feature request: Exit/close dialog on Control+C #41

Closed f-person closed 5 months ago

sahilsehwag commented 1 year ago

This used to work, but after recents updates in smart-open, Ctrl+c to close the telescope is not working for smart-open. This fix would be great, since this change makes it inconsistent with Telescope general mappings. And Its inconvenient/frustrating to close smart-open window by pressing escape twice

Can we change the mapping for this action (https://github.com/danielfalk/smart-open.nvim/blob/beb74b0cb0d6947963b36b6022dfd23c9b2a1e27/lua/telescope/_extensions/smart_open/picker.lua#L62)

And it would be great if we can see the smart-open mappings in telescope help window (when we press ? to see the bindings in current telescope instance)

danielfalk commented 1 year ago

Yeah you're right. This needs to be configurable. I added this as a way of doing some basic buffer management within the finder. For me it works nicely, but then I have telescope set up to close with a single escape, and I know that's not necessarily common.

Anybody want to take this on? I can at some point, but if anyone can do so quicker and wants to contribute, I'd appreciate.

And my apologies for the regression! I didn't know C-c was used by anybody for quickly closing.

tanishqmanuja commented 6 months ago

Is there a workaround ?

EDIT (made on myself for now):

-- Fix Telescope Prompt (smart-open)
vim.api.nvim_create_autocmd('FileType', {
  group = vim.api.nvim_create_augroup('user-telescope-picker', { clear = true }),
  pattern = { 'TelescopePrompt' },
  callback = function(event)
    vim.keymap.set('i', '<C-c>', function()
      require('telescope.actions').close(event.buf)
    end, { noremap = true, silent = true, buffer = event.buf })
  end,
})
danielfalk commented 6 months ago

If you can turn this into a PR I'd happily take it. I've just been too busy to get to these issues, though I fully intend to return to addressing them all.

tanishqmanuja commented 6 months ago

This is just a workaround, and can be added to users init.lua for now. Couldn't be a part of the actual plugin because the best way would be to make the plugin use the mapping from telescope's config instead of manually overwriting to ctrl + c for everyone.

I understand maintaining open source can be difficult at times, so take your time. Great plugin overall.. really enjoying it ✨

danielfalk commented 5 months ago

Hi, I've started a new branch 0.2.x where I have a fix for this. If you want to try it out and let me know, that would be great. I'll be updating that branch more hopefully in the near future and if it looks good, will start recommending it more broadly.

I'll close this for now, but if you want to try it out feel free to leave feedback here.

danielfalk commented 5 months ago

Oh, and just a comment on the fix, I've just changed the default keymapping from C-c to C-w, but even that can be overridden through your own mappings table. Still looking for feedback, but if this seems good, I can start documenting.

tanishqmanuja commented 5 months ago

Sure, I will test soon... Thanks for the fix 💯

tanishqmanuja commented 5 months ago

It works now and the best part was that I didn't even setup key mappings in smart-open, telescope key mappings just works by default for me now.

https://github.com/tanishqmanuja/init.lua/commit/9cd60d3e78ec726171778b9cca88175e281ade38