diff --git a/mzte-nv/conf/lua/pluginconf/p-nvimtree.fnl b/mzte-nv/conf/lua/pluginconf/p-nvimtree.fnl index 316887f..a975177 100644 --- a/mzte-nv/conf/lua/pluginconf/p-nvimtree.fnl +++ b/mzte-nv/conf/lua/pluginconf/p-nvimtree.fnl @@ -7,16 +7,5 @@ :ignore false} :renderer {:indent_markers {:enable true} :group_empty true}}) -;; open on startup -(fn on-enter [data] - (local is-no-name (and (= data.file "") (= (. vim :bo data.buf :buftype) ""))) - (local is-dir (= (vim.fn.isdirectory data.file) 1)) - (when is-dir - (vim.cmd.cd data.file)) - (when (or is-no-name is-dir) - ((. (require :nvim-tree.api) :tree :open)))) - -(vim.api.nvim_create_autocmd [:VimEnter] {:callback on-enter}) - (vim.keymap.set :n :TT #((. (require :nvim-tree.api) :tree :toggle)) (. (require :mzte_nv) :utils :map_opt)) diff --git a/mzte-nv/conf/lua/pluginconf/p-telescope.fnl b/mzte-nv/conf/lua/pluginconf/p-telescope.fnl index 54c27bc..bf95c31 100644 --- a/mzte-nv/conf/lua/pluginconf/p-telescope.fnl +++ b/mzte-nv/conf/lua/pluginconf/p-telescope.fnl @@ -34,7 +34,7 @@ (tset opt k v)) `(do (nmap ,(.. :g suffix) ,action ,opt) - (nmap ,(.. :gt suffix) ,action + (nmap ,(.. :gn suffix) ,action ,(doto (collect [k v (pairs opt)] k v) (tset :jump_type :tab))) (nmap ,(.. :gs suffix) ,action diff --git a/mzte-nv/conf/lua/plugins.fnl b/mzte-nv/conf/lua/plugins.fnl index 8e8f894..e2e7a03 100644 --- a/mzte-nv/conf/lua/plugins.fnl +++ b/mzte-nv/conf/lua/plugins.fnl @@ -1,38 +1,61 @@ (local mztenv (require :mzte_nv)) +(tset mztenv.reg :plugin_load_callbacks []) + (let [path mztenv.reg.nvim_plugins] (when path (vim.opt.runtimepath:append (.. path "/*")))) -(let [plugins [:lspconf - :cmp - :luasnip - :nullls - :catppuccin - :line - :treesitter - :devicons - :nvimtree - :neogit - :telescope - :autopairs - :tterm - :ts-context - :ufo - :aerial - :dap - :harpoon - :recorder - :noice - :tsn-actions - :lightbulb - :dressing] - errors {}] - (each [_ p (ipairs plugins)] - (let [(success ret) (pcall require (.. :pluginconf/p- p))] - (when (not success) - (tset errors p ret)))) - (when (next errors) - (vim.notify (accumulate [text "Errors loading plugin configs:\n" plugin err (pairs errors)] - (.. text " - " plugin ": " err)) - vim.log.levels.error))) +;; Plugins to load before nvim finishes startup +(local startup-plugins []) + +;; Plugins to load in the background +(local deferred-plugins [:lspconf + :cmp + :luasnip + :nullls + :catppuccin + :line + :treesitter + :nvimtree + :devicons + :neogit + :telescope + :autopairs + :tterm + :ts-context + :ufo + :aerial + :dap + :harpoon + :recorder + :noice + :tsn-actions + :lightbulb + :dressing]) + +(local errors {}) + +(fn load-plugin [plugin] + (let [(success ret) (pcall require (.. :pluginconf/p- plugin))] + (when (not success) + (tset errors p ret)))) + +(each [_ p (ipairs startup-plugins)] + (load-plugin p)) + +(fn load-one-deferred [idx] + (let [plugin (. deferred-plugins idx)] + (if plugin + (do + (load-plugin plugin) + (vim.schedule #(load-one-deferred (+ idx 1)))) + (do + (when (next errors) + (vim.notify (accumulate [text "Errors loading plugin configs:\n" plugin err (pairs errors)] + (.. text " - " plugin ": " err)) + vim.log.levels.error)) + (each [_ cb (ipairs mztenv.reg.plugin_load_callbacks)] + (pcall cb)))))) + +(vim.schedule #(load-one-deferred 1))