Go to file
pseudometa b186f610de patch 2022-11-27 12:05:17 +01:00
lua refactoring trashFile 2022-11-27 08:48:29 +01:00
LICENSE initial commit 2022-11-21 13:54:41 +01:00
README.md patch 2022-11-27 12:05:17 +01:00

README.md

nvim-genghis

Convenience file operations for neovim, written in lua.

Note
Previously, "genghis" was spelled wrong at various places, including the GitHub-URL and the package name. 🙈 By fixing that, the repo-address and package name have changed. Sorry for the inconvenience!


How is this different from vim.eunuch?

  • Written 100% in lua. Uses only vim-commands or lua os-modules and no shell commands to it works on every platform.
  • Uses up-to-date nvim features like vim.ui.input or vim.notify. This means you can get nicer input fields via plugins like dressing.nvim, and nicer confirmation notices with plugins like nvim-notify, if they are installed and setup.
  • Some small improvements like automatically keeping the extensions when no extension is given, or moving to the trash instead of removing files.

Installation and setup

-- Recommended (Packer)
use {"chrisgrieser/nvim-genghis", requires = "stevearc/dressing.nvim"}

-- if you do not care about nice input fields
use "chrisgrieser/nvim-genghis"

nvim-genghis (and dressign.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>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)

Available commands

  • .copyFilepath: Copy the absolute file path. When clipboard="unnamed[plus]", copies to the + register, otherwise to ".
  • .copyFilename: Copy the file name. When clipboard='unnamed[plus], copies to the + register, otherwise to ".
  • .chmodx: Makes current file executable. Equivalent to chmod +x.
  • .renameFile: Rename the current file. If no extension is provided, keeps the current file extension.
  • .createNewFile: Create a new file. If no extension is provided, uses the extension of the current file.
  • .duplicateFile: Duplicate the current file. If no extension is provided, keeps the current file extension.
  • .trashFile: Move the current file to $HOME/.Trash. Can optionally be passed a table to change the trash location: .trashFile{trashLocation = "your/path/"}. Note that any existing files in the trash location with the same name may be overwritten.
  • .moveSelectionToNewFile: Visual Line Mode Command. Prompts for a new file name and moves the current selection to that new file. (Note that the selection is moved linewise.)

Why that name

A nod to vim.eunuch - as opposed to childless eunuchs, it is said that Genghis Khan has fathered thousands of children.

About me

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

Donate Buy Me a Coffee at ko-fi.com


This is my first neovim plugin, so suggestions for improvements are welcome.