feat: initial commit

This commit is contained in:
Folke Lemaitre 2024-11-02 23:24:33 +01:00
commit 63a24f6eb0
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 93 additions and 0 deletions

13
README.md Normal file
View file

@ -0,0 +1,13 @@
# Snacks
- bigfile
- bufremove
- lazygit
- lsp
- quickfile
- rename
- root
- statuscolumn
- terminal
- toggle
- words

49
lua/snacks/bigfile.lua Normal file
View file

@ -0,0 +1,49 @@
local M = {}
---@class snacks.bigfile.Config
local defaults = {
size = 1.5 * 1024 * 1024, -- 1.5MB
---@param opts {buf: number, ft:string}
behave = function(opts)
vim.b.minianimate_disable = true
vim.schedule(function()
vim.bo.syntax = opts.ft
end)
vim.notify("Big file detected, syntax highlighting disabled", "warn")
end,
}
---@param opts snacks.bigfile.Config?
function M.setup(opts)
opts = vim.tbl_deep_extend("force", defaults, opts or {})
vim.filetype.add({
pattern = {
[".*"] = {
function(path, buf)
return vim.bo[buf]
and vim.bo[buf].filetype ~= "bigfile"
and path
and vim.fn.getfsize(path) > opts.size
and "bigfile"
or nil
end,
},
},
})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = vim.api.nvim_create_augroup("snacks_bigfile", { clear = true }),
pattern = "bigfile",
callback = function(ev)
vim.api.nvim_buf_call(ev.buf, function()
opts.behave({
buf = ev.buf,
ft = vim.filetype.match({ buf = ev.buf }) or "",
})
end)
end,
})
end
return M

4
selene.toml Normal file
View file

@ -0,0 +1,4 @@
std="vim"
[lints]
mixed_table="allow"

6
stylua.toml Normal file
View file

@ -0,0 +1,6 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
[sort_requires]
enabled = true

21
vim.toml Normal file
View file

@ -0,0 +1,21 @@
[selene]
base = "lua51"
name = "vim"
[vim]
any = true
[jit]
any = true
[assert]
any = true
[describe]
any = true
[it]
any = true
[before_each.args]
any = true