Explorer auto close when open files #1798
Replies: 4 comments 18 replies
-
opts = {
picker = {
sources = {
explorer = {
win = {
list = {
keys = {
['L'] = { 'L', { 'confirm', 'close' } },
-- OR
-- ['L'] = { { 'confirm', 'close' } }, |
Beta Was this translation helpful? Give feedback.
-
@drowning-cat was there a breaking since Apr 24? My following config does not seem to be working anymore. explorer = {
actions = {
go_in_if_dir = function(picker, item)
if item.dir then
picker:action 'confirm'
end
end,
},
win = {
list = {
keys = {
['l'] = 'go_in_if_dir', -- Same as ./custom/MiniFiles.lua
['L'] = { { 'confirm', 'close' } }, ---@diagnostic disable-line: assign-type-mismatch
['<CR>'] = { { 'confirm', 'close' } }, ---@diagnostic disable-line: assign-type-mismatch
},
},
},
focus = 'input',
}, |
Beta Was this translation helpful? Give feedback.
-
After playing around with the config this is what I have in my local function get_explorer_keys()
-- Default keys
local list_keys = require('snacks.picker').sources.explorer.win.list.keys
-- Override keys
return vim.tbl_extend('force', list_keys, {
['l'] = 'go_in_if_dir', -- Same as ./custom/MiniFiles.lua
['L'] = { { 'confirm', 'close' } }, ---@diagnostic disable-line: assign-type-mismatch
['<CR>'] = { { 'confirm', 'close' } }, ---@diagnostic disable-line: assign-type-mismatch
})
end
return {
'folke/snacks.nvim',
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
...
explorer = {
focus = 'input',
actions = {
go_in_if_dir = function(picker, item)
if item.dir then
picker:action 'confirm'
end
end,
},
win = {
list = {
keys = get_explorer_keys(),
},
-- There is no default Snacks.picker.explorer.win.input.keys set
-- so the keys default to Snacks.picker.Config.win.input.keys
-- This sets the keys for focus = 'input'
input = {
keys = get_explorer_keys(),
},
},
},
...
} Is this the proper way to do this? |
Beta Was this translation helpful? Give feedback.
-
I have another question, how can i make enter key in insert/input mode also open the file directly? I've tried the following but they didn't work too.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any way to auto close the explorer when a new file is opened?
Beta Was this translation helpful? Give feedback.
All reactions