Go to file
pseudometa 5eb340dc14 add stylua config 2022-12-17 12:24:19 +01:00
lua patch 2022-12-13 14:11:37 +01:00
.luarc.json patch 2022-11-27 21:16:02 +01:00
.stylua.toml add stylua config 2022-12-17 12:24:19 +01:00
LICENSE initial commit 2022-11-21 13:54:41 +01:00
README.md docs: added instructions for name autocompletion 2022-12-13 14:03:50 +01:00

README.md

nvim-genghis

Convenience file operations for neovim, written in lua.

How is this different from vim.eunuch?

  • Various improvements like automatically keeping the extensions when no extension is given, or moving files to the trash instead of removing them.
  • Uses only vim-commands or lua os-modules, so it has no dependencies and works cross-platform.
  • Makes use of 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.
  • If used with dressing and cmp, you can also get autocompletion of filenames.
  • Written 100% in lua.

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]" has been set, copies to the + register, otherwise to ".
  • .copyFilename: Copy the file name. When clipboard="unnamed[plus]" has been set, 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, uses the current file extension.
  • .trashFile{trashLocation = "your/path/"}: Move the current file the trash location. Defaults to location is $HOME/.Trash/. ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable.
  • .moveSelectionToNewFile: 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.

Autocompletion of filenames

You can get autocompletion for filenames 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",
		},
	}
-- required setup for cmp, somewhere after your main cmp-config
require("cmp").setup.filetype("DressingInput", {
	sources = cmp.config.sources { {name = "omni"} },
})

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


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