This repository has been archived on 2024-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
nvim-config/fnl/plugin/telescope.fnl

72 lines
3.6 KiB
Plaintext
Raw Normal View History

2023-02-23 11:41:01 -08:00
(import-macros {: bind! : setup! : module-call!} :macros)
{ :setup (fn []
(bind! :n :<leader>fq "<cmd>Telescope quickfix<cr>")
(bind! :n :<leader>fr "<cmd>Telescope registers<cr>")
(bind! :n :<leader>fj "<cmd>Telescope jumplist<cr>")
(bind! :n :<leader>fa "<cmd>Telescope marks<cr>")
(bind! :n :<leader>fh "<cmd>Telescope help_tags<cr>")
(bind! :n :<leader>g "<cmd>Telescope live_grep<cr>")
(bind! :n :<leader>fg "<cmd>Telescope live_grep<cr>")
(bind! :n :<leader>d "<cmd>Telescope treesitter<cr>")
(bind! :n :<leader>b "<cmd>Telescope buffers<cr>")
(bind! :n :<leader>fu "<cmd>Telescope git_status<cr>")
(bind! :n :<leader>fm "<cmd>Telescope man_pages<cr>")
(bind! :n :<leader>fe "<cmd>Telescope diagnostics<cr>")
(bind! :n :<leader>fl "<cmd>Telescope loclist<cr>")
(bind! :n :<leader>fp "<cmd>Telescope spell_suggest<cr>")
(bind! :n :<leader>fo "<cmd>Telescope vim_options<cr>")
(bind! :n :<leader>c "<cmd>Telescope command_history<cr>")
(bind! :n :<leader>i "<cmd>Telescope find_files<cr>")
(bind! :n :z= "<cmd>Telescope spell_suggest<cr>")
(fn list-git-or-default []
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
(if (= code 0)
(vim.cmd "Telescope git_files")
(vim.cmd "Telescope find_files"))))
(bind! :n :<leader>ff list-git-or-default)
(bind! :n :<leader>u list-git-or-default)
(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))]
(when (and (vim.api.nvim_buf_is_loaded id)
(vim.api.nvim_buf_get_option id :buflisted))
(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)))))
2023-02-23 11:41:01 -08:00
(if (= term_count 0)
(vim.cmd.terminal)
(= term_count 1)
(vim.cmd.buffer last_id)
(vim.cmd "Telescope buffers default_text=term://")))
(bind! :n :<leader>t jump-or-open-terminal))
:config (fn []
(vim.cmd "PackerLoad plenary.nvim")
(vim.cmd "PackerLoad telescope-ui-select.nvim")
(vim.cmd "PackerLoad telescope-fzf-native.nvim")
(let [actions (require :telescope.actions)]
(setup! :telescope
:defaults {
:mappings {
:i { :<esc> actions.close
:<C-k> actions.move_selection_previous
:<C-j> actions.move_selection_next }
:n { :<C-k> actions.move_selection_previous
:<C-j> actions.move_selection_next }}}
:pickers {
:buffers {
;;:ignore_current_buffer true
:sort_lastused true }}
:extensions {
:ui-select [
(module-call! :telescope.themes :get_dropdown)
]
})
(module-call! :telescope :load_extension :ui-select)
(module-call! :telescope :load_extension :fzf))) }