Add pkg macro to only load config when plugin is loaded

This commit is contained in:
elkowar 2021-05-05 19:23:32 +02:00
parent a6b4d0dbdc
commit f06c064719
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
6 changed files with 127 additions and 102 deletions

View file

@ -4,26 +4,26 @@
nvim aniseed.nvim nvim aniseed.nvim
str aniseed.string str aniseed.string
kb keybinds kb keybinds
utils utils utils utils}
nvim-treesitter-configs nvim-treesitter.configs
gitsigns gitsigns}
require-macros [macros]}) require-macros [macros]})
(macro make-errors-epic [f] (macro make-errors-epic [f]
`(xpcall #,f #(a.println (fennel.traceback $1)))) `(xpcall #,f #(a.println (fennel.traceback $1))))
(make-errors-epic (require "plugins.telescope"))
(make-errors-epic (require "plugins.lsp")) (make-errors-epic (require "plugins.lsp"))
(make-errors-epic (require "plugins.galaxyline"))
(make-errors-epic (require "plugins.bufferline")) (when (utils.plugin-installed? :telescope.nvim)
(make-errors-epic (require "plugins.telescope")))
(when (utils.plugin-installed? :galaxyline.nvim)
(make-errors-epic (require "plugins.galaxyline")))
(when (utils.plugin-installed? :nvim-bufferline.lua)
(make-errors-epic (require "plugins.bufferline")))
(def- colors utils.colors) (def- colors utils.colors)
;(tset debug :traceback fennel.traceback) (when (utils.plugin-installed? :conjure)
(set vim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed."))
(set vim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed.")
; Colors ------------------------------------------------------- foldstart ; Colors ------------------------------------------------------- foldstart
@ -37,7 +37,9 @@
; Treesitter ------------------------------------------------------- foldstart ; Treesitter ------------------------------------------------------- foldstart
(nvim-treesitter-configs.setup
(pkg :nvim-treesitter [configs (require "nvim-treesitter.configs")]
(configs.setup
{:ensure_installed "all" {:ensure_installed "all"
:highlight {:enable true :highlight {:enable true
:disable ["fennel"]} :disable ["fennel"]}
@ -56,7 +58,7 @@
;:rainbow { :enable true ;:rainbow { :enable true
;:extended_mode true} ;:extended_mode true}
:context_commentstring {:enable true}}) :context_commentstring {:enable true}}))
;(nvim-biscuits.setup {} ;(nvim-biscuits.setup {}
;{ :on_events ["InsertLeave" "CursorHoldI"]}) ;{ :on_events ["InsertLeave" "CursorHoldI"]})
@ -65,6 +67,7 @@
; gitsigns.nvim ------------------------------------------------------- foldstart ; gitsigns.nvim ------------------------------------------------------- foldstart
; https://github.com/lewis6991/gitsigns.nvim ; https://github.com/lewis6991/gitsigns.nvim
(pkg :gitsigns.nvim [gitsigns (require "gitsigns")]
(gitsigns.setup (gitsigns.setup
{:signs {:add {:text "▍"} {:signs {:add {:text "▍"}
:change {:text "▍"} :change {:text "▍"}
@ -78,13 +81,12 @@
(utils.highlight "GitSignsAdd" {:bg "NONE" :fg colors.bright_aqua}) (utils.highlight "GitSignsAdd" {:bg "NONE" :fg colors.bright_aqua})
(utils.highlight "GitSignsDelete" {:bg "NONE" :fg colors.neutral_red}) (utils.highlight "GitSignsDelete" {:bg "NONE" :fg colors.neutral_red})
(utils.highlight "GitSignsChange" {:bg "NONE" :fg colors.bright_blue}) (utils.highlight "GitSignsChange" {:bg "NONE" :fg colors.bright_blue}))
; foldend ; foldend
; :: diffview ------------------------------------------------------------------- foldstart ; :: diffview ------------------------------------------------------------------- foldstart
(pkg :diffview.nvim [diffview (require "diffview")
(let [diffview (require "diffview")
cb (. (require "diffview.config") :diffview_callback)] cb (. (require "diffview.config") :diffview_callback)]
(diffview.setup (diffview.setup
{:diff_binaries false {:diff_binaries false
@ -122,4 +124,12 @@
; foldend ; foldend
; vim:foldmarker=foldstart,foldend ; vim:foldmarker=foldstart,foldend

View file

@ -16,7 +16,6 @@
(fn cmd [s desc] [(.. "<cmd>" s "<cr>") desc]) (fn cmd [s desc] [(.. "<cmd>" s "<cr>") desc])
(fn le [s desc] (cmd (.. "call luaeval(\"" s "\")") desc))
(fn rebind [s desc] [s desc]) (fn rebind [s desc] [s desc])
(wk.setup {}) (wk.setup {})

View file

@ -22,5 +22,13 @@
(fn [x ...] (fn [x ...]
`(do `(do
(a.println ,...) (a.println ,...)
(,x ,...)))} (,x ,...)))
:pkg
(fn [name mappings ...]
`(if (~= nil (. packer_plugins ,name))
(let ,mappings ,...)
(print (.. "plugin disabled " ,name))))}

View file

@ -4,25 +4,22 @@
nvim aniseed.nvim nvim aniseed.nvim
lsp lspconfig lsp lspconfig
lsp-configs lspconfig.configs lsp-configs lspconfig.configs
saga lspsaga utils utils}
utils utils
compe compe
lsp_signature lsp_signature
symbols-outline symbols-outline
trouble trouble
rust-tools rust-tools}
require-macros [macros]}) require-macros [macros]})
(def- colors utils.colors) (def- colors utils.colors)
(symbols-outline.setup { :highlight_hovered_item true :show_guides true}) (pkg :symbols-outline.nvim [symbols-outline (require "symbols-outline")]
(symbols-outline.setup { :highlight_hovered_item true :show_guides true}))
; LSP config -------------------------------------------------------------------------------- <<<<< ; LSP config -------------------------------------------------------------------------------- <<<<<
(fn on_attach [client bufnr] (fn on_attach [client bufnr]
(lsp_signature.on_attach) (pkg :lsp_signature.nvim [lsp_signature (require "lsp_signature")]
(lsp_signature.on_attach))
(if client.resolved_capabilities.document_highlight (if client.resolved_capabilities.document_highlight
(do (do
(utils.highlight "LspReferenceRead" {:gui "underline"}) (utils.highlight "LspReferenceRead" {:gui "underline"})
@ -74,6 +71,7 @@
; >>>>> ; >>>>>
; compe -------------------------------------------------------------------------------- <<<<< ; compe -------------------------------------------------------------------------------- <<<<<
(pkg :nvim-compe [compe (require "compe")]
(compe.setup (compe.setup
{:enabled true {:enabled true
:autocomplete false :autocomplete false
@ -93,12 +91,12 @@
:nvim_lsp true :nvim_lsp true
:nvim_lua true :nvim_lua true
:vsnip false :vsnip false
:conjure true}}) :conjure true}}))
; >>>>> ; >>>>>
; LSP saga -------------------------------------------------------------------------------- <<<<< ; LSP saga -------------------------------------------------------------------------------- <<<<<
(pkg :lspsaga.nvim [saga (require "lspsaga")]
(saga.init_lsp_saga (saga.init_lsp_saga
{:border_style "single" ; single double round plus {:border_style "single" ; single double round plus
:code_action_prompt {:enable true :code_action_prompt {:enable true
@ -114,7 +112,6 @@
:scroll_down "<C-d>"}}) :scroll_down "<C-d>"}})
(utils.highlight [ "LspFloatWinNormal" ] {:bg colors.dark0_hard})
(utils.highlight ["LspFloatWinBorder" (utils.highlight ["LspFloatWinBorder"
"LspSagaHoverBorder" "LspSagaHoverBorder"
"LspSagaRenameBorder" "LspSagaRenameBorder"
@ -135,12 +132,17 @@
"LspSagaCodeActionContent" "LspSagaCodeActionContent"
"LspSagaFinderSelection" "LspSagaFinderSelection"
"LspSagaDiagnosticHeader"] "LspSagaDiagnosticHeader"]
{ :fg colors.bright_aqua}) {:fg colors.bright_aqua}))
(utils.highlight "LspFloatWinNormal" {:bg colors.dark0_hard})
(utils.highlight "LspFloatWinBorder" {:bg colors.dark0_hard
:fg colors.dark0_hard})
(utils.highlight "TargetWord" {:fg colors.bright_aqua})
; >>>>> ; >>>>>
; LSP trouble -------------------------------------------------------------------------------- <<<<< ; LSP trouble -------------------------------------------------------------------------------- <<<<<
(pkg :lsp-trouble.nvim [trouble (require "trouble")]
(trouble.setup (trouble.setup
{:icons false {:icons false
:auto_preview true :auto_preview true
@ -153,7 +155,6 @@
:cancel "q" :cancel "q"
:hover ["a" "K"]}}) :hover ["a" "K"]}})
(utils.highlight "LspTroubleFoldIcon" {:bg "NONE" :fg colors.bright_orange}) (utils.highlight "LspTroubleFoldIcon" {:bg "NONE" :fg colors.bright_orange})
(utils.highlight "LspTroubleCount" {:bg "NONE" :fg colors.bright_green}) (utils.highlight "LspTroubleCount" {:bg "NONE" :fg colors.bright_green})
(utils.highlight "LspTroubleText" {:bg "NONE" :fg colors.light0}) (utils.highlight "LspTroubleText" {:bg "NONE" :fg colors.light0})
@ -161,7 +162,7 @@
(utils.highlight "LspTroubleSignError" {:bg "NONE" :fg colors.bright_red}) (utils.highlight "LspTroubleSignError" {:bg "NONE" :fg colors.bright_red})
(utils.highlight "LspTroubleSignWarning" {:bg "NONE" :fg colors.bright_yellow}) (utils.highlight "LspTroubleSignWarning" {:bg "NONE" :fg colors.bright_yellow})
(utils.highlight "LspTroubleSignInformation" {:bg "NONE" :fg colors.bright_aqua}) (utils.highlight "LspTroubleSignInformation" {:bg "NONE" :fg colors.bright_aqua})
(utils.highlight "LspTroubleSignHint" {:bg "NONE" :fg colors.bright_blue}) (utils.highlight "LspTroubleSignHint" {:bg "NONE" :fg colors.bright_blue}))
; >>>>> ; >>>>>
@ -169,7 +170,8 @@
; >>>>> ; >>>>>
(rust-tools.setup { :tools { :inlay_hints { :show_parameter_hints false}}}) (pkg :rust-tools.nvim [rust-tools (require "rust-tools")]
(rust-tools.setup { :tools { :inlay_hints { :show_parameter_hints false}}}))
(set vim.o.signcolumn "yes") (set vim.o.signcolumn "yes")

View file

@ -4,6 +4,11 @@
nvim aniseed.nvim} nvim aniseed.nvim}
require-macros [macros]}) require-macros [macros]})
(def req
(setmetatable {} {:__index (fn [_ idx] (require idx))}))
(defn plugin-installed? [name]
(~= nil (. packer_plugins name)))
(defn dbg [x] (defn dbg [x]
(a.println (fennel.view x)) (a.println (fennel.view x))

View file

@ -542,6 +542,7 @@ myManageHook :: Query (Data.Monoid.Endo WindowSet)
myManageHook = composeAll myManageHook = composeAll
[ resource =? "Dialog" --> ManageHelpers.doCenterFloat [ resource =? "Dialog" --> ManageHelpers.doCenterFloat
, appName =? "pavucontrol" --> ManageHelpers.doCenterFloat , appName =? "pavucontrol" --> ManageHelpers.doCenterFloat
, className =? "Myxer" --> ManageHelpers.doCenterFloat
--, className =? "mpv" --> ManageHelpers.doRectFloat (W.RationalRect 0.9 0.9 0.1 0.1) --, className =? "mpv" --> ManageHelpers.doRectFloat (W.RationalRect 0.9 0.9 0.1 0.1)
, title =? "Something" --> doFloat , title =? "Something" --> doFloat
, className =? "termite_floating" --> ManageHelpers.doRectFloat(W.RationalRect 0.2 0.2 0.6 0.6) , className =? "termite_floating" --> ManageHelpers.doRectFloat(W.RationalRect 0.2 0.2 0.6 0.6)