Skip to content
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

[feature request] providing Lua APIs to manipulate files #881

Open
haolian9 opened this issue Feb 25, 2023 · 3 comments
Open

[feature request] providing Lua APIs to manipulate files #881

haolian9 opened this issue Feb 25, 2023 · 3 comments
Labels

Comments

@haolian9
Copy link
Contributor

Hi, this issue follows the previous discuss.

Why need such Lua APIs for plugins:

  • trigger proper events
  • cross-platform
  • able to undo operations

Which API are needed (from my perspective, speak in vifm commands):

  • :rename
  • :delete
  • :move
  • :mkdir
  • :touch
@xaizek xaizek added the lua label Feb 26, 2023
@xaizek
Copy link
Member

xaizek commented Feb 26, 2023

There are actually two separate groups of operations here: high-level (you've listed them) and low-level.

Low-level would be for cross-platform operations that don't trigger events or allow for undo, because you don't want to undo creation of a temporary file or stuff like that.

Among high-level ones, list rename is definitely needed to handle non-trivial renames (a -> b, b -> a). Overall this will need more thought in dealing with undo/redo, although initially undo can be done per operation.

@haolian9
Copy link
Contributor Author

how about exposing vle_cmds_run (or something i dont know) to lua? with it, lua can do what vifm script can. and it partly avoids providing the same APIs in vifm script and lua sides.

@xaizek
Copy link
Member

xaizek commented Dec 30, 2023

how about exposing vle_cmds_run (or something i dont know) to lua? with it, lua can do what vifm script can. and it partly avoids providing the same APIs in vifm script and lua sides.

Bad idea. :commands are not regular, it's impossible to guarantee proper escaping of arguments and their interaction with views and managing of state (like for conditionals) will very likely create serious problems (think calling Lua handler that calls :command from inside another :command). It will also be like mixing VimL with Python and calling from one into another with things falling apart due to escaping, I've seen that a lot with clang_complete and don't want to allow it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants