Convenience file operations for neovim, written in lua.
vim.eunuch
?vim.eunuch
?vim.ui.input
or vim.notify
. This means you can get nicer input fields with normal mode support via plugins like dressing.nvim, and confirmation notices with plugins like nvim-notify, if they are installed and setup.-- Packer
use {"chrisgrieser/nvim-genghis", requires = "stevearc/dressing.nvim"}
-- Lazy
{"chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim"},
nvim-genghis
(and dressing.nvim
) require no .setup()
function. Just create keybindings for the commands you want to use:
local keymap = vim.keymap.set
local genghis = require("genghis")
keymap("n", "<leader>yp", genghis.copyFilepath)
keymap("n", "<leader>yn", genghis.copyFilename)
keymap("n", "<leader>cx", genghis.chmodx)
keymap("n", "<leader>rf", genghis.renameFile)
keymap("n", "<leader>mf", genghis.moveAndRenameFile)
keymap("n", "<leader>nf", genghis.createNewFile)
keymap("n", "<leader>yf", genghis.duplicateFile)
keymap("n", "<leader>df", function () genghis.trashFile{trashLocation = "your/path"} end) -- default: "$HOME/.Trash".
keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
.createNewFile
or :New
: Create a new file..duplicateFile
or :Duplicate
: Duplicate the current file..moveSelectionToNewFile
or :NewFromSelection
: Prompts for a new file name and moves the current selection to that new file. (Note that this is a Visual Line Mode command; the selection is moved linewise.).renameFile
or :Rename
: Rename the current file..moveAndRenameFile
or :Move
: Move and Rename the current file. Works like the UNIX mv
command. Best used with autocompletion of directories.The following applies to all commands above:
/
, the new file is placed in the respective subdirectory, creating any non-existing folders. Except for .moveAndRenameFile
, all operations take only place in the current working directory, so .moveAndRenameFile
is the only command that can move to a parent directory..trashFile{trashLocation = "/your/path/"}
or :Trash
: Move the current file to the trash location. Defaults to the operating-system-specific trash directory. ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable..copyFilename
or :CopyFilename
: Copy the file name. When clipboard="unnamed[plus]"
has been set, copies to the +
register, otherwise to "
..copyFilepath
or :CopyFilepath
: Copy the absolute file path. When clipboard="unnamed[plus]"
has been set, copies to the +
register, otherwise to "
..chmodx
or :Chmodx
: Makes current file executable. Equivalent to chmod +x
.Put this in your configuration file:
-- lua
vim.g.genghis_disable_commands = true
-- viml
let g:genghis_disable_commands = v:true
You can get autocompletion for directories by using dressing.nvim
, nvim-cmp
, and vim's omnifunc:
-- packer
use { "chrisgrieser/nvim-genghis", requires = {
"stevearc/dressing.nvim",
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-omni",
},
}
-- lazy
{ "chrisgrieser/nvim-genghis", dependencies = {
"stevearc/dressing.nvim",
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-omni",
},
},
-- required setup for cmp, somewhere after your main cmp-config
require("cmp").setup.filetype("DressingInput", {
sources = cmp.config.sources { {name = "omni"} },
})
A nod to vim.eunuch - as opposed to childless eunuchs, it is said that Genghis Khan has fathered thousands of children.
In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.
Profiles