2024-08-03 23:38:33 +03:00
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
local user_command = vim.api.nvim_create_user_command
|
|
|
|
|
2024-07-12 01:01:02 +03:00
|
|
|
-- used for when lazyness takes over and I'm using a mouse to click around in neo-tree
|
|
|
|
-- if insert mode is active then neo-tree won't behave as expected, so we want to stop it
|
2024-08-03 23:38:33 +03:00
|
|
|
autocmd("BufEnter", {
|
|
|
|
pattern = { "*" },
|
2024-07-12 01:01:02 +03:00
|
|
|
callback = function()
|
2024-08-03 23:38:33 +03:00
|
|
|
local filetype = vim.filetype.match({ buf = 0 })
|
|
|
|
if filetype == nil then
|
|
|
|
vim.cmd("stopinsert")
|
|
|
|
end
|
2024-07-12 01:01:02 +03:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2024-08-04 12:36:36 +03:00
|
|
|
user_command("ExportPlugins", function()
|
2024-05-24 16:07:28 +03:00
|
|
|
local plugins = require("lazy").plugins()
|
|
|
|
|
|
|
|
local f, err = io.open("plugins", "w+")
|
|
|
|
if f then
|
|
|
|
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, {})
|
2024-06-08 13:16:34 +03:00
|
|
|
|
2024-08-03 23:38:33 +03:00
|
|
|
user_command("CountWords", function()
|
2024-06-08 13:16:34 +03:00
|
|
|
local words = vim.fn.wordcount()["words"]
|
|
|
|
print("Words: " .. words)
|
|
|
|
end, {})
|
2024-10-28 22:14:36 +02:00
|
|
|
|
|
|
|
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",
|
|
|
|
})
|