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

View file

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

View file

@ -22,5 +22,13 @@
(fn [x ...]
`(do
(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
lsp lspconfig
lsp-configs lspconfig.configs
saga lspsaga
utils utils
compe compe
lsp_signature lsp_signature
symbols-outline symbols-outline
trouble trouble
rust-tools rust-tools}
utils utils}
require-macros [macros]})
(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 -------------------------------------------------------------------------------- <<<<<
(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
(do
(utils.highlight "LspReferenceRead" {:gui "underline"})
@ -74,8 +71,9 @@
; >>>>>
; compe -------------------------------------------------------------------------------- <<<<<
(compe.setup
{ :enabled true
(pkg :nvim-compe [compe (require "compe")]
(compe.setup
{:enabled true
:autocomplete false
:debug false
:min_length 1
@ -87,26 +85,26 @@
:max_kind_width 100
:max_menu_width 100
:documentation true
:source { :path true
:source {:path true
:buffer true
:calc true
:nvim_lsp true
:nvim_lua true
:vsnip false
:conjure true}})
:conjure true}}))
; >>>>>
; LSP saga -------------------------------------------------------------------------------- <<<<<
(saga.init_lsp_saga
{ :border_style "single" ; single double round plus
:code_action_prompt { :enable true
(pkg :lspsaga.nvim [saga (require "lspsaga")]
(saga.init_lsp_saga
{:border_style "single" ; single double round plus
:code_action_prompt {:enable true
:sign true
:virtual_text false}
:code_action_keys { :quit "<esc>" :exec "<CR>"}
:rename_action_keys { :quit "<esc>" :exec "<CR>"}
:finder_action_keys { :quit "<esc>"
:code_action_keys {:quit "<esc>" :exec "<CR>"}
:rename_action_keys {:quit "<esc>" :exec "<CR>"}
:finder_action_keys {:quit "<esc>"
:open "<CR>"
:vsplit "v"
:split "b"
@ -114,54 +112,57 @@
:scroll_down "<C-d>"}})
(utils.highlight [ "LspFloatWinNormal" ] {:bg colors.dark0_hard})
(utils.highlight [ "LspFloatWinBorder"
(utils.highlight ["LspFloatWinBorder"
"LspSagaHoverBorder"
"LspSagaRenameBorder"
"LspSagaSignatureHelpBorder"
"LspSagaCodeActionBorder"
"LspSagaDefPreviewBorder"
"LspSagaDiagnosticBorder"]
{ :bg colors.dark0_hard :fg colors.dark0_hard})
{:bg colors.dark0_hard :fg colors.dark0_hard})
(utils.highlight [ "LspSagaDiagnosticTruncateLine"
(utils.highlight ["LspSagaDiagnosticTruncateLine"
"LspSagaDocTruncateLine"
"LspSagaShTruncateLine"]
{ :bg "NONE" :fg colors.dark0})
{:bg "NONE" :fg colors.dark0})
(utils.highlight [ "TargetWord"
(utils.highlight ["TargetWord"
"LspSagaCodeActionTitle"
"LspSagaBorderTitle"
"LspSagaCodeActionContent"
"LspSagaFinderSelection"
"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 -------------------------------------------------------------------------------- <<<<<
(trouble.setup
{ :icons false
(pkg :lsp-trouble.nvim [trouble (require "trouble")]
(trouble.setup
{:icons false
:auto_preview true
:auto_close true
:auto_open false
:action_keys
{ :jump "o"
{:jump "o"
:jump_close "<CR>"
:close "<esc>"
:cancel "q"
: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 "LspTroubleCount" {:bg "NONE" :fg colors.bright_green})
(utils.highlight "LspTroubleText" {:bg "NONE" :fg colors.light0})
(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})
(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")

View file

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

View file

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