feat: add option to toggle

This commit is contained in:
edluffy 2021-05-05 15:46:06 +01:00
parent a03c03ed53
commit a62319a224
2 changed files with 18 additions and 0 deletions

View file

@ -43,6 +43,9 @@ require('specs').setup{
}
```
- `:lua require('specs').toggle()`
- Toggle Specs on/off
Faders:
- linear_fader `▁▂▂▃▃▄▄▅▅▆▆▇▇██`
- exp_fader `▁▁▁▁▂▂▂▃▃▃▄▄▅▆▇`

View file

@ -2,6 +2,7 @@ local M = {}
local opts = {}
local old_cur
local au_toggle
function M.on_cursor_moved()
local cur = vim.api.nvim_win_get_cursor(0)
@ -184,13 +185,27 @@ function M.setup(user_opts)
M.create_autocmds()
end
function M.toggle()
if au_toggle then
M.clear_autocmds()
else
M.create_autocmds()
end
end
function M.create_autocmds()
vim.cmd("augroup Specs") vim.cmd("autocmd!")
if opts.show_jumps then
vim.cmd("silent autocmd CursorMoved * :lua require('specs').on_cursor_moved()")
end
vim.cmd("augroup END")
au_toggle = true
end
function M.clear_autocmds()
vim.cmd("augroup Specs") vim.cmd("autocmd!")
vim.cmd("augroup END")
au_toggle = false
end
return M