From e12bf77a9fd8ebe81347532528c084d3a07c366a Mon Sep 17 00:00:00 2001
From: Gustaf Rydholm <gustaf.rydholm@gmail.com>
Date: Tue, 19 Jul 2022 23:38:55 +0200
Subject: Add util fun for loading most plugin opts

---
 fnl/config/aerial.fnl        |   3 +-
 fnl/config/autopairs.fnl     |  36 ++++++-------
 fnl/config/better-escape.fnl |  13 ++---
 fnl/config/bqf.fnl           |   3 +-
 fnl/config/colorizer.fnl     |   3 +-
 fnl/config/comment.fnl       |   7 +--
 fnl/config/fidget.fnl        |   5 +-
 fnl/config/gitsigns.fnl      |  49 +++++++++---------
 fnl/config/hop.fnl           |   6 ++-
 fnl/config/lualine.fnl       |  61 +++++++++++-----------
 fnl/config/minibar.fnl       |  47 +++++++++--------
 fnl/config/neogit.fnl        |   3 +-
 fnl/config/project.fnl       |  27 ++++------
 fnl/config/spectre.fnl       | 121 +++++++++++++++++++++----------------------
 fnl/config/spellsitter.fnl   |   5 +-
 fnl/config/treesitter.fnl    |  56 ++++++++++----------
 fnl/config/trim.fnl          |   5 +-
 fnl/config/which-key.fnl     |   6 ++-
 fnl/config/window-picker.fnl |   9 ++--
 fnl/config/zen.fnl           |  21 ++++----
 fnl/util.fnl                 |   4 ++
 21 files changed, 247 insertions(+), 243 deletions(-)

diff --git a/fnl/config/aerial.fnl b/fnl/config/aerial.fnl
index 0ed3f83..e91ca3c 100644
--- a/fnl/config/aerial.fnl
+++ b/fnl/config/aerial.fnl
@@ -1,5 +1,4 @@
 ;; Skimming code.
 (module config.aerial {autoload {: util}})
 
-(let [aerial (util.load-plugin :aerial)]
-  (aerial.setup {}))
+(util.use-config :aerial {})
diff --git a/fnl/config/autopairs.fnl b/fnl/config/autopairs.fnl
index 6d7d466..f0aa2b6 100644
--- a/fnl/config/autopairs.fnl
+++ b/fnl/config/autopairs.fnl
@@ -1,21 +1,21 @@
 ;; Autopairs for brackets and quote symbols.
 (module config.autopairs {autoload {: util}})
 
-(let [npairs (util.load-plugin :nvim-autopairs)]
-  (npairs.setup {:check_ts true
-                 :ts_config {:lua [:string :source]
-                             :javascript [:string :template_string]
-                             :java false}
-                 :disable_filetype [:TelescopePrompt :spectre_panel]
-                 :fast_warp {:map :<M-e>
-                             :chars ["{" "[" "(" "\"" "'"]
-                             :pattern (string.gsub "[%'%\"%)%>%]%)%}%,]" "%s+"
-                                                   "")
-                             :check_comma true
-                             :highlight :PmenuSel
-                             :highlight_grey :LineNr
-                             :offset 0
-                             :end_key "$"
-                             :keys :qwertyuiopzxcvbnmasdfghjkl
-                             :highlight :PmenuSel
-                             :highlight_grey :LineNr}}))
+(def- opts {:check_ts true
+            :ts_config {:lua [:string :source]
+                        :javascript [:string :template_string]
+                        :java false}
+            :disable_filetype [:TelescopePrompt :spectre_panel]
+            :fast_warp {:map :<M-e>
+                        :chars ["{" "[" "(" "\"" "'"]
+                        :pattern (string.gsub "[%'%\"%)%>%]%)%}%,]" "%s+" "")
+                        :check_comma true
+                        :highlight :PmenuSel
+                        :highlight_grey :LineNr
+                        :offset 0
+                        :end_key "$"
+                        :keys :qwertyuiopzxcvbnmasdfghjkl
+                        :highlight :PmenuSel
+                        :highlight_grey :LineNr}})
+
+(util.use-config :nvim-autopairs opts)
diff --git a/fnl/config/better-escape.fnl b/fnl/config/better-escape.fnl
index ffe3a6e..769fb32 100644
--- a/fnl/config/better-escape.fnl
+++ b/fnl/config/better-escape.fnl
@@ -1,8 +1,9 @@
-;; Better escape without nasty delay
+;; Better escape without nasty delay.
 (module config.better-escape {autoload {: util}})
 
-(let [better-escape (util.load-plugin :better_escape)]
-  (better-escape.setup {:mapping [:jk :jj]
-                        :timeout vim.o.timeoutlen
-                        :clear_empty_lines false
-                        :keys :<Esc>}))
+(def- opts {:mapping [:kk :jj]
+            :timeout vim.o.timeoutlen
+            :clear_empty_lines false
+            :keys :<Esc>})
+
+(util.use-config :better_escape opts)
diff --git a/fnl/config/bqf.fnl b/fnl/config/bqf.fnl
index 9a4de06..e5d7ab2 100644
--- a/fnl/config/bqf.fnl
+++ b/fnl/config/bqf.fnl
@@ -1,5 +1,4 @@
 ;; Make Neovim's quickfix window better.
 (module config.bqf {autoload {: util}})
 
-(let [bqf (util.load-plugin :bqf)]
-  (bqf.setup {}))
+(util.use-config :bqf {})
diff --git a/fnl/config/colorizer.fnl b/fnl/config/colorizer.fnl
index 748fffa..0757500 100644
--- a/fnl/config/colorizer.fnl
+++ b/fnl/config/colorizer.fnl
@@ -1,5 +1,4 @@
 ;; Enables colorization of color codes in source files.
 (module config.colorizer {autoload {: util}})
 
-(let [colorizer (util.load-plugin :colorizer)]
-  (colorizer.setup))
+(util.use-config :colorizer {})
diff --git a/fnl/config/comment.fnl b/fnl/config/comment.fnl
index f6e4972..d4256fe 100644
--- a/fnl/config/comment.fnl
+++ b/fnl/config/comment.fnl
@@ -17,6 +17,7 @@
          (internal.calculate_commentstring {:key (get-type ctx U)
                                             :location (get-location ctx U)})))
 
-(let [nvim-comment (util.load-plugin :Comment)]
-  (nvim-comment.setup {:pre_hook (fn [ctx]
-                                   (pre-hook ctx))}))
+(def- opts {:pre_hook (fn [ctx]
+                        (pre-hook ctx))})
+
+(util.use-config :Comment opts)
diff --git a/fnl/config/fidget.fnl b/fnl/config/fidget.fnl
index 734d1c9..fa87fd1 100644
--- a/fnl/config/fidget.fnl
+++ b/fnl/config/fidget.fnl
@@ -1,5 +1,6 @@
 ;; Show lsp progress.
 (module config.fidget {autoload {: util}})
 
-(let [fidget (util.load-plugin :fidget)]
-  (fidget.setup {:text {:spinner :dots_snake}}))
+(def- opts {:text {:spinner :dots_snake}})
+
+(util.use-config :fidget opts)
diff --git a/fnl/config/gitsigns.fnl b/fnl/config/gitsigns.fnl
index ecd3311..a693f7d 100644
--- a/fnl/config/gitsigns.fnl
+++ b/fnl/config/gitsigns.fnl
@@ -22,27 +22,28 @@
                             :numhl :GitSignsChangeNr
                             :linehl :GitSignsChangeLn}})
 
-(let [gitsigns (util.load-plugin :gitsigns)]
-  (gitsigns.setup {: signs
-                   :signcolumn true
-                   :numhl false
-                   :linehl false
-                   :word_diff false
-                   :watch_gitdir {:interval 1000 :follow_files true}
-                   :attach_to_untracked true
-                   :current_line_blame false
-                   :current_line_blame_opts {:virt_text true
-                                             :virt_text_pos :eol
-                                             :delay 1000
-                                             :ignore_whitespace false}
-                   :current_line_blame_formatter_opts {:relative_time false}
-                   :sign_priority 6
-                   :update_debounce 100
-                   :status_formatter nil
-                   :max_file_length 40000
-                   :preview_config {:border :single
-                                    :style :minimal
-                                    :relative :cursor
-                                    :row 0
-                                    :col 1}
-                   :yadm {:enable false}}))
+(def- opts {: signs
+            :signcolumn true
+            :numhl false
+            :linehl false
+            :word_diff false
+            :watch_gitdir {:interval 1000 :follow_files true}
+            :attach_to_untracked true
+            :current_line_blame false
+            :current_line_blame_opts {:virt_text true
+                                      :virt_text_pos :eol
+                                      :delay 1000
+                                      :ignore_whitespace false}
+            :current_line_blame_formatter_opts {:relative_time false}
+            :sign_priority 6
+            :update_debounce 100
+            :status_formatter nil
+            :max_file_length 40000
+            :preview_config {:border :single
+                             :style :minimal
+                             :relative :cursor
+                             :row 0
+                             :col 1}
+            :yadm {:enable false}})
+
+(util.use-config :gitsigns opts)
diff --git a/fnl/config/hop.fnl b/fnl/config/hop.fnl
index 678b5e2..a2aff1e 100644
--- a/fnl/config/hop.fnl
+++ b/fnl/config/hop.fnl
@@ -1,8 +1,7 @@
 ;; Hopping in text.
 (module config.hop {autoload {: util nvim aniseed.nvim}})
 
-(let [hop (util.load-plugin :hop)]
-  (hop.setup {}))
+(util.use-config :hop {})
 
 (def- opts {:noremap true :silent true})
 
@@ -11,12 +10,15 @@
 (nvim.set_keymap :o :f
                  ":lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<CR>"
                  opts)
+
 (nvim.set_keymap :o :F
                  ":lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<CR>"
                  opts)
+
 (nvim.set_keymap :o :t
                  ":lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, hint_offset = -1 })<CR>"
                  opts)
+
 (nvim.set_keymap :o :T
                  ":lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 })<CR>"
                  opts)
diff --git a/fnl/config/lualine.fnl b/fnl/config/lualine.fnl
index 746fc58..2a7bc66 100644
--- a/fnl/config/lualine.fnl
+++ b/fnl/config/lualine.fnl
@@ -15,13 +15,13 @@
               ""])
 
 (defn- active-clients [] (let [clients (vim.lsp.buf_get_clients)
-                              client_names []]
-                          (each [_ client (pairs clients)]
-                            (if (not= client.name :null-ls)
-                                (table.insert client_names client.name)))
-                          (if (> (length client_names) 0)
-                              (table.concat client_names ", ")
-                              "")))
+                               client_names []]
+                           (each [_ client (pairs clients)]
+                             (if (not= client.name :null-ls)
+                                 (table.insert client_names client.name)))
+                           (if (> (length client_names) 0)
+                               (table.concat client_names ", ")
+                               "")))
 
 (defn- hide-in-width [] (> (vim.fn.winwidth 0) 80))
 
@@ -34,9 +34,7 @@
                    :update_in_insert false
                    :always_visible true})
 
-(def- diff {1 :diff
-            :colored false
-            :cond hide-in-width})
+(def- diff {1 :diff :colored false :cond hide-in-width})
 
 (def- branch {1 "b:gitsigns_head" :icon " " :cond hide-in-width})
 
@@ -44,25 +42,24 @@
 
 (def- language-server {1 active-clients :cond hide_in_width})
 
-(let [lualine (util.load-plugin :lualine)]
-  (lualine.setup {:options {:icons_enabled true
-                            :theme :auto
-                            :component_separators {:left "" :right ""}
-                            :section_separators {:left "" :right ""}
-                            :disabled_filetypes ignore
-                            :always_divide_middle true}
-                  :sections {:lualine_a [:mode]
-                             :lualine_b [branch diff]
-                             :lualine_c {}
-                             :lualine_x [language-server diagnostics]
-                             :lualine_y [filetype]
-                             :lualine_z [:location :progress]}
-                  :inactive_sections {:lualine_a [:mode]
-                                      :lualine_b {}
-                                      :lualine_c {}
-                                      :lualine_x {}
-                                      :lualine_y {}
-                                      :lualine_z [:location
-                                                  :progress
-                                                  :encoding]}
-                  :extensions {}}))
+(def- opts {:options {:icons_enabled true
+                      :theme :auto
+                      :component_separators {:left "" :right ""}
+                      :section_separators {:left "" :right ""}
+                      :disabled_filetypes ignore
+                      :always_divide_middle true}
+            :sections {:lualine_a [:mode]
+                       :lualine_b [branch diff]
+                       :lualine_c {}
+                       :lualine_x [language-server diagnostics]
+                       :lualine_y [filetype]
+                       :lualine_z [:location :progress]}
+            :inactive_sections {:lualine_a [:mode]
+                                :lualine_b {}
+                                :lualine_c {}
+                                :lualine_x {}
+                                :lualine_y {}
+                                :lualine_z [:location :progress :encoding]}
+            :extensions {}})
+
+(util.use-config :lualine opts)
diff --git a/fnl/config/minibar.fnl b/fnl/config/minibar.fnl
index 6d3cce7..7a6945a 100644
--- a/fnl/config/minibar.fnl
+++ b/fnl/config/minibar.fnl
@@ -1,25 +1,26 @@
 (module config.minibar {autoload {: util}})
 
-(let [minibar (util.load-plugin :minibar)]
-  (minibar.setup {:ignore-filetypes [:help
-                                     :startify
-                                     :dashboard
-                                     :packer
-                                     :neogitstatus
-                                     :NvimTree
-                                     :Trouble
-                                     :alpha
-                                     :lir
-                                     :Outline
-                                     :NeogitStatus
-                                     :NeogitCommitMessage
-                                     :NeogitNotification
-                                     :NeogitCommitView
-                                     :spectre_panel]
-                  :events [:CursorMoved
-                           :CursorHold
-                           :BufWinEnter
-                           :BufFilePost
-                           :InsertEnter
-                           :BufWritePost
-                           :TabClosed]}))
+(def- opts {:ignore-filetypes [:help
+                               :startify
+                               :dashboard
+                               :packer
+                               :neogitstatus
+                               :NvimTree
+                               :Trouble
+                               :alpha
+                               :lir
+                               :Outline
+                               :NeogitStatus
+                               :NeogitCommitMessage
+                               :NeogitNotification
+                               :NeogitCommitView
+                               :spectre_panel]
+            :events [:CursorMoved
+                     :CursorHold
+                     :BufWinEnter
+                     :BufFilePost
+                     :InsertEnter
+                     :BufWritePost
+                     :TabClosed]})
+
+(util.use-config :minibar opts)
diff --git a/fnl/config/neogit.fnl b/fnl/config/neogit.fnl
index 353e8fc..da723c7 100644
--- a/fnl/config/neogit.fnl
+++ b/fnl/config/neogit.fnl
@@ -1,5 +1,4 @@
 ;; UI for git.
 (module config.neogit {autoload {: util}})
 
-(let [neogit (util.load-plugin :trim)]
-  (neogit.setup {}))
+(util.use-config :neogit {})
diff --git a/fnl/config/project.fnl b/fnl/config/project.fnl
index 27f689c..6ef7942 100644
--- a/fnl/config/project.fnl
+++ b/fnl/config/project.fnl
@@ -1,19 +1,14 @@
 ;; Provides project management.
 (module config.project {autoload {: util}})
 
-(let [project (util.load-plugin :project_nvim)]
-  (project.setup {:active true
-                  :on_config_done nil
-                  :manual_mode false
-                  :detection_methods [:patterns]
-                  :patterns [:git
-                             :_darcs
-                             :.hg
-                             :.bzr
-                             :.svn
-                             :Makefile
-                             :package.json]
-                  :show_hidden false
-                  :silent_chdir true
-                  :ignore_lsp {}
-                  :datapath (vim.fn.stdpath :data)}))
+(def- opts {:active true
+            :on_config_done nil
+            :manual_mode false
+            :detection_methods [:patterns]
+            :patterns [:git :_darcs :.hg :.bzr :.svn :Makefile :package.json]
+            :show_hidden false
+            :silent_chdir true
+            :ignore_lsp {}
+            :datapath (vim.fn.stdpath :data)})
+
+(util.use-config :project_nvim opts)
diff --git a/fnl/config/spectre.fnl b/fnl/config/spectre.fnl
index c181367..13bbcc5 100644
--- a/fnl/config/spectre.fnl
+++ b/fnl/config/spectre.fnl
@@ -1,64 +1,63 @@
 ;; Find and replace.
 (module config.spectre {autoload {: util}})
 
-(let [spectre (util.load-plugin :spectre)]
-  (spectre.setup {:color_devicons true
-                  :highlight {:ui :String
-                              :search :DiffChange
-                              :replace :DiffDelete}
-                  :mapping {:toggle_line {:map :t
-                                          :cmd "<cmd>lua require('spectre').toggle_line()<CR>"
-                                          :desc "toggle current item"}
-                            :enter_file {:map :<cr>
-                                         :cmd "<cmd>lua require('spectre.actions').select_entry()<CR>"
-                                         :desc "goto current file"}
-                            :send_to_qf {:map :Q
-                                         :cmd "<cmd>lua require('spectre.actions').send_to_qf()<CR>"
-                                         :desc "send all item to quickfix"}
-                            :replace_cmd {:map :c
-                                          :cmd "<cmd>lua require('spectre.actions').replace_cmd()<CR>"
-                                          :desc "input replace vim command"}
-                            :show_option_menu {:map :o
-                                               :cmd "<cmd>lua require('spectre').show_options()<CR>"
-                                               :desc "show option"}
-                            :run_replace {:map :R
-                                          :cmd "<cmd>lua require('spectre.actions').run_replace()<CR>"
-                                          :desc "replace all"}
-                            :change_view_mode {:map :m
-                                               :cmd "<cmd>lua require('spectre').change_view()<CR>"
-                                               :desc "change result view mode"}
-                            :toggle_ignore_case {:map :I
-                                                 :cmd "<cmd>lua require('spectre').change_options('ignore-case')<CR>"
-                                                 :desc "toggle ignore case"}
-                            :toggle_ignore_hidden {:map :H
-                                                   :cmd "<cmd>lua require('spectre').change_options('hidden')<CR>"
-                                                   :desc "toggle search hidden"}}
-                  :find_engine {:rg {:cmd :rg
-                                     :args [:--color=never
-                                            :--no-heading
-                                            :--with-filename
-                                            :--line-number
-                                            :--column]
-                                     :options {:ignore-case {:value :--ignore-case
-                                                             :icon "[I]"
-                                                             :desc "ignore case"}
-                                               :hidden {:value :--hidden
-                                                        :desc "hidden file"
-                                                        :icon "[H]"}}}
-                                :ag {:cmd :ag
-                                     :args [:--vimgrep :-s]
-                                     :options {:ignore-case {:value :-i
-                                                             :icon "[I]"
-                                                             :desc "ignore case"}
-                                               :hidden {:value :--hidden
-                                                        :desc "hidden file"
-                                                        :icon "[H]"}}}}
-                  :replace_engine {:sed {:cmd :sed :args nil}
-                                   :options {:ignore-case {:value :--ignore-case
-                                                           :icon "[I]"
-                                                           :desc "ignore case"}}}
-                  :default {:find {:cmd :rg :options [:ignore-case]}
-                            :replace {:cmd :sed}}
-                  :replace_vim_cmd :cdo
-                  :is_open_target_win true
-                  :is_insert_mode false}))
+(def- opts {:color_devicons true
+            :highlight {:ui :String :search :DiffChange :replace :DiffDelete}
+            :mapping {:toggle_line {:map :t
+                                    :cmd "<cmd>lua require('spectre').toggle_line()<CR>"
+                                    :desc "toggle current item"}
+                      :enter_file {:map :<cr>
+                                   :cmd "<cmd>lua require('spectre.actions').select_entry()<CR>"
+                                   :desc "goto current file"}
+                      :send_to_qf {:map :Q
+                                   :cmd "<cmd>lua require('spectre.actions').send_to_qf()<CR>"
+                                   :desc "send all item to quickfix"}
+                      :replace_cmd {:map :c
+                                    :cmd "<cmd>lua require('spectre.actions').replace_cmd()<CR>"
+                                    :desc "input replace vim command"}
+                      :show_option_menu {:map :o
+                                         :cmd "<cmd>lua require('spectre').show_options()<CR>"
+                                         :desc "show option"}
+                      :run_replace {:map :R
+                                    :cmd "<cmd>lua require('spectre.actions').run_replace()<CR>"
+                                    :desc "replace all"}
+                      :change_view_mode {:map :m
+                                         :cmd "<cmd>lua require('spectre').change_view()<CR>"
+                                         :desc "change result view mode"}
+                      :toggle_ignore_case {:map :I
+                                           :cmd "<cmd>lua require('spectre').change_options('ignore-case')<CR>"
+                                           :desc "toggle ignore case"}
+                      :toggle_ignore_hidden {:map :H
+                                             :cmd "<cmd>lua require('spectre').change_options('hidden')<CR>"
+                                             :desc "toggle search hidden"}}
+            :find_engine {:rg {:cmd :rg
+                               :args [:--color=never
+                                      :--no-heading
+                                      :--with-filename
+                                      :--line-number
+                                      :--column]
+                               :options {:ignore-case {:value :--ignore-case
+                                                       :icon "[I]"
+                                                       :desc "ignore case"}
+                                         :hidden {:value :--hidden
+                                                  :desc "hidden file"
+                                                  :icon "[H]"}}}
+                          :ag {:cmd :ag
+                               :args [:--vimgrep :-s]
+                               :options {:ignore-case {:value :-i
+                                                       :icon "[I]"
+                                                       :desc "ignore case"}
+                                         :hidden {:value :--hidden
+                                                  :desc "hidden file"
+                                                  :icon "[H]"}}}}
+            :replace_engine {:sed {:cmd :sed :args nil}
+                             :options {:ignore-case {:value :--ignore-case
+                                                     :icon "[I]"
+                                                     :desc "ignore case"}}}
+            :default {:find {:cmd :rg :options [:ignore-case]}
+                      :replace {:cmd :sed}}
+            :replace_vim_cmd :cdo
+            :is_open_target_win true
+            :is_insert_mode false})
+
+(util.use-config :spectre opts)
diff --git a/fnl/config/spellsitter.fnl b/fnl/config/spellsitter.fnl
index ee72d4b..dbd006c 100644
--- a/fnl/config/spellsitter.fnl
+++ b/fnl/config/spellsitter.fnl
@@ -1,5 +1,6 @@
 ;; Enable spell checking in comments.
 (module config.spellsitter {autoload {: util}})
 
-(let [spellsitter (util.load-plugin :spellsitter)]
-  (spellsitter.setup {:enable true :debug false}))
+(def- opts {:enable true :debug false})
+
+(util.use-config :spellsitter opts)
diff --git a/fnl/config/treesitter.fnl b/fnl/config/treesitter.fnl
index d71e9ce..a2ba356 100644
--- a/fnl/config/treesitter.fnl
+++ b/fnl/config/treesitter.fnl
@@ -2,31 +2,31 @@
 ;; In the neovim context it helps with better coloring.
 (module config.treesitter {autoload {: util}})
 
-(let [treesitter (util.load-plugin :nvim-treesitter.configs)]
-  (treesitter.setup {:ensure_installed [:c
-                                        :rust
-                                        :lua
-                                        :hcl
-                                        :org
-                                        :haskell
-                                        :python
-                                        :fennel
-                                        :make
-                                        :go
-                                        :ocaml
-                                        :erlang
-                                        :vim
-                                        :yaml
-                                        :html
-                                        :toml
-                                        :dockerfile
-                                        :markdown
-                                        :latex]
-                     :sync_install false
-                     :ignore_install [""]
-                     :autopairs {:enable true}
-                     :highlight {:enable true :disable [:org]}
-                     :context_commentstring {:enable true
-                                             :enable_autocmd false}
-                     :indent {:enable true :disable [:yaml :python :css]}
-                     :playground {:enable true}}))
+(def- opts {:ensure_installed [:c
+                               :rust
+                               :lua
+                               :hcl
+                               :org
+                               :haskell
+                               :python
+                               :fennel
+                               :make
+                               :go
+                               :ocaml
+                               :erlang
+                               :vim
+                               :yaml
+                               :html
+                               :toml
+                               :dockerfile
+                               :markdown
+                               :latex]
+            :sync_install false
+            :ignore_install [""]
+            :autopairs {:enable true}
+            :highlight {:enable true :disable [:org]}
+            :context_commentstring {:enable true :enable_autocmd false}
+            :indent {:enable true :disable [:yaml :python :css]}
+            :playground {:enable true}})
+
+(util.use-config :nvim-treesitter.configs opts)
diff --git a/fnl/config/trim.fnl b/fnl/config/trim.fnl
index 929ca1d..a2faf48 100644
--- a/fnl/config/trim.fnl
+++ b/fnl/config/trim.fnl
@@ -1,5 +1,6 @@
 ;; Trim whitespaces on save.
 (module config.trim {autoload {: util}})
 
-(let [trim (util.load-plugin :trim)]
-  (trim.setup {:disable [:python]}))
+(def- opts {:disable [:python]})
+
+(util.use-config :trim opts)
diff --git a/fnl/config/which-key.fnl b/fnl/config/which-key.fnl
index 1f9f0fe..e60744b 100644
--- a/fnl/config/which-key.fnl
+++ b/fnl/config/which-key.fnl
@@ -47,8 +47,10 @@
        :n [:<cmd>nohlsearch<CR> "No Highlight"]
        :P ["<cmd>Telescope projects<cr>" :Projects]
        :z [:<cmd>ZenMode<cr> "Zen Mode"]
-       :b ["<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{sort_lastused = true, initial_mode = 'normal', previewer = false})<cr>" "Switch buffers"]
-       :f ["<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})<cr>" "Find files"]
+       :b ["<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{sort_lastused = true, initial_mode = 'normal', previewer = false})<cr>"
+           "Switch buffers"]
+       :f ["<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})<cr>"
+           "Find files"]
        :t ["<cmd>Telescope live_grep theme=ivy<cr>" "Find text"]
        :p {:name :Packer
            :c [:<cmd>PackerCompile<cr> :Compile]
diff --git a/fnl/config/window-picker.fnl b/fnl/config/window-picker.fnl
index 1f9aaeb..3775ffe 100644
--- a/fnl/config/window-picker.fnl
+++ b/fnl/config/window-picker.fnl
@@ -1,7 +1,8 @@
 ;; Trim whitespaces on save.
 (module config.window-picker {autoload {: util}})
 
-(let [window-picker (util.load-plugin :window-picker)]
-  (window-picker.setup {:other_win_hl_color "#171717"
-                        :fg_color "#E1E1E1"
-                        :selection_chars :MNEIOARSTG}))
+(def- opts {:other_win_hl_color "#171717"
+            :fg_color "#E1E1E1"
+            :selection_chars :MNEIOARSTG})
+
+(util.use-config :window-picker opts)
diff --git a/fnl/config/zen.fnl b/fnl/config/zen.fnl
index b32ed9c..543afe7 100644
--- a/fnl/config/zen.fnl
+++ b/fnl/config/zen.fnl
@@ -1,13 +1,14 @@
 ;; Zen mode.
 (module config.zen {autoload {: util}})
 
-(let [zen-mode (util.load-plugin :zen-mode)]
-  (zen-mode.setup {:window {:backdrop 1
-                            :height 0.8
-                            :width 0.5
-                            :options {:signcolumn :no
-                                      :number false
-                                      :relativenumber false}}
-                   :plugins {:gitsigns {:enabled false}
-                             :tmux {:enabled true}
-                             :twilight {:enabled true}}}))
+(def- opts {:window {:backdrop 1
+                     :height 0.8
+                     :width 0.5
+                     :options {:signcolumn :no
+                               :number false
+                               :relativenumber false}}
+            :plugins {:gitsigns {:enabled false}
+                      :tmux {:enabled true}
+                      :twilight {:enabled true}}})
+
+(util.use-config :zen-mode opts)
diff --git a/fnl/util.fnl b/fnl/util.fnl
index 0e90396..dd82b23 100644
--- a/fnl/util.fnl
+++ b/fnl/util.fnl
@@ -28,3 +28,7 @@
             val-or-err
             (vim.notify (.. "Could not load config: " val-or-err)
                         vim.log.levels.WARN))))
+
+(defn use-config [plugin config]
+      (let [plugin (load-plugin plugin)]
+        (plugin.setup config)))
-- 
cgit v1.2.3-70-g09d2