Closed samdmarshall closed 7 years ago
There are a couple problems with the plugin that need to be fixed before this can be merged.
1.
The main issue is that HandleShellCommand
isn't doing what you think it is. This is because the documentation for that function is bad and the function itself really needs to be cleaned up. When you call HandleShellCommand
and pass in false
for the second argument it doesn't return anything because the shell command goes off in its own thread in the background. So the line HandleShellCommand("pwd", false, false)
is actually always returning ""
.
Instead of HandleShellCommand
to get the working directory, you should use Lua's standard library:
local handle = io.popen("pwd")
local working_path = handle:read("*a")
Now you should see that every file opened has the working directory prepended to it, and therefore is an absolute path. I don't think this is what you intended, so I think you should just entirely remove the working_directory
stuff because it isn't necessary.
I'm really sorry about the problems with HandleShellCommand
.
2.
This is really a minor detail, but it's better to use CurView():CanClose()
instead of just saving the buffer at the start of the fzf()
function:
function fzf()
if CurView():CanClose() then
...
end
end
This way if someone has an empty/unchanged file open it doesn't ask them to save, but it does ask them to save if they have unsaved changes.
Thanks for making this plugin! fzf is very useful, and I'll definitely be using this.
Wow, ok, that makes more sense to me now. Thank you!
I have updated the respective plugin and it seems to have cleared up a very strange panic that I was encountering as well! The code for getting the working directory was something I didn't realize I needed after the fact as the reason I was getting a failure of opening directly from fzf was due to the trailing newline, not the fact that the path wasn't absolute. I have removed that code as you have recommended.
Thank you for making such a good plugin API, it was extremely easy to build this.
adding a new plugin that allows
fzf
to be use to select files to open in micro.