Comments (9)
Try using this:
require('fm-nvim').setup{
on_close = {
function()
vim.cmd [[ checktime ]]
end
},
}
from fm-nvim.
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 :Delete
or :Rename
a file.
from fm-nvim.
:checkt[ime] Check if any buffers were changed outside of Vim.
This checks and warns you if you would end up with two
versions of a file.
If this is called from an autocommand, a ":global"
command or is not typed the actual check is postponed
until a moment the side effects (reloading the file)
would be harmless.
Each loaded buffer is checked for its associated file
being changed. If the file was changed Vim will take
action. If there are no changes in the buffer and
'autoread' is set, the buffer is reloaded. Otherwise,
you are offered the choice of reloading the file. If
the file was deleted you get an error message.
If the file previously didn't exist you get a warning
if it exists now.
Once a file has been checked the timestamp is reset,
you will not be warned again.
Syntax highlighting, marks, diff status,
'fileencoding', 'fileformat' and 'binary' options
are not changed. See |v:fcs_choice| to reload these
too (for example, if a code formatting tools has
changed the file).
:checktime
essentially checks if any changes were made to the current buffer. Running this when Lf closes should in theory warn you about the file not existing but it doesn't seem to work for me either. 🤔
I'll see what I can do later today.
from fm-nvim.
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
}
}
from fm-nvim.
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 vim.cmd [[ checktime ]]
does the job... would it be worth making that default behaviour?
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.
from fm-nvim.
In this scenario, your vim.cmd [[ checktime ]] does the job... would it be worth making that default behaviour?
Seems like a great idea!
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.
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 lf
, you could create a command in your lfrc
that renames the selected file (at it normally would) and writes the new file's path to some temp file. Then in the on_close
option, check if the temp file exists and then read from it.
from fm-nvim.
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 fm-nvim
and one a bit more outside of it!
from fm-nvim.
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.lua
local 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
}
}
from fm-nvim.
Ah this awesome! Thank you so much! Guess we can close this now 😀🎆
from fm-nvim.
Related Issues (20)
- Open browser with current file selected HOT 9
- Allow directional splits HOT 1
- Ctrl-j and Ctrl-k not working when using Broot HOT 4
- enter key doesn't work as expected when using xplr HOT 6
- FEATURE:bookmark HOT 2
- LF icons not working HOT 6
- split mode does not work HOT 1
- [Feature] Change current directory HOT 2
- Close buffer along with window HOT 1
- [Feature Request] Allow custom border characters HOT 1
- Joshuto does not work HOT 3
- Make it possible to disable or override a mapping
- lazygit not open file in nvim HOT 3
- Xplr not open file inside already open buffer
- Can it run in the background permanently
- Joshuto does not work HOT 2
- broot just.. doesn't work?
- Add support for Yazi HOT 1
- Cannot open files that contain spaces in file/path name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fm-nvim.