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,7 +67,8 @@
; gitsigns.nvim ------------------------------------------------------- foldstart ; gitsigns.nvim ------------------------------------------------------- foldstart
; https://github.com/lewis6991/gitsigns.nvim ; https://github.com/lewis6991/gitsigns.nvim
(gitsigns.setup (pkg :gitsigns.nvim [gitsigns (require "gitsigns")]
(gitsigns.setup
{:signs {:add {:text "▍"} {:signs {:add {:text "▍"}
:change {:text "▍"} :change {:text "▍"}
:delete {:text "▍"} :delete {:text "▍"}
@ -76,15 +79,14 @@
:current_line_blame true :current_line_blame true
:update_debounce 100}) :update_debounce 100})
(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,8 +71,9 @@
; >>>>> ; >>>>>
; compe -------------------------------------------------------------------------------- <<<<< ; compe -------------------------------------------------------------------------------- <<<<<
(compe.setup (pkg :nvim-compe [compe (require "compe")]
{ :enabled true (compe.setup
{:enabled true
:autocomplete false :autocomplete false
:debug false :debug false
:min_length 1 :min_length 1
@ -87,26 +85,26 @@
:max_kind_width 100 :max_kind_width 100
:max_menu_width 100 :max_menu_width 100
:documentation true :documentation true
:source { :path true :source {:path true
:buffer true :buffer true
:calc true :calc true
: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
:sign true :sign true
:virtual_text false} :virtual_text false}
:code_action_keys { :quit "<esc>" :exec "<CR>"} :code_action_keys {:quit "<esc>" :exec "<CR>"}
:rename_action_keys { :quit "<esc>" :exec "<CR>"} :rename_action_keys {:quit "<esc>" :exec "<CR>"}
:finder_action_keys { :quit "<esc>" :finder_action_keys {:quit "<esc>"
:open "<CR>" :open "<CR>"
:vsplit "v" :vsplit "v"
:split "b" :split "b"
@ -114,54 +112,57 @@
: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"
"LspSagaSignatureHelpBorder" "LspSagaSignatureHelpBorder"
"LspSagaCodeActionBorder" "LspSagaCodeActionBorder"
"LspSagaDefPreviewBorder" "LspSagaDefPreviewBorder"
"LspSagaDiagnosticBorder"] "LspSagaDiagnosticBorder"]
{ :bg colors.dark0_hard :fg colors.dark0_hard}) {:bg colors.dark0_hard :fg colors.dark0_hard})
(utils.highlight [ "LspSagaDiagnosticTruncateLine" (utils.highlight ["LspSagaDiagnosticTruncateLine"
"LspSagaDocTruncateLine" "LspSagaDocTruncateLine"
"LspSagaShTruncateLine"] "LspSagaShTruncateLine"]
{ :bg "NONE" :fg colors.dark0}) {:bg "NONE" :fg colors.dark0})
(utils.highlight [ "TargetWord" (utils.highlight ["TargetWord"
"LspSagaCodeActionTitle" "LspSagaCodeActionTitle"
"LspSagaBorderTitle" "LspSagaBorderTitle"
"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 -------------------------------------------------------------------------------- <<<<<
(trouble.setup (pkg :lsp-trouble.nvim [trouble (require "trouble")]
{ :icons false (trouble.setup
{:icons false
:auto_preview true :auto_preview true
:auto_close true :auto_close true
:auto_open false :auto_open false
:action_keys :action_keys
{ :jump "o" {:jump "o"
:jump_close "<CR>" :jump_close "<CR>"
:close "<esc>" :close "<esc>"
:cancel "q" :cancel "q"
:hover ["a" "K"]}}) :hover ["a" "K"]}})
(utils.highlight "LspTroubleFoldIcon" {:bg "NONE" :fg colors.bright_orange})
(utils.highlight "LspTroubleCount" {:bg "NONE" :fg colors.bright_green})
(utils.highlight "LspTroubleText" {:bg "NONE" :fg colors.light0})
(utils.highlight "LspTroubleFoldIcon" {:bg "NONE" :fg colors.bright_orange}) (utils.highlight "LspTroubleSignError" {:bg "NONE" :fg colors.bright_red})
(utils.highlight "LspTroubleCount" {:bg "NONE" :fg colors.bright_green}) (utils.highlight "LspTroubleSignWarning" {:bg "NONE" :fg colors.bright_yellow})
(utils.highlight "LspTroubleText" {:bg "NONE" :fg colors.light0}) (utils.highlight "LspTroubleSignInformation" {:bg "NONE" :fg colors.bright_aqua})
(utils.highlight "LspTroubleSignHint" {:bg "NONE" :fg colors.bright_blue}))
(utils.highlight "LspTroubleSignError" {:bg "NONE" :fg colors.bright_red})
(utils.highlight "LspTroubleSignWarning" {:bg "NONE" :fg colors.bright_yellow})
(utils.highlight "LspTroubleSignInformation" {:bg "NONE" :fg colors.bright_aqua})
(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)