From f06c064719cfe266783b0b16fb85c21fcb9ae89b Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Wed, 5 May 2021 19:23:32 +0200 Subject: [PATCH] Add pkg macro to only load config when plugin is loaded --- files/.config/nvim/fnl/init.fnl | 96 +++++++++++--------- files/.config/nvim/fnl/keybinds.fnl | 1 - files/.config/nvim/fnl/macros.fnl | 10 ++- files/.config/nvim/fnl/plugins/lsp.fnl | 116 +++++++++++++------------ files/.config/nvim/fnl/utils.fnl | 5 ++ files/.xmonad/lib/Config.hs | 1 + 6 files changed, 127 insertions(+), 102 deletions(-) diff --git a/files/.config/nvim/fnl/init.fnl b/files/.config/nvim/fnl/init.fnl index 7cf60c1..09bd5da 100644 --- a/files/.config/nvim/fnl/init.fnl +++ b/files/.config/nvim/fnl/init.fnl @@ -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,26 +37,28 @@ ; Treesitter ------------------------------------------------------- foldstart -(nvim-treesitter-configs.setup - {:ensure_installed "all" - :highlight {:enable true - :disable ["fennel"]} - ;:indent {:enable true} - ;:disable ["lua"]} - :incremental_selection - {:enable true - :keymaps {:init_selection "gss" - :node_incremental "gsl" - :node_decremental "gsh" - :scope_incremental "gsj" - :scope_decremental "gsk"}} +(pkg :nvim-treesitter [configs (require "nvim-treesitter.configs")] + (configs.setup + {:ensure_installed "all" + :highlight {:enable true + :disable ["fennel"]} + ;:indent {:enable true} + ;:disable ["lua"]} - ; disabled due to it fucking with gitsigns.nvim - ;:rainbow { :enable true - ;:extended_mode true} + :incremental_selection + {:enable true + :keymaps {:init_selection "gss" + :node_incremental "gsl" + :node_decremental "gsh" + :scope_incremental "gsj" + :scope_decremental "gsk"}} - :context_commentstring {:enable true}}) + ; disabled due to it fucking with gitsigns.nvim + ;:rainbow { :enable true + ;:extended_mode true} + + :context_commentstring {:enable true}})) ;(nvim-biscuits.setup {} ;{ :on_events ["InsertLeave" "CursorHoldI"]}) @@ -65,27 +67,27 @@ ; gitsigns.nvim ------------------------------------------------------- foldstart ; https://github.com/lewis6991/gitsigns.nvim -(gitsigns.setup - {:signs {:add {:text "▍"} - :change {:text "▍"} - :delete {:text "▍"} - :topdelete {:text "▍"} - :changedelete {:text "▍"}} - :keymaps {:noremap true - :buffer true} - :current_line_blame true - :update_debounce 100}) +(pkg :gitsigns.nvim [gitsigns (require "gitsigns")] + (gitsigns.setup + {:signs {:add {:text "▍"} + :change {:text "▍"} + :delete {:text "▍"} + :topdelete {:text "▍"} + :changedelete {:text "▍"}} + :keymaps {:noremap true + :buffer true} + :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") - cb (. (require "diffview.config") :diffview_callback)] +(pkg :diffview.nvim [diffview (require "diffview") + cb (. (require "diffview.config") :diffview_callback)] (diffview.setup {:diff_binaries false :file_panel {:width 35 @@ -122,4 +124,12 @@ ; foldend + + + + + + + + ; vim:foldmarker=foldstart,foldend diff --git a/files/.config/nvim/fnl/keybinds.fnl b/files/.config/nvim/fnl/keybinds.fnl index e51c03e..640789b 100644 --- a/files/.config/nvim/fnl/keybinds.fnl +++ b/files/.config/nvim/fnl/keybinds.fnl @@ -16,7 +16,6 @@ (fn cmd [s desc] [(.. "" s "") desc]) -(fn le [s desc] (cmd (.. "call luaeval(\"" s "\")") desc)) (fn rebind [s desc] [s desc]) (wk.setup {}) diff --git a/files/.config/nvim/fnl/macros.fnl b/files/.config/nvim/fnl/macros.fnl index dc4f680..080799a 100644 --- a/files/.config/nvim/fnl/macros.fnl +++ b/files/.config/nvim/fnl/macros.fnl @@ -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))))} + + diff --git a/files/.config/nvim/fnl/plugins/lsp.fnl b/files/.config/nvim/fnl/plugins/lsp.fnl index b2860e8..d7a6faa 100644 --- a/files/.config/nvim/fnl/plugins/lsp.fnl +++ b/files/.config/nvim/fnl/plugins/lsp.fnl @@ -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,81 +85,84 @@ :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 "" :exec ""} - :rename_action_keys { :quit "" :exec ""} - :finder_action_keys { :quit "" + :code_action_keys {:quit "" :exec ""} + :rename_action_keys {:quit "" :exec ""} + :finder_action_keys {:quit "" :open "" :vsplit "v" :split "b" :scroll_up "" :scroll_down ""}}) - + -(utils.highlight [ "LspFloatWinNormal" ] {:bg colors.dark0_hard}) -(utils.highlight [ "LspFloatWinBorder" - "LspSagaHoverBorder" - "LspSagaRenameBorder" - "LspSagaSignatureHelpBorder" - "LspSagaCodeActionBorder" - "LspSagaDefPreviewBorder" - "LspSagaDiagnosticBorder"] - { :bg colors.dark0_hard :fg colors.dark0_hard}) + (utils.highlight ["LspFloatWinBorder" + "LspSagaHoverBorder" + "LspSagaRenameBorder" + "LspSagaSignatureHelpBorder" + "LspSagaCodeActionBorder" + "LspSagaDefPreviewBorder" + "LspSagaDiagnosticBorder"] + {:bg colors.dark0_hard :fg colors.dark0_hard}) -(utils.highlight [ "LspSagaDiagnosticTruncateLine" - "LspSagaDocTruncateLine" - "LspSagaShTruncateLine"] - { :bg "NONE" :fg colors.dark0}) + (utils.highlight ["LspSagaDiagnosticTruncateLine" + "LspSagaDocTruncateLine" + "LspSagaShTruncateLine"] + {:bg "NONE" :fg colors.dark0}) -(utils.highlight [ "TargetWord" - "LspSagaCodeActionTitle" - "LspSagaBorderTitle" - "LspSagaCodeActionContent" - "LspSagaFinderSelection" - "LspSagaDiagnosticHeader"] - { :fg colors.bright_aqua}) + (utils.highlight ["TargetWord" + "LspSagaCodeActionTitle" + "LspSagaBorderTitle" + "LspSagaCodeActionContent" + "LspSagaFinderSelection" + "LspSagaDiagnosticHeader"] + {: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_close "" - :close "" - :cancel "q" - :hover ["a" "K"]}}) - + {:jump "o" + :jump_close "" + :close "" + :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") diff --git a/files/.config/nvim/fnl/utils.fnl b/files/.config/nvim/fnl/utils.fnl index c8f4e76..29d02cf 100644 --- a/files/.config/nvim/fnl/utils.fnl +++ b/files/.config/nvim/fnl/utils.fnl @@ -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)) diff --git a/files/.xmonad/lib/Config.hs b/files/.xmonad/lib/Config.hs index 39a7cd3..623b6d5 100644 --- a/files/.xmonad/lib/Config.hs +++ b/files/.xmonad/lib/Config.hs @@ -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)