Easily generate dummy text in Neovim
Add the flake input, then pass the package to your Neovim config:
# flake.nix
inputs.lorem-nvim.url = "github:derektata/lorem.nvim";home-manager (programs.neovim):
programs.neovim.plugins = [
inputs.lorem-nvim.packages.${system}.default
];nixvim:
extraPlugins = [
inputs.lorem-nvim.packages.${system}.default
];Then configure as usual in either case:
require("lorem").setup {
sentence_length = "mixed",
comma_chance = 0.3,
max_commas = 2,
}vim.pack.add { 'https://github.com/derektata/lorem.nvim' }
require('lorem').setup {
sentence_length = "mixed",
comma_chance = 0.3,
max_commas = 2,
}return {
'derektata/lorem.nvim',
opts = {
sentence_length = "mixed", -- using a default configuration
comma_chance = 0.3, -- 30% chance to insert a comma
max_commas = 2, -- maximum 2 commas per sentence
},
}The plugin is designed to be as plug-and-play as possible, and therefore no setup is needed as it is shipped with sensible defaults. It is however possible to customize the behavior of the plugin like this:
require('lorem').setup {
sentence_length = "mixed", -- using a default configuration
comma_chance = 0.3, -- 30% chance to insert a comma
max_commas = 2, -- maximum 2 commas per sentence
}
-- or
require('lorem').setup {
sentence_length = { -- custom configuration
w_per_sentence = 8,
s_per_paragraph = 6
},
comma_chance = 0.3, -- 30% chance to insert a comma
max_commas = 2, -- maximum 2 commas per sentence
}This property determines the intervals for how long the sentences of latin words should be before ending them with a period. The following values are available:
| Value | Words Per Sentence | Sentences Per Paragraph |
|---|---|---|
| short | 5 | 3 |
| medium | 10 | 5 |
| long | 14 | 7 |
| mixedShort | 8 | 4 |
| mixed | 12 | 6 |
| mixedLong | 16 | 8 |
This property controls the likelihood of inserting a comma after a word within a sentence. This property allows for the generation of more natural-looking text by adding occasional commas, mimicking the natural pauses in human writing.
This property sets the maximum number of commas that can be inserted in a single sentence. This property ensures that sentences do not become overly complex or cluttered with too many commas, maintaining readability and natural flow.
Type loremX followed by a space, where X is the number of words you want. The plugin will replace the trigger with the generated text and move the cursor to the end.
Type loremXp followed by a space, where X is the number of paragraphs you want. The plugin will replace the trigger with the specified number of paragraphs and move the cursor to the end.
The command features tab-completion to help streamline text generation. Start typing :LoremIpsum and press <TAB> to reveal available options for mode (words or paragraphs). After selecting a mode, pressing <TAB> again suggests the appropriate next argument (<amount>).
# defaults: 100 words, 1 paragraph
:LoremIpsum <mode> <amount>
┌────────────┐
│ │
│ Menu │
│depending on│
┌────────────┐│ previous │
│ words ││ selection │
│ paragraphs ││ │
└────────────┘└────────────┘
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
:LoremIpsum <TAB> <TAB>
┗━━━mode━━━┛ ┗━━━amount━━━┛
# i.e.
:LoremIpsum words 1000
:LoremIpsum paragraphs 2
The Custom Ipsum feature offers users granular control over the generated text without needing to modify their configuration. By using the :LoremIpsum command with specific arguments, users can dynamically specify the format, amount, and structure of the generated text.
Custom usage for paragraphs:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
:LoremIpsum paragraphs 1 10 5
┃ ┃ ┃ ┃
format━━━━━━━━┛ ┃ ┃ ┃
┃ ┃ ┃
amount━━━━━━━━━━━━━━━┛ ┃ ┃
┃ ┃
w_per_sentence━━━━━━━━━━━━━━━━━━━┛ ┃
┃
s_per_paragraph━━━━━━━━━━━━━━━━━━━━━━┛
# print lorem ipsum words to the terminal
# (default: 100)
nvim --headless -c 'lua print(require("lorem").words())' +qall | tail -n +1
# print 500 words to the terminal
nvim --headless -c 'lua print(require("lorem").words(500))' +qall | tail -n +1
# using the shell script
chmod +x lorem.sh
./lorem.sh -w 10



