-
Notifications
You must be signed in to change notification settings - Fork 215
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
mini.files errors when combined with mini.starter #485
Comments
Hi! Thanks for kind words! This is working as intended. You seem to start 'mini.files' with something like this which opens inside a directory of current file. But Starter buffer is not associated with any file. Try plain |
When I tried to open it as you suggested, I received the following error:
|
It assumes that you ran Try |
That works, indeed. I appreciate your help! |
I put together this function which toggles mini.files, assigned to a key combination: function()
local miniFiles = require("mini.files")
if not miniFiles.close() then
-- open file explorer if current buffer is not on disk, e.g. Starter
if vim.fn.getreg("%") ~= "" then
miniFiles.open()
else
-- open file explorer at current file
miniFiles.open(vim.api.nvim_buf_get_name(0))
end
end
end |
@akijakya, this will do more closely what is described in the comments (assuming function()
-- Close explorer if it is opened
if MiniFiles.close() then return end
-- Compute whether current buffer is for file on disk.
-- If yes - use it to open explorer; otherwise use cwd.
local buf_path = vim.api.nvim_buf_get_name(0)
local path = vim.loop.fs_stat(buf_path) ~= nil and buf_path or vim.fn.getcwd()
MiniFiles.open(path)
end |
@echasnovski thanks a lot, that is much better! Sorry for the half-baked attempt (would have made sense (only) for the Starter buffer with this condition |
No worries. Usually the better way to tell if the buffer is for a certain plugin is to test its filetype. So here it could be |
Contributing guidelines
Module(s)
mini.starter, mini.files
Description
Thank you for your work! I'm a huge fan of
mini.files
, but the only place where it doesn't work for me is for the specialStarter
file. I want to be able to browse the project files on the starting screen without opening Telescope or similar plugins.Neovim version
0.9.2
Steps to reproduce
mini.starter
mini.files
Expected behavior
No response
Actual behavior
The text was updated successfully, but these errors were encountered: