diff options
author | crupest <crupest@outlook.com> | 2023-10-01 17:40:04 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-01 17:40:04 +0800 |
commit | 2396c7525c26e5d8b2afbdca814e73d2ed2b2b91 (patch) | |
tree | 2ef2947e8a8afa6c4e8bb7172d3700a3c50f8d95 /configs/nvim/lua/crupest/filesystem-cmd.lua | |
parent | 9a9cd716024cb74dd88a5625dd657a099844a56e (diff) | |
download | crupest-2396c7525c26e5d8b2afbdca814e73d2ed2b2b91.tar.gz crupest-2396c7525c26e5d8b2afbdca814e73d2ed2b2b91.tar.bz2 crupest-2396c7525c26e5d8b2afbdca814e73d2ed2b2b91.zip |
Update nvim config.
Diffstat (limited to 'configs/nvim/lua/crupest/filesystem-cmd.lua')
-rw-r--r-- | configs/nvim/lua/crupest/filesystem-cmd.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/configs/nvim/lua/crupest/filesystem-cmd.lua b/configs/nvim/lua/crupest/filesystem-cmd.lua new file mode 100644 index 0000000..3148cef --- /dev/null +++ b/configs/nvim/lua/crupest/filesystem-cmd.lua @@ -0,0 +1,49 @@ +local function setup_filesystem_user_commands() + vim.api.nvim_create_user_command("Mv", function(opts) + require("crupest.nvim").mv_buf_file(vim.api.nvim_get_current_buf(), opts.fargs[1]) + end, { + nargs = 1, + complete = "file" + }) + + vim.api.nvim_create_user_command("MvFile", function(opts) + if (#opts.fargs ~= 2) then + vim.notify("MvFile accepts exactly two arguments, old file and new file.") + end + require("crupest.nvim").mv_file(opts.fargs[1], opts.fargs[2]) + end, { + nargs = "+", + complete = "file" + }) + + vim.api.nvim_create_user_command("MvDir", function(opts) + if (#opts.fargs ~= 2) then + vim.notify("MvDir accepts exactly two arguments, old dir and new dir.") + end + require("crupest.nvim").mv_dir(opts.fargs[1], opts.fargs[2]) + end, { + nargs = "+", + complete = "file" + }) + + vim.api.nvim_create_user_command("Rename", function(opts) + require("crupest.nvim").rename_buf_file(vim.api.nvim_get_current_buf(), opts.fargs[1]) + end, { + nargs = 1, + complete = "file" + }) + + vim.api.nvim_create_user_command("RenameFile", function(opts) + if (#opts.fargs ~= 2) then + vim.notify("RenameFile accepts exactly two arguments, old file and new file.") + end + require("crupest.nvim").rename_file(opts.fargs[1], opts.fargs[2]) + end, { + nargs = "+", + complete = "file" + }) +end + +return { + setup_filesystem_user_commands = setup_filesystem_user_commands +} |