Add option to open buffers in the insert mode
DUOLabs333 opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
Right now, if you open a buffer using Telescope buffers
, you will always enter the buffer in normal mode. However, I usually work in insert mode, so it's an extra keystroke to enter insert mode after jumping to a buffer.
Describe the solution you'd like
An option to set the mode of the buffer that you open using Telescope buffers
.
Describe alternatives you've considered
Additional context
You can modify the existing select
action to add a post action like so:
local action_set = require("telescope.actions.set")
require("telescope.builtin").buffers({
attach_mappings = function()
action_set.select:enhance({
post = function()
vim.schedule(function()
vim.cmd([[startinsert]])
end)
end,
})
return true
end,
})
I can answer any follow ups but I'll close the issue otherwise.
How would you add this to a config? I tried pasting it in, but it starts Neovim with the buffers window open.
That would depend on your config and things like package manager.
But in general that code you would do something like using that function as part of a keybinding.
Alternatively, you can put this in your telescope setup config
require("telescope").setup({
defaults = {
-- ...,
},
pickers = {
buffers = {
attach_mappings = function()
require("telescope.actions.set").select:enhance({
post = function()
vim.schedule(function()
vim.cmd([[startinsert]])
end)
end,
})
return true
end,
},
},
})
This works. Thanks!