(import-macros {: bind! : setup! : module-call!} :macros) { :setup (fn [] (bind! :n :fq "Telescope quickfix") (bind! :n :fr "Telescope registers") (bind! :n :fj "Telescope jumplist") (bind! :n :fa "Telescope marks") (bind! :n :fh "Telescope help_tags") (bind! :n :g "Telescope live_grep") (bind! :n :fg "Telescope live_grep") (bind! :n :d "Telescope treesitter") (bind! :n :b "Telescope buffers") (bind! :n :fu "Telescope git_status") (bind! :n :fm "Telescope man_pages") (bind! :n :fe "Telescope diagnostics") (bind! :n :fl "Telescope loclist") (bind! :n :fp "Telescope spell_suggest") (bind! :n :fo "Telescope vim_options") (bind! :n :c "Telescope command_history") (bind! :n :i "Telescope find_files") (bind! :n :z= "Telescope spell_suggest") (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 :ff list-git-or-default) (bind! :n :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))))) (if (= term_count 0) (vim.cmd.terminal) (= term_count 1) (vim.cmd.buffer last_id) (vim.cmd "Telescope buffers default_text=term://"))) (bind! :n :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 { : actions.close : actions.move_selection_previous : actions.move_selection_next } :n { : actions.move_selection_previous : 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))) }