Make jump to term selector use fzf
This commit is contained in:
parent
7a42c9ecf5
commit
af45712b8b
@ -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
|
||||
|
22
init.fnl
22
init.fnl
@ -81,28 +81,6 @@
|
||||
#(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1)
|
||||
(set vim.opt_local.spell true)))
|
||||
|
||||
(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)
|
||||
(vim.ui.select terms
|
||||
{ :prompt "Terminal Buffers" }
|
||||
(fn [choice]
|
||||
(when choice
|
||||
(vim.cmd.buffer choice))))))
|
||||
(bind! :n :<leader>t jump-or-open-terminal)
|
||||
|
||||
;; Some keybindings for diagnostics
|
||||
(bind! :n :<leader>e vim.diagnostic.open_float)
|
||||
(bind! :n "[d" vim.diagnostic.goto_prev)
|
||||
|
Reference in New Issue
Block a user