diff --git a/fnl/plugin.fnl b/fnl/plugin.fnl index 322fc6b..7be522c 100644 --- a/fnl/plugin.fnl +++ b/fnl/plugin.fnl @@ -74,73 +74,9 @@ :opt true :run :make }] :setup - (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 :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))] - (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) + (module-call! :plugin.telescope :setup) :config - (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))) + (module-call! :plugin.telescope :config)) ;; Trouble (use! :folke/trouble.nvim diff --git a/fnl/plugin/cmp.fnl b/fnl/plugin/cmp.fnl index 34fd134..829e35a 100644 --- a/fnl/plugin/cmp.fnl +++ b/fnl/plugin/cmp.fnl @@ -60,7 +60,10 @@ { :name "buffer" :priority 0 :group 3 } { :name "path" :priority 0 :group 4 }] :view { - :entries { :name "custom" :selection_order "near_cursor" }} + :entries { + :name "custom" + ; :selection_order "near_cursor" + }} :sorting { :priority_weight 2 :comparators [ @@ -93,7 +96,7 @@ : (cmp.mapping (fn [] (if (cmp.visible) - (cmp.select_next_item) + (cmp.select_prev_item) (do (cmp.complete) (cmp.complete_common_string)))) @@ -101,7 +104,7 @@ : (cmp.mapping (fn [] (if (cmp.visible) - (cmp.select_prev_item) + (cmp.select_next_item) (do (cmp.complete) (cmp.complete_common_string)))) @@ -109,7 +112,7 @@ : (cmp.mapping (fn [] (if (cmp.visible) - (cmp.select_next_item + (cmp.select_prev_item { :behavior cmp.SelectBehavior.Select }) (vim.api.nvim_feedkeys (vim.api.nvim_replace_termcodes : @@ -121,7 +124,7 @@ : (cmp.mapping (fn [] (if (cmp.visible) - (cmp.select_prev_item + (cmp.select_next_item { :behavior cmp.SelectBehavior.Select }) (vim.api.nvim_feedkeys (vim.api.nvim_replace_termcodes : @@ -131,24 +134,24 @@ :n false))) [ :i :c ]) : (cmp.mapping - (cmp.mapping.select_next_item + (cmp.mapping.select_prev_item { :behavior cmp.SelectBehavior.Select }) [ :i :c ]) : (cmp.mapping - (cmp.mapping.select_prev_item + (cmp.mapping.select_next_item { :behavior cmp.SelectBehavior.Select }) [ :i :c ]) : (cmp.mapping (fn [fallback] (if (cmp.visible) - (cmp.select_next_item + (cmp.select_prev_item { :behavior cmp.SelectBehavior.Select }) (fallback))) [ :i :c ]) : (cmp.mapping (fn [fallback] (if (cmp.visible) - (cmp.select_prev_item + (cmp.select_next_item { :behavior cmp.SelectBehavior.Select }) (fallback))) [ :i :c ])}] diff --git a/fnl/plugin/telescope.fnl b/fnl/plugin/telescope.fnl new file mode 100644 index 0000000..ecf4480 --- /dev/null +++ b/fnl/plugin/telescope.fnl @@ -0,0 +1,72 @@ +(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 :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))) } diff --git a/init.fnl b/init.fnl index 2822a54..f84b42b 100644 --- a/init.fnl +++ b/init.fnl @@ -97,6 +97,7 @@ :extension { "nasm" :nasm "h" :c - "ui" :xml }}) + "ui" :xml + "tpp" :cpp }}) (module-call! :packer :startup (require :plugin))