feat: set specs ft

This commit is contained in:
raf 2024-05-19 02:31:49 +03:00
parent 2743e412bb
commit 30a4c18276
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29

View file

@ -66,8 +66,11 @@ function M.show_specs(popup)
height = 1, height = 1,
col = cursor_col, col = cursor_col,
row = cursor_row, row = cursor_row,
style = 'minimal' style = 'minimal',
noautocmd = true
}) })
vim.api.nvim_set_option_value('filetype', 'specs.nvim', { buf = bufh })
vim.api.nvim_win_set_option(win_id, 'winhl', 'Normal:' .. _opts.popup.winhl) vim.api.nvim_win_set_option(win_id, 'winhl', 'Normal:' .. _opts.popup.winhl)
vim.api.nvim_win_set_option(win_id, "winblend", _opts.popup.blend) vim.api.nvim_win_set_option(win_id, "winblend", _opts.popup.blend)
@ -109,76 +112,92 @@ function M.show_specs(popup)
cnt = cnt + 1 cnt = cnt + 1
end end
end)) end))
end end
--[[ ▁▁▂▂▃▃▄▄▅▅▆▆▇▇██ ]]-- --[[ ▁▁▂▂▃▃▄▄▅▅▆▆▇▇██ ]]
--
function M.linear_fader(blend, cnt) function M.linear_fader(blend, cnt)
if blend + cnt <= 100 then if blend + cnt <= 100 then
return cnt return cnt
else return nil end else
return nil
end
end end
--[[ ⌣/⌢\⌣/⌢\⌣/⌢\⌣/⌢\ ]]-- --[[ ⌣/⌢\⌣/⌢\⌣/⌢\⌣/⌢\ ]]
--
function M.sinus_fader(blend, cnt) function M.sinus_fader(blend, cnt)
if cnt <= 100 then if cnt <= 100 then
return math.ceil((math.sin(cnt * (1 / blend)) * 0.5 + 0.5) * 100) return math.ceil((math.sin(cnt * (1 / blend)) * 0.5 + 0.5) * 100)
else return nil end else
return nil
end
end end
--[[ ▁▁▁▁▂▂▂▃▃▃▄▄▅▆▇ ]]
--[[ ▁▁▁▁▂▂▂▃▃▃▄▄▅▆▇ ]]-- --
function M.exp_fader(blend, cnt) function M.exp_fader(blend, cnt)
if blend + math.floor(math.exp(cnt / 10)) <= 100 then if blend + math.floor(math.exp(cnt / 10)) <= 100 then
return blend + math.floor(math.exp(cnt / 10)) return blend + math.floor(math.exp(cnt / 10))
else return nil end else
return nil
end
end end
--[[ ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁ ]]
--[[ ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁ ]]-- --
function M.pulse_fader(blend, cnt) function M.pulse_fader(blend, cnt)
if cnt < (100 - blend) / 2 then if cnt < (100 - blend) / 2 then
return cnt return cnt
elseif cnt < 100 - blend then elseif cnt < 100 - blend then
return 100 - cnt return 100 - cnt
else return nil end else
return nil
end
end end
--[[ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ]]-- --[[ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ]]
--
function M.empty_fader(_, _) function M.empty_fader(_, _)
return nil return nil
end end
--[[ ░░▒▒▓█████▓▒▒░░ ]]
--[[ ░░▒▒▓█████▓▒▒░░ ]]-- --
function M.shrink_resizer(width, ccol, cnt) function M.shrink_resizer(width, ccol, cnt)
if width - cnt > 0 then if width - cnt > 0 then
return { width - cnt, ccol - (width - cnt) / 2 + 1 } return { width - cnt, ccol - (width - cnt) / 2 + 1 }
else return nil end else
return nil
end
end end
--[[ ████▓▓▓▒▒▒▒░░░░ ]]
--[[ ████▓▓▓▒▒▒▒░░░░ ]]-- --
function M.slide_resizer(width, ccol, cnt) function M.slide_resizer(width, ccol, cnt)
if width - cnt > 0 then if width - cnt > 0 then
return { width - cnt, ccol } return { width - cnt, ccol }
else return nil end else
return nil
end
end end
--[[ ███████████████ ]]
--[[ ███████████████ ]]-- --
function M.empty_resizer(width, ccol, cnt) function M.empty_resizer(width, ccol, cnt)
if cnt < 100 then if cnt < 100 then
return { width, ccol - width / 2 } return { width, ccol - width / 2 }
else return nil end else
return nil
end
end end
local DEFAULT_OPTS = { local DEFAULT_OPTS = {
@ -213,7 +232,8 @@ function M.toggle()
end end
function M.create_autocmds() function M.create_autocmds()
vim.cmd("augroup Specs") vim.cmd("autocmd!") vim.cmd("augroup Specs")
vim.cmd("autocmd!")
if opts.show_jumps then if opts.show_jumps then
vim.cmd("silent autocmd CursorMoved * :lua require('specs').on_cursor_moved()") vim.cmd("silent autocmd CursorMoved * :lua require('specs').on_cursor_moved()")
end end
@ -222,7 +242,8 @@ function M.create_autocmds()
end end
function M.clear_autocmds() function M.clear_autocmds()
vim.cmd("augroup Specs") vim.cmd("autocmd!") vim.cmd("augroup Specs")
vim.cmd("autocmd!")
vim.cmd("augroup END") vim.cmd("augroup END")
au_toggle = false au_toggle = false
end end