Make jump to term selector use fzf

This commit is contained in:
2022-12-03 22:54:50 -08:00
parent 7a42c9ecf5
commit af45712b8b
2 changed files with 18 additions and 23 deletions

View File

@ -80,7 +80,24 @@
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
(if (= code 0)
(fzf.git_files)
(fzf.files)))))))
(fzf.files)))))
(fn jump-or-open-terminal []
"If no terminal buffer exists, create one. Otherwise, open new one."
(var term_count 0)
(var last_id 0)
(var terms [ ])
(each [_ id (pairs (vim.api.nvim_list_bufs))]
(let [name (vim.api.nvim_buf_get_name id)]
(when (vim.startswith name "term://")
(table.insert terms name)
(set term_count (+ term_count 1))
(set last_id id))))
(if (= term_count 0)
(vim.cmd.terminal)
(= term_count 1)
(vim.cmd.buffer last_id)
(fzf.buffers { :query "term://" })))
(bind! :n :<leader>t jump-or-open-terminal)))
;; Nvim surround
(use! :kylechui/nvim-surround