-
Notifications
You must be signed in to change notification settings - Fork 18
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
Update buffer on file action with LF #25
Comments
Try using this: require('fm-nvim').setup{
on_close = {
function()
vim.cmd [[ checktime ]]
end
},
} |
Hmm, what exactly should this be doing - reloading the file? I added it but it doesn't seem to do anything... I guess the exact behaviour I'm looking for is that of https://github.com/tpope/vim-eunuch when you |
I'll see what I can do later today. |
Not sure if this is what you wanted but now you will be warned if a file does not exist. require('fm-nvim').setup{
on_close = {
function()
vim.fn.expand("%")
end
}
} |
The more I use this library, the more I reckon updating the buffer applies to most of its integrations too. For example, take any one of the git integrations, reset a hunk, and return to the buffer. Ideally, you shouldn't see the old hunk, you should see the updated changes in the buffer. Currently, you need to close and reopen the buffer to do so. In this scenario, your I guess it won't work in regards to my original query around deleting or renaming a file, as the file is now different... so maybe that's almost a separate issue, maybe outside the scope of the plugin and would need some LF specific code. |
Seems like a great idea!
If you want to be notified when you're working with a deleted/renamed file, you can use the code from my last comment. On the other hand, if you want to edit the newly renamed file after quitting from |
I guess it would also need to close the buffer with the old file name too? The most simple plugin I can think of that already does this is Tim Pope's Eunuch with the rename function: https://github.com/tpope/vim-eunuch/blob/master/plugin/eunuch.vim#L37 But yeah, this feels like two different issues now, one perhaps within the scope of |
I think I get what you're getting at now. The following code should do the trick! lfrc:cmd mv ${{
mv "$f" "$1"
echo "$(readlink -f $1)" > /tmp/lf_renamed
}} init.lualocal function Rename()
local temp = "/tmp/lf_renamed"
local file = io.open(temp, "r")
if file ~= nil then
vim.cmd("bdelete!")
vim.cmd("edit " .. vim.fn.readfile(temp)[1])
io.close(file)
os.remove(temp)
end
end
local function Delete()
local file = vim.fn.expand("%:p")
if io.open(file, "r") == nil then
vim.cmd("bdelete!")
end
end
require('fm-nvim').setup{
on_close = {
Rename,
Delete
}
} |
Ah this awesome! Thank you so much! Guess we can close this now 😀🎆 |
Is there a way to update the buffer when a file action is performed with LF? For example, if I delete or rename a file with LF and then return to the buffer, the old file exists - which will lead to errors if I then try to edit it. Thanks in advance, love this plugin!
The text was updated successfully, but these errors were encountered: