about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--fnl/nvrc/keymaps.fnl19
-rw-r--r--fnl/nvrc/macro/pack.fnl2
-rw-r--r--fnl/nvrc/pack.fnl5
-rw-r--r--fnl/nvrc/utils.fnl124
4 files changed, 54 insertions, 96 deletions
diff --git a/fnl/nvrc/keymaps.fnl b/fnl/nvrc/keymaps.fnl
index 67b0d70..790d21b 100644
--- a/fnl/nvrc/keymaps.fnl
+++ b/fnl/nvrc/keymaps.fnl
@@ -12,14 +12,12 @@
 (map! [v :silent] :<leader>/
       ":lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode()) <cr>")
 
-(map! [n :silent] :<leader>ff ":Telescope find_files <cr>")
-(map! [n :silent] :<leader>fc ":Telescope grep_string <cr>")
-(map! [n :silent] :<leader>fs ":Telescope live_grep <cr>")
-(map! [n :silent] :<leader>fa
-      ":Telescope find_files follow=true no_ignore=true hidden=true <cr>")
-(map! [n :silent] :<leader>fb ":Telescope buffers <cr>")
-(map! [n :silent] :<leader>gc ":Telescope git_commits <cr>")
-(map! [n :silent] :<leader>gs ":Telescope git_status <cr>")
+(map! [n :silent] :<leader>ff ":FzfLua files <cr>")
+(map! [n :silent] :<leader>fc ":FzfLua grep <cr>")
+(map! [n :silent] :<leader>fs ":FzfLua live_grep <cr>")
+(map! [n :silent] :<leader>fb ":FzfLua buffers <cr>")
+(map! [n :silent] :<leader>gc ":FzfLua git_commits <cr>")
+(map! [n :silent] :<leader>gs ":FzfLua git_status <cr>")
 
 (map! [n] :f :<plug>Lightspeed_f)
 (map! [n] :F :<plug>Lightspeed_F)
@@ -31,14 +29,13 @@
 (map! [n :silent] :<leader>ra ":TZAtaraxis <cr>")
 
 (map! [t] :jk "<C-\\><C-n>")
-(map! [t :silent] :JK "<C-\\><C-n> :lua require ('nvrc.utils').close_buf() <cr>")
-(map! [n :silent] :<leader>tl ":Telescope terms <cr>")
+(map! [t :silent] :JK "<C-\\><C-n> :lua require ('nvrc.utils').del_buf() <cr>")
 ; FIXME This opens on top of existing vertical/horizontal term
 (map! [n :silent] :<leader>th ":execute 15 .. 'new +terminal' | let b:term_type = 'hori' <cr>")
 (map! [n :silent] :<leader>tv ":execute 'vnew +terminal' | let b:term_type = 'vert' <cr>")
 (map! [n :silent] :<leader>tn ":execute 'terminal' | let b:term_type = 'wind' <cr>")
 
-(map! [n :silent] :<leader>q ":lua require('nvrc.utils').close_buf() <cr>")
+(map! [n :silent] :<leader>q ":lua require('nvrc.utils').del_buf() <cr>")
 (map! [n :silent] :<leader>ya ":%y+ <cr>")
 (map! [n :silent] :<leader>bn ":enew <cr>")
 (map! [n :silent] :<leader>wn ":tabnew <cr>")
diff --git a/fnl/nvrc/macro/pack.fnl b/fnl/nvrc/macro/pack.fnl
index 5ba7896..0adb18a 100644
--- a/fnl/nvrc/macro/pack.fnl
+++ b/fnl/nvrc/macro/pack.fnl
@@ -25,7 +25,7 @@
         options (collect [k v (pairs options)]
                          (if
                            (= k :req) (values :config (format "require('nvrc.packs.%s')" v))
-                           (= k :init) (values :config (format "require('%s').setup()" v))
+                           (= k :init) (values :config (format "require('%s').setup({})" v))
                            (= k :defer) (values :setup (format "require('nvrc.utils').defer_unpack('%s', 5)" v))
                            (values k v)))]
     (doto options
diff --git a/fnl/nvrc/pack.fnl b/fnl/nvrc/pack.fnl
index a1c611a..35bd6df 100644
--- a/fnl/nvrc/pack.fnl
+++ b/fnl/nvrc/pack.fnl
@@ -24,10 +24,9 @@
 (pack! :luukvbaal/stabilize.nvim {:after :jellybeans.vim :init :stabilize})
 (pack! :numToStr/Comment.nvim {:module :Comment :init :Comment})
 ; TODO: https://github.com/kyazdani42/nvim-tree.lua/issues/951
-(pack! :kyazdani42/nvim-tree.lua {:req :nvimtree :cmd [:NvimTreeToggle :NvimTreeFocus] :commit "d8bf1ad"})
+(pack! :kyazdani42/nvim-tree.lua {:req :nvimtree :defer :nvim-tree.lua})
 (pack! :ggandor/lightspeed.nvim {:keys [:s :S :x :X :f :F]})
-(pack! :nvim-telescope/telescope.nvim {:req :telescope :module :telescope :cmd :Telescope})
-(pack! :boppyt/nvrc-extra)
+(pack! :ibhagwan/fzf-lua {:init :fzf-lua :module :fzf-lua :cmd :FzfLua})
 
 (pack! :bakpakin/fennel.vim {:ft :fennel})
 
diff --git a/fnl/nvrc/utils.fnl b/fnl/nvrc/utils.fnl
index 6812c0c..52ca454 100644
--- a/fnl/nvrc/utils.fnl
+++ b/fnl/nvrc/utils.fnl
@@ -19,15 +19,15 @@
   the previous value as the first arg. Starting with init."
   (var result init)
   (run! (fn [x]
-                (set result (f result x))) xs)
+          (set result (f result x))) xs)
   result)
 
 (fn merge! [base ...]
   (reduce (fn [acc m]
-                  (when m
-                    (each [k v (pairs m)]
-                      (tset acc k v)))
-                  acc) (or base {}) [...]))
+            (when m
+              (each [k v (pairs m)]
+                (tset acc k v)))
+            acc) (or base {}) [...]))
 
 (fn merge [...]
   (merge! {} ...))
@@ -37,91 +37,53 @@
   (let [lsp (. (vim.lsp.util.get_progress_messages) 1)]
     (when lsp
       (let [msg (or lsp.message "")
-          percentage (or lsp.percentage 0)
-          title (or lsp.title "")
-          spinners {1"⠋" 2 "⠙" 3 "⠹" 4 "⠸" 5 "⠼" 6 "⠴" 7 "⠦" 8 "⠧" 9 "⠇" 10 "⠏"}
-          success-icon "^.^!"
-          ms (/ (vim.loop.hrtime) 1000000)
-          frame (% (math.floor (/ ms 120)) (length spinners))]
-      (when (>= percentage 70)
+            percentage (or lsp.percentage 0)
+            title (or lsp.title "")
+            spinners {1 "⠋"
+                      2 "⠙"
+                      3 "⠹"
+                      4 "⠸"
+                      5 "⠼"
+                      6 "⠴"
+                      7 "⠦"
+                      8 "⠧"
+                      9 "⠇"
+                      10 "⠏"}
+            success-icon "^.^!"
+            ms (/ (vim.loop.hrtime) 1000000)
+            frame (% (math.floor (/ ms 120)) (length spinners))]
+        (when (>= percentage 70)
+          (let [ertn [(string.format " %%<%s %s %s (%s%%%%) " success-icon
+                                     title msg percentage)]]
+            (lua "return (table.unpack or _G.unpack)(ertn)")))
         (let [ertn [(string.format " %%<%s %s %s (%s%%%%) "
-                                   success-icon
-                                   title msg
-                                   percentage)]]
-          (lua "return (table.unpack or _G.unpack)(ertn)")))
-      (let [ertn [(string.format " %%<%s %s %s (%s%%%%) "
-                                 (. spinners
-                                    (+ frame 1))
-                                 title msg
-                                 percentage)]]
-        (lua "return (table.unpack or _G.unpack)(ertn)"))))) "")
+                                   (. spinners (+ frame 1)) title msg percentage)]]
+          (lua "return (table.unpack or _G.unpack)(ertn)")))))
+  "")
 
 (fn will_it_fit [width winid]
   "Returns whether this module will fit in the given width"
   (> (vim.api.nvim_win_get_width (or (tonumber winid) 0)) width))
 
-(fn close_buf [force]
-  "ojroques/nvim-bufdel 'BSD-2'"
-  (let [opts {:next :cycle :quit false}]
-    (fn switch-buffer [windows buf]
-      (let [cur-win (vim.fn.winnr)]
-        (each [_ winid (ipairs windows)]
-          (set-forcibly! winid (or (tonumber winid) 0))
-          (vim.cmd (string.format "%d wincmd w" (vim.fn.win_id2win winid)))
-          (vim.cmd (string.format "buffer %d" buf)))
-        (vim.cmd (string.format "%d wincmd w" cur-win))))
-
-    (fn get-next-buf [buf]
-      (var next (vim.fn.bufnr "#"))
-      (when (and (= opts.next :alternate) (= (vim.fn.buflisted next) 1))
-        (lua "return next"))
-      (for [i 0 (- (vim.fn.bufnr "$") 1) 1]
-        (set next (+ (% (+ buf i) (vim.fn.bufnr "$")) 1))
-        (when (= (vim.fn.buflisted next) 1)
-          (lua "return next"))))
-
-    (local buf (vim.fn.bufnr))
-    (when (= (vim.fn.buflisted buf) 0)
-      (vim.cmd :close)
+(fn del_buf []
+  (let [buflisted (vim.fn.getbufinfo {:buflisted 1})
+        (cur-winnr cur-bufnr) (values (vim.fn.winnr) (vim.fn.bufnr))]
+    (when (< (length buflisted) 2)
+      (vim.cmd "confirm qall")
       (lua "return "))
-    (when (< (length (vim.fn.getbufinfo {:buflisted 1})) 2)
-      (when opts.quit
-        (if force (vim.cmd :qall!) (vim.cmd "confirm qall"))
-        (lua "return "))
-      (local (term _)
-             (pcall (fn []
-                      (vim.api.nvim_buf_get_var buf :term_type))))
-      (when term
-        (vim.cmd (string.format "setlocal nobl" buf))
-        (vim.cmd :enew)
-        (lua "return "))
-      (vim.cmd :enew)
-      (vim.cmd :bp))
-    (local next-buf (get-next-buf buf))
-    (local windows (. (. (vim.fn.getbufinfo buf) 1) :windows))
-    (if (or force (= (vim.fn.getbufvar buf :&buftype) :terminal))
-        (let [(term type) (pcall (fn []
-                                   (vim.api.nvim_buf_get_var buf :term_type)))]
-          (if term
-              (if (= type :wind)
-                  (do
-                    (vim.cmd (string.format "%d bufdo setlocal nobl" buf))
-                    (vim.cmd :BufferLineCycleNext))
-                  (let [cur-win (vim.fn.winnr)]
-                    (vim.cmd (string.format "%d wincmd c" cur-win))
-                    (lua "return ")))
-              (do
-                (switch-buffer windows next-buf)
-                (vim.cmd (string.format "bd! %d" buf)))))
-        (do
-          (switch-buffer windows next-buf)
-          (vim.cmd (string.format "silent! confirm bd %d" buf))))
-    (when (= (vim.fn.buflisted buf) 1)
-      (switch-buffer windows buf))))
+    (each [_ winid (ipairs (. (. (vim.fn.getbufinfo cur-bufnr) 1) :windows))]
+      (vim.cmd (string.format "%d wincmd w" (vim.fn.win_id2win winid)))
+      (vim.cmd (or (and (= cur-bufnr (. (. buflisted (length buflisted)) :bufnr))
+                    :bp) :bn)))
+    (vim.cmd (string.format "%d wincmd w" cur-winnr))
+    (local is-terminal (= (vim.fn.getbufvar cur-bufnr :&buftype) :terminal))
+    (vim.cmd (or (and is-terminal "bd! #") "silent! confirm bd #"))))
 
 (fn defer_unpack [pack after]
   (when pack
     (set-forcibly! after (or after 0))
-    (vim.defer_fn (fn [] ((. (require :packer) :loader) pack)) after)))
+    (vim.defer_fn (fn []
+                    ((. (require :packer) :loader) pack))
+                  after)))
 
-{: merge : lsp_fidget : will_it_fit : close_buf : defer_unpack}
+{: merge : lsp_fidget : will_it_fit : del_buf : defer_unpack}