Adds RandomFile generator
This commit is contained in:
parent
c5935a5692
commit
8c69a2f7e5
3 changed files with 2027 additions and 0 deletions
1999
.config/nvim/assets/words.txt
Normal file
1999
.config/nvim/assets/words.txt
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -6,3 +6,4 @@ require("config.lazy")
|
||||||
require("commands.optolith")
|
require("commands.optolith")
|
||||||
require("commands.open")
|
require("commands.open")
|
||||||
require("commands.CopyToPlayers")
|
require("commands.CopyToPlayers")
|
||||||
|
require("commands.RandomFile")
|
||||||
|
|
|
||||||
27
.config/nvim/lua/commands/RandomFile.lua
Normal file
27
.config/nvim/lua/commands/RandomFile.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
local fs = require("functions.fs")
|
||||||
|
|
||||||
|
local function tocamel(s)
|
||||||
|
return string.upper(string.sub(s, 1, 1)) .. string.sub(s, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("CreateRandomFile", function()
|
||||||
|
local words = vim.fn.readfile(vim.fs.normalize("~/.config/nvim/assets/words.txt"))
|
||||||
|
|
||||||
|
local wordsRequests = math.random(2, 4)
|
||||||
|
|
||||||
|
local wordsFinal = ""
|
||||||
|
for i = 1, wordsRequests do
|
||||||
|
local word = words[math.random(#words)]
|
||||||
|
wordsFinal = wordsFinal .. tocamel(word)
|
||||||
|
end
|
||||||
|
|
||||||
|
local currentPath = fs.getCurrentPath()
|
||||||
|
|
||||||
|
local directory = currentPath
|
||||||
|
if vim.fn.isdirectory(currentPath) == 0 then
|
||||||
|
directory = vim.fs.dirname(currentPath)
|
||||||
|
end
|
||||||
|
|
||||||
|
local path = vim.fs.joinpath(directory, wordsFinal .. ".md")
|
||||||
|
os.execute(string.format('touch "%s"', path))
|
||||||
|
end, {})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue