.dotfiles/.config/nvim/lua/nvwynd/autocmds.lua

36 lines
903 B
Lua
Raw Normal View History

local autocmd = vim.api.nvim_create_autocmd
local user_command = vim.api.nvim_create_user_command
-- 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
autocmd("BufEnter", {
pattern = { "*" },
callback = function()
local filetype = vim.filetype.match({ buf = 0 })
if filetype == nil then
vim.cmd("stopinsert")
end
end,
})
user_command("ListPlugins", 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, {})
user_command("CountWords", function()
local words = vim.fn.wordcount()["words"]
print("Words: " .. words)
end, {})