mirror of
https://github.com/folke/snacks.nvim
synced 2025-07-07 13:15:08 +00:00
feat: initial commit
This commit is contained in:
commit
63a24f6eb0
5 changed files with 93 additions and 0 deletions
13
README.md
Normal file
13
README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Snacks
|
||||
|
||||
- bigfile
|
||||
- bufremove
|
||||
- lazygit
|
||||
- lsp
|
||||
- quickfile
|
||||
- rename
|
||||
- root
|
||||
- statuscolumn
|
||||
- terminal
|
||||
- toggle
|
||||
- words
|
49
lua/snacks/bigfile.lua
Normal file
49
lua/snacks/bigfile.lua
Normal 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
4
selene.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
std="vim"
|
||||
|
||||
[lints]
|
||||
mixed_table="allow"
|
6
stylua.toml
Normal file
6
stylua.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 120
|
||||
[sort_requires]
|
||||
enabled = true
|
||||
|
21
vim.toml
Normal file
21
vim.toml
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue