mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-06-14 09:18:50 +02:00
mzte-nv: load plugins in chunked event loop callbacks
TODO: move into MZTE-NV with libUV idler
This commit is contained in:
parent
73b009dd51
commit
acf4abc8ba
|
@ -7,16 +7,5 @@
|
||||||
:ignore false}
|
:ignore false}
|
||||||
:renderer {:indent_markers {:enable true} :group_empty true}})
|
: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))
|
(vim.keymap.set :n :TT #((. (require :nvim-tree.api) :tree :toggle))
|
||||||
(. (require :mzte_nv) :utils :map_opt))
|
(. (require :mzte_nv) :utils :map_opt))
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
(tset opt k v))
|
(tset opt k v))
|
||||||
`(do
|
`(do
|
||||||
(nmap ,(.. :g suffix) ,action ,opt)
|
(nmap ,(.. :g suffix) ,action ,opt)
|
||||||
(nmap ,(.. :gt suffix) ,action
|
(nmap ,(.. :gn suffix) ,action
|
||||||
,(doto (collect [k v (pairs opt)] k v)
|
,(doto (collect [k v (pairs opt)] k v)
|
||||||
(tset :jump_type :tab)))
|
(tset :jump_type :tab)))
|
||||||
(nmap ,(.. :gs suffix) ,action
|
(nmap ,(.. :gs suffix) ,action
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
(local mztenv (require :mzte_nv))
|
(local mztenv (require :mzte_nv))
|
||||||
|
|
||||||
|
(tset mztenv.reg :plugin_load_callbacks [])
|
||||||
|
|
||||||
(let [path mztenv.reg.nvim_plugins]
|
(let [path mztenv.reg.nvim_plugins]
|
||||||
(when path
|
(when path
|
||||||
(vim.opt.runtimepath:append (.. path "/*"))))
|
(vim.opt.runtimepath:append (.. path "/*"))))
|
||||||
|
|
||||||
(let [plugins [:lspconf
|
;; Plugins to load before nvim finishes startup
|
||||||
|
(local startup-plugins [])
|
||||||
|
|
||||||
|
;; Plugins to load in the background
|
||||||
|
(local deferred-plugins [:lspconf
|
||||||
:cmp
|
:cmp
|
||||||
:luasnip
|
:luasnip
|
||||||
:nullls
|
:nullls
|
||||||
:catppuccin
|
:catppuccin
|
||||||
:line
|
:line
|
||||||
:treesitter
|
:treesitter
|
||||||
:devicons
|
|
||||||
:nvimtree
|
:nvimtree
|
||||||
|
:devicons
|
||||||
:neogit
|
:neogit
|
||||||
:telescope
|
:telescope
|
||||||
:autopairs
|
:autopairs
|
||||||
|
@ -26,13 +32,30 @@
|
||||||
:noice
|
:noice
|
||||||
:tsn-actions
|
:tsn-actions
|
||||||
:lightbulb
|
:lightbulb
|
||||||
:dressing]
|
:dressing])
|
||||||
errors {}]
|
|
||||||
(each [_ p (ipairs plugins)]
|
(local errors {})
|
||||||
(let [(success ret) (pcall require (.. :pluginconf/p- p))]
|
|
||||||
|
(fn load-plugin [plugin]
|
||||||
|
(let [(success ret) (pcall require (.. :pluginconf/p- plugin))]
|
||||||
(when (not success)
|
(when (not success)
|
||||||
(tset errors p ret))))
|
(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)
|
(when (next errors)
|
||||||
(vim.notify (accumulate [text "Errors loading plugin configs:\n" plugin err (pairs errors)]
|
(vim.notify (accumulate [text "Errors loading plugin configs:\n" plugin err (pairs errors)]
|
||||||
(.. text " - " plugin ": " err))
|
(.. text " - " plugin ": " err))
|
||||||
vim.log.levels.error)))
|
vim.log.levels.error))
|
||||||
|
(each [_ cb (ipairs mztenv.reg.plugin_load_callbacks)]
|
||||||
|
(pcall cb))))))
|
||||||
|
|
||||||
|
(vim.schedule #(load-one-deferred 1))
|
||||||
|
|
Loading…
Reference in a new issue