uuid-gen-nvim provides functions to generate, insert, and highlight UUIDs in
Neovim.
Note
This is my first plug-in. I use Linux (Arch, btw). I have not tested this plug-in on any other machine but my own. I am very open to any feedback to make the plug-in more accessible on different OSs.
uuid-gen-nvim uses uuidgen by default. However, you may configure a
different application in the setup.
Using lazy.nvim:
{
"MikeWallaceDev/uuid-gen-nvim",
-- The following two lines are *required* if you want lazy loading,
-- which you should
lazy = true,
cmd = { "UuidInsertLinear", "UuidInsertBlock", "UuidToggleHighlighting" },
opts = {}
}If you are using Packer.nvim as your plugin manager, include the following line in your Packer configuration:
Note
I don't use packer, and this is a new/small/unknown plug-in, so I didn't test this. Please tell me if it works.
use 'git@github.com:MikeWallaceDev/uuid-gen-nvim.git'
require('uuid-gen-nvim').setup({})The default values :
opts = {
case = "lower",
insert = "after",
quotes = "none",
prefix = "",
suffix = "",
qty_linear = 1
qty_block = 5,
command = "uuidgen",
highlighting = false,
}| Option | Description | Possible values |
|---|---|---|
| case | UUID letters in uppercase or lowercase. | "upper","lower" |
| insert | Where the UUID will be inserted. | "before","after" |
| quotes | Surround the UUID with quotes. | "single", |
"double", |
||
"none" |
||
| prefix | String printed before the UUID. | string |
| suffix | A string printed after the UUID. | string |
| qty_linear | How many UUIDs to create in linear mode. | integer |
| qty_block | How many UUIDs to create in block mode. | integer |
| command | System command used to create the UUID. | string |
| highlighting | UUID syntax highlighting. | true, false |
One possible configuration is to set command = "uuidgen -7" in order two
generate V7 UUIDs.
Another suggestion might be to set prefix ="," to automatically add a comma
after your UUID. Especially if generating many UUIDs in linear mode.
uuid-gen-nvim provides help docs which can be accessed by running :help uuid-gen-nvim.
Note
This help is only available once the plug-in is loaded. You might want to just insert a UUID in the current document and then undo...
The plugin exposes three vim commands.
UuidInsertLinearwhich generates and inserts new UUIDs in character mode. By default only one UUID is generated. However you may request more by simply appending an integer to the command and they will be inserted one after the other.UuidInsertBlockwhich generates and inserts new UUIDs in line mode on the line below the cursor. By default 5 UUIDs are generated and insert in a block, one under the other.UuidToggleHighlightingwhich enables/disables UUID syntax highlighting
Note
Highlighting isn't fantastic yet... I'm working on it.
Simply create a key mapping that calls the desired function:
vim.keymap.set("n", "<leader>uu", "<cmd>UuidInsertLinear<CR>", {})
vim.keymap.set("n", "<leader>uU", "<cmd>UuidInsertLinear 3<CR>", {})
vim.keymap.set("n", "<leader>ub", "<cmd>UuidInsertBlock<CR>", {})
vim.keymap.set("n", "<leader>uB", "<cmd>UuidInsertBlock 10<CR>", {})
vim.keymap.set("n", "<leader>ut", "<cmd>UuidToggleHighlighting<CR>", {})Feel free to open an issue or pull request if you find any bugs or have suggestions for improvements.
wallacehub-personal/uuid-gen-nvim
This plug-in was inspired by the following plugins.
Thanks to my buddy Joe for helping out with testing.
/_ vim: set textwidth=80 : _/