44 lines
1001 B
Lua
44 lines
1001 B
Lua
local user_command = vim.api.nvim_create_user_command
|
|
|
|
user_command("ExportPlugins", function()
|
|
local plugins = require("lazy").plugins()
|
|
|
|
local f, err = io.open("README.md", "w+")
|
|
if f then
|
|
f:write("# neovim config\n\n")
|
|
f:write("## plugins used\n\n")
|
|
for _, v in ipairs(plugins) do
|
|
local plugin = string.format("- [%s](%s)\n", v.name, v.url)
|
|
f:write(plugin)
|
|
end
|
|
|
|
f:close()
|
|
else
|
|
print("Error opening file: " .. err)
|
|
end
|
|
end, {})
|
|
|
|
user_command("CountWords", function()
|
|
local words = vim.fn.wordcount()["words"]
|
|
print("Words: " .. words)
|
|
end, {})
|
|
|
|
user_command("FormatDisable", function(args)
|
|
if args.bang then
|
|
-- FormatDisable! will disable formatting just for this buffer
|
|
vim.b.disable_autoformat = true
|
|
else
|
|
vim.g.disable_autoformat = true
|
|
end
|
|
end, {
|
|
desc = "Disable autoformat-on-save",
|
|
bang = true,
|
|
})
|
|
|
|
user_command("FormatEnable", function()
|
|
vim.b.disable_autoformat = false
|
|
vim.g.disable_autoformat = false
|
|
end, {
|
|
desc = "Re-enable autoformat-on-save",
|
|
})
|