Add a file and immediately open as a buffer #718
Unanswered
varunshoor
asked this question in
Q&A
Replies: 2 comments 1 reply
-
A solution that came up to my mind is to look at this file and combine few of them as a new command that suits your needs and map it to a new keybind. Sorry, I haven't tested them but for example command = {
create_and_edit = function (state)
local commands = require("neo-tree.sources.filesystem.commands")
commands.add(state)
commands.open(state)
end,
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
I thought we had to rely on neo-tree to handle the new file but it was way more simple. command = {
create_and_edit = function(state)
local cc = require("neo-tree.sources.common.commands")
local fs = require("neo-tree.sources.filesystem")
cc.add(state, function(destination) -- callback to cc.add, destination is the new file/dir path
fs.show_new_children(state, destination) -- lazily update neo-tree to show created item
local file_info = vim.loop.fs_stat(destination)
if file_info and file_info.type == "file" then -- ignoring when destination is dir
vim.cmd.edit(destination)
end
end)
end,
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I searched before posting but can't seem to find an answer.
I would like to open the newly added file immediately as a buffer so I can start writing my code, currently I have to open it from the tree after it gets created.
Is it possible with current options? I can't seem to find the relevant one in docs
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions