echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.84k stars 183 forks source link

mini.files: Allow to open mini.files with terminal buffer #1146

Closed David-Kunz closed 4 weeks ago

David-Kunz commented 4 weeks ago

Contributing guidelines

Module(s)

mini.files

Description

When opening mini.files with a terminal buffer, one gets the following error message:

E5108: Error executing lua (mini.files) `path` is not a valid path ("/<somePath>/Terminal 1")                                                                                                                                          
stack traceback:                                                                                                                                                                                                                          
        [C]: in function 'error'                                                                                                                                                                                                          
        ...023/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:2642: in function 'error'                                                                                                                                             
        ...023/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:708: in function 'open'                                                                                                                                               
        [string ":lua"]:1: in main chunk                                                                                                                                                                                                  
E21: Cannot make changes, 'modifiable' is off  
MiniFiles.open(vim.api.nvim_buf_get_name(0)) -- currently a terminal buffer

Suggestion: Open the current working directory instead (vim.fn.getcwd()).

Thanks, @echasnovski !

Neovim version

0.10.1

Steps to reproduce

  1. :term
  2. :lua MiniFiles.open(vim.api.nvim_buf_get_name(0))

Expected behavior

Opens vim.fn.getcwd() instead.

Actual behavior

Throws error

E5108: Error executing lua (mini.files) `path` is not a valid path ("/<somePath>/Terminal 1")                                                                                                                                          
echasnovski commented 4 weeks ago

Thanks for the suggestion!

This works as expected because open() is called not with existing on disk path. To open explorer in current directory, use either one of:

David-Kunz commented 4 weeks ago

Thank you, @echasnovski !