mirror of
https://github.com/NotAShelf/specs.nvim.git
synced 2024-12-27 05:02:24 +00:00
feat: add option to toggle
This commit is contained in:
parent
a03c03ed53
commit
a62319a224
2 changed files with 18 additions and 0 deletions
|
@ -43,6 +43,9 @@ require('specs').setup{
|
|||
}
|
||||
```
|
||||
|
||||
- `:lua require('specs').toggle()`
|
||||
- Toggle Specs on/off
|
||||
|
||||
Faders:
|
||||
- linear_fader `▁▂▂▃▃▄▄▅▅▆▆▇▇██`
|
||||
- exp_fader `▁▁▁▁▂▂▂▃▃▃▄▄▅▆▇`
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue