diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-04 08:44:50 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-06 16:43:16 +0200 |
| commit | 0bc002288b984d8ec8123c135456570c78a22da3 (patch) | |
| tree | 020ed3f6a7f28a081687a3e46ea190e3aa724f7c /.config/nvim/plugin/50-lorem.lua | |
| download | dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.tar.gz dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.zip | |
feat: initial setup
- `dotfiles` (this project's CLI)
- foot configuration
- tmux configuration
- bash configuration
- nvim (as a git submodule) + configuration
- ranger configuration
- fzf configuration
- KDE global shortcuts
- Other miscellaneous dependencies
Diffstat (limited to '.config/nvim/plugin/50-lorem.lua')
| -rw-r--r-- | .config/nvim/plugin/50-lorem.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/.config/nvim/plugin/50-lorem.lua b/.config/nvim/plugin/50-lorem.lua new file mode 100644 index 0000000..8970574 --- /dev/null +++ b/.config/nvim/plugin/50-lorem.lua @@ -0,0 +1,35 @@ +-- +-- Lorem plugin (command to insert "lorem ipsum" words) +-- + +-- Returns lorem ipsum words +local function iter_lorem() + local filename = vim.env.HOME .. "/.local/share/dotfiles/lorem.txt" + local file = assert(io.open(filename, "r")) + local string = file:read("*all") + io.close(file) + local lorem_words = vim.split(vim.trim(string), " ", { trimempty = true }) + local i = 0 + return function() + i = i % #lorem_words + 1 + return lorem_words[i] + end +end + +-- Returns a n words long "lorem ipsum" string +local function get_lorem(n) + local iter = iter_lorem() + local words = {} + for i = 1, n do + words[i] = iter() + end + return table.concat(words, " ") +end + +local function put_lorem(n) + vim.api.nvim_put({ get_lorem(n) }, "c", true, true) +end + +vim.api.nvim_create_user_command("Lorem", function(opts) + put_lorem(tonumber(opts.args)) +end, { desc = "Put lorem ipsum string", nargs = 1 }) |
