From 68719ee058a302a4bda697b6a39ebfd5fefb06fc Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 8 Jan 2023 14:24:05 +0100 Subject: Refactor loading of plugins --- fnl/config/aniseed.fnl | 2 + fnl/config/bufdel.fnl | 3 + fnl/config/cmd.fnl | 28 ++++---- fnl/config/colorizer.fnl | 3 + fnl/config/diffview.fnl | 5 ++ fnl/config/harpoon.fnl | 2 + fnl/config/init.fnl | 46 ++++++++++++ fnl/config/lir.fnl | 20 +++--- fnl/config/lsp/null-ls.fnl | 4 +- fnl/config/neogit.fnl | 6 ++ fnl/config/project.fnl | 24 ++++--- fnl/config/stay-in-place.fnl | 3 + fnl/config/surround.fnl | 3 + fnl/config/symbols-outline.fnl | 3 + fnl/config/telescope.fnl | 157 ++++++++++++++++++++--------------------- fnl/config/treesitter.fnl | 9 ++- fnl/config/undotree.fnl | 3 + fnl/config/util.fnl | 19 ++--- fnl/config/window-picker.fnl | 2 +- 19 files changed, 209 insertions(+), 133 deletions(-) create mode 100644 fnl/config/aniseed.fnl create mode 100644 fnl/config/bufdel.fnl create mode 100644 fnl/config/colorizer.fnl create mode 100644 fnl/config/diffview.fnl create mode 100644 fnl/config/init.fnl create mode 100644 fnl/config/neogit.fnl create mode 100644 fnl/config/stay-in-place.fnl create mode 100644 fnl/config/surround.fnl create mode 100644 fnl/config/symbols-outline.fnl create mode 100644 fnl/config/undotree.fnl (limited to 'fnl/config') diff --git a/fnl/config/aniseed.fnl b/fnl/config/aniseed.fnl new file mode 100644 index 0000000..c024792 --- /dev/null +++ b/fnl/config/aniseed.fnl @@ -0,0 +1,2 @@ +;; Transpiler for fennel to lua. +{1 :Olical/aniseed} diff --git a/fnl/config/bufdel.fnl b/fnl/config/bufdel.fnl new file mode 100644 index 0000000..4719a53 --- /dev/null +++ b/fnl/config/bufdel.fnl @@ -0,0 +1,3 @@ +;; Delete buffers. + +{1 :ojroques/nvim-bufdel :cmd :BufDel} diff --git a/fnl/config/cmd.fnl b/fnl/config/cmd.fnl index 735bbc4..1ae9b58 100644 --- a/fnl/config/cmd.fnl +++ b/fnl/config/cmd.fnl @@ -3,85 +3,85 @@ (nvim.create_user_command :OrgAgendaPrompt (lambda [] - (let [orgmode (util.prequire :orgmode)] + (let [orgmode (require :orgmode)] (orgmode.action :agenda.prompt))) {:nargs 0}) (nvim.create_user_command :OrgCapturePrompt (lambda [] - (let [orgmode (util.prequire :orgmode)] + (let [orgmode (require :orgmode)] (orgmode.action :capture.prompt))) {:nargs 0}) (nvim.create_user_command :CommentNormal (lambda [] - (let [comment-api (util.prequire :Comment.api)] + (let [comment-api (require :Comment.api)] (comment-api.toggle.linewise.current))) {:nargs 0}) (nvim.create_user_command :CommentVisual (lambda [] - (let [comment-api (util.prequire :Comment.api)] + (let [comment-api (require :Comment.api)] (comment-api.toggle.linewise (vim.fn.visualmode)))) {:nargs 0}) (nvim.create_user_command :HarpoonAdd (lambda [] - (let [harpoon (util.prequire :harpoon.mark)] + (let [harpoon (require :harpoon.mark)] (harpoon.add_file))) {:nargs 0}) (nvim.create_user_command :HarpoonNext (lambda [] - (let [harpoon (util.prequire :harpoon.ui)] + (let [harpoon (require :harpoon.ui)] (harpoon.nav_next))) {:nargs 0}) (nvim.create_user_command :HarpoonPrev (lambda [] - (let [harpoon (util.prequire :harpoon.ui)] + (let [harpoon (require :harpoon.ui)] (harpoon.nav_prev))) {:nargs 0}) (nvim.create_user_command :HarpoonUI (lambda [] - (let [harpoon (util.prequire :harpoon.ui)] + (let [harpoon (require :harpoon.ui)] (harpoon.toggle_quick_menu))) {:nargs 0}) (nvim.create_user_command :Replace (lambda [] - (let [spectre (util.prequire :spectre)] + (let [spectre (require :spectre)] (spectre.open))) {:nargs 0}) (nvim.create_user_command :ReplaceWord (lambda [] - (let [spectre (util.prequire :spectre)] + (let [spectre (require :spectre)] (spectre.open_visual {:select_word true}))) {:nargs 0}) (nvim.create_user_command :ReplaceInBuf (lambda [] - (let [spectre (util.prequire :spectre)] + (let [spectre (require :spectre)] (spectre.open_file_search))) {:nargs 0}) (nvim.create_user_command :RestoreSession (lambda [] - (let [persistence (util.prequire :persistence)] + (let [persistence (require :persistence)] (persistence.load))) {:nargs 0}) (nvim.create_user_command :RestoreLastSession (lambda [] - (let [persistence (util.prequire :persistence)] + (let [persistence (require :persistence)] (persistence.load {:last true}))) {:nargs 0}) (nvim.create_user_command :IgnoreSession (lambda [] - (let [persistence (util.prequire :persistence)] + (let [persistence (require :persistence)] (persistence.stop))) {:nargs 0}) diff --git a/fnl/config/colorizer.fnl b/fnl/config/colorizer.fnl new file mode 100644 index 0000000..553024b --- /dev/null +++ b/fnl/config/colorizer.fnl @@ -0,0 +1,3 @@ +;; Display colors of hex numbers. + +{1 :norcalli/nvim-colorizer.lua :cmd :ColorizerToggle :config true} diff --git a/fnl/config/diffview.fnl b/fnl/config/diffview.fnl new file mode 100644 index 0000000..9978c2e --- /dev/null +++ b/fnl/config/diffview.fnl @@ -0,0 +1,5 @@ +;; Inspect commits. + +{1 :sindrets/diffview.nvim + :cmd [:DiffviewFileHistory :DiffviewOpen] + :config true} diff --git a/fnl/config/harpoon.fnl b/fnl/config/harpoon.fnl index 9bdd81f..41b6b81 100644 --- a/fnl/config/harpoon.fnl +++ b/fnl/config/harpoon.fnl @@ -1,5 +1,7 @@ ;; Harpoon files for navigation. +(local util (require :config.util)) + (fn setup [] (vim.keymap.set :n : (fn [] diff --git a/fnl/config/init.fnl b/fnl/config/init.fnl new file mode 100644 index 0000000..b8bbddf --- /dev/null +++ b/fnl/config/init.fnl @@ -0,0 +1,46 @@ +;; Load all plugin configs. + +(local plugins [:config.alpha + :config.aniseed + :config.autopairs + :config.better-escape + :config.bqf + :config.bufdel + :config.cmp + :config.colorizer + :config.colorscheme + :config.comment + :config.diffview + :config.flit + :config.gitsigns + :config.harpoon + :config.leap + :config.lir + :config.lsp.lspconfig + :config.lsp.mason + :config.lsp.null-ls + :config.lualine + :config.minibar + :config.neogit + :config.orgmode + :config.persistence + :config.project + :config.spectre + :config.stay-in-place + :config.surround + :config.symbols-outline + :config.telescope + :config.toggleterm + :config.treesitter + :config.trim + :config.trouble + :config.undotree + :config.vim-slash + :config.which-key + :config.window-picker + :config.zen]) + +(let [configs []] + (each [_ plugin (pairs plugins)] + (table.insert configs (require plugin))) + configs) diff --git a/fnl/config/lir.fnl b/fnl/config/lir.fnl index 22b15cf..d74b248 100644 --- a/fnl/config/lir.fnl +++ b/fnl/config/lir.fnl @@ -30,18 +30,18 @@ {:border :rounded : width : height}))} :hide_cursor false :on_init (fn [] - (nvim.buf_set_keymap 0 :x :J - ":lua require(\"lir.mark.actions\").toggle_mark(\"v\")" - {:noremap true :silent true}))}) + (vim.api.nvim_buf_set_keymap 0 :x :J + ":lua require(\"lir.mark.actions\").toggle_mark(\"v\")" + {:noremap true :silent true}))}) (fn setup [] - (let [lir (require :lir)] - (let [actions (require :lir.actions) - mark-actions (require :lir.mark.actions) - clipboard-actions (require :lir.clipboard.actions)] - (lir.setup (opts actions mark-actions clipboard-actions)) - (nvim.set_keymap :n "-" ":lua require'lir.float'.toggle()" - {:noremap true :silent true})))) + (let [actions (require :lir.actions) + clipboard-actions (require :lir.clipboard.actions) + mark-actions (require :lir.mark.actions) + lir (require :lir)] + (lir.setup (opts actions mark-actions clipboard-actions)) + (vim.keymap.set :n "-" ":lua require'lir.float'.toggle()" + {:noremap true :silent true}))) {1 :tamago324/lir.nvim :keys "-" diff --git a/fnl/config/lsp/null-ls.fnl b/fnl/config/lsp/null-ls.fnl index 2d03b0d..13dd493 100644 --- a/fnl/config/lsp/null-ls.fnl +++ b/fnl/config/lsp/null-ls.fnl @@ -35,7 +35,9 @@ (mason-null-ls.setup mason-opts))) {1 :jose-elias-alvarez/null-ls.nvim - :dependencies [:mason.nvim :jayp0521/mason-null-ls.nvim] + :dependencies [:mason.nvim + :jayp0521/mason-null-ls.nvim + :nvim-lua/plenary.nvim] :event :BufReadPre :config (fn [] (setup))} diff --git a/fnl/config/neogit.fnl b/fnl/config/neogit.fnl new file mode 100644 index 0000000..b7c1633 --- /dev/null +++ b/fnl/config/neogit.fnl @@ -0,0 +1,6 @@ +;; Git ui. + +{1 :TimUntersberger/neogit + :cmd :Neogit + :dependencies [:nvim-lua/plenary.nvim] + :config true} diff --git a/fnl/config/project.fnl b/fnl/config/project.fnl index eceef84..57cfb9c 100644 --- a/fnl/config/project.fnl +++ b/fnl/config/project.fnl @@ -1,15 +1,17 @@ ;; Provides project management. (local 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)}) + :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)}) - {1 :ahmedkhalf/project.nvim - :event :BufReadPre - :config opts} +{1 :ahmedkhalf/project.nvim + :cmd :Telescope + :config (fn [] + (let [project (require :project_nvim)] + (project.setup opts)))} diff --git a/fnl/config/stay-in-place.fnl b/fnl/config/stay-in-place.fnl new file mode 100644 index 0000000..b264a05 --- /dev/null +++ b/fnl/config/stay-in-place.fnl @@ -0,0 +1,3 @@ +;; Keep cursor at character when indenting. + +{1 :gbprod/stay-in-place.nvim :event :BufReadPost :config true} diff --git a/fnl/config/surround.fnl b/fnl/config/surround.fnl new file mode 100644 index 0000000..e8fda32 --- /dev/null +++ b/fnl/config/surround.fnl @@ -0,0 +1,3 @@ +;; Surround selections. + +{1 :kylechui/nvim-surround :event :InsertEnter :config true} diff --git a/fnl/config/symbols-outline.fnl b/fnl/config/symbols-outline.fnl new file mode 100644 index 0000000..4195de0 --- /dev/null +++ b/fnl/config/symbols-outline.fnl @@ -0,0 +1,3 @@ +;; List tree of symbols. + +{1 :simrat39/symbols-outline.nvim :cmd :SymbolsOutline :config true} diff --git a/fnl/config/telescope.fnl b/fnl/config/telescope.fnl index ce4fb9c..7f782e1 100644 --- a/fnl/config/telescope.fnl +++ b/fnl/config/telescope.fnl @@ -1,90 +1,89 @@ ;; Telescope a highly extendable fuzzy finder over lists. -(local opts {:noremap true :silent true}) - (fn setup [] - (let [telescope (util.prequire :telescope)] - (let [actions (require :telescope.actions)] - (telescope.setup {:defaults {:prompt_prefix "  " - :selection_caret "> " - :path_display [:smart] - :color_devicons false - :vimgrep_arguments [:rg - :--color=never - :--no-heading - :--with-filename - :--line-number - :--column - :--smart-case - :--hidden] - :mappings {:i {: actions.cycle_history_next - : actions.cycle_history_prev - : actions.move_selection_next - : actions.move_selection_previous - : actions.close - : actions.move_selection_next - : actions.move_selection_previous - : actions.select_default - : actions.select_horizontal - : actions.select_vertical - : actions.select_tab - : actions.preview_scrolling_up - : actions.preview_scrolling_down - : actions.results_scrolling_up - : actions.results_scrolling_down - : (+ actions.toggle_selection - actions.move_selection_worse) - : (+ actions.toggle_selection - actions.move_selection_better) - : (+ actions.send_to_qflist - actions.open_qflist) - : (+ actions.send_selected_to_qflist - actions.open_qflist) - : actions.complete_tag - : actions.which_key} - :n {: actions.close - : actions.select_default - : actions.select_horizontal - : actions.select_vertical - : actions.select_tab - : (+ actions.toggle_selection - actions.move_selection_worse) - : (+ actions.toggle_selection - actions.move_selection_better) - : (+ actions.send_to_qflist - actions.open_qflist) - : (+ actions.send_selected_to_qflist - actions.open_qflist) - :j actions.move_selection_next - :k actions.move_selection_previous - :H actions.move_to_top - :M actions.move_to_middle - :L actions.move_to_bottom - : actions.move_selection_next - : actions.move_selection_previous - :gg actions.move_to_top - :G actions.move_to_bottom - :q actions.close - : actions.preview_scrolling_up - : actions.preview_scrolling_down - : actions.results_scrolling_up - : actions.results_scrolling_down - :dd actions.delete_buffer - :? actions.which_key}}} - :extensions {:fzf {:fuzzy true - :override_generic_sorter true - :override_file_sorter true - :case_mode :smart_case}}}) - (telescope.load_extension :fzf) - (telescope.load_extension :frecency) - (telescope.load_extension :orgmode) - (telescope.load_extension :projects) - (telescope.load_extension :harpoon)))) + (let [telescope (require :telescope) + actions (require :telescope.actions)] + (telescope.setup {:defaults {:prompt_prefix "  " + :selection_caret "> " + :path_display [:smart] + :color_devicons false + :vimgrep_arguments [:rg + :--color=never + :--no-heading + :--with-filename + :--line-number + :--column + :--smart-case + :--hidden] + :mappings {:i {: actions.cycle_history_next + : actions.cycle_history_prev + : actions.move_selection_next + : actions.move_selection_previous + : actions.close + : actions.move_selection_next + : actions.move_selection_previous + : actions.select_default + : actions.select_horizontal + : actions.select_vertical + : actions.select_tab + : actions.preview_scrolling_up + : actions.preview_scrolling_down + : actions.results_scrolling_up + : actions.results_scrolling_down + : (+ actions.toggle_selection + actions.move_selection_worse) + : (+ actions.toggle_selection + actions.move_selection_better) + : (+ actions.send_to_qflist + actions.open_qflist) + : (+ actions.send_selected_to_qflist + actions.open_qflist) + : actions.complete_tag + : actions.which_key} + :n {: actions.close + : actions.select_default + : actions.select_horizontal + : actions.select_vertical + : actions.select_tab + : (+ actions.toggle_selection + actions.move_selection_worse) + : (+ actions.toggle_selection + actions.move_selection_better) + : (+ actions.send_to_qflist + actions.open_qflist) + : (+ actions.send_selected_to_qflist + actions.open_qflist) + :j actions.move_selection_next + :k actions.move_selection_previous + :H actions.move_to_top + :M actions.move_to_middle + :L actions.move_to_bottom + : actions.move_selection_next + : actions.move_selection_previous + :gg actions.move_to_top + :G actions.move_to_bottom + :q actions.close + : actions.preview_scrolling_up + : actions.preview_scrolling_down + : actions.results_scrolling_up + : actions.results_scrolling_down + :dd actions.delete_buffer + :? actions.which_key}}} + :extensions {:fzf {:fuzzy true + :override_generic_sorter true + :override_file_sorter true + :case_mode :smart_case}}}) + (telescope.load_extension :fzf) + (telescope.load_extension :frecency) + (telescope.load_extension :orgmode) + (telescope.load_extension :projects) + (telescope.load_extension :harpoon))) {1 :nvim-telescope/telescope.nvim :cmd :Telescope :dependencies [:nvim-lua/popup.nvim :nvim-telescope/telescope-frecency.nvim + {1 :nvim-telescope/telescope-fzf-native.nvim :build :make} :tami5/sqlite.lua :ahmedkhalf/project.nvim :nvim-lua/plenary.nvim diff --git a/fnl/config/treesitter.fnl b/fnl/config/treesitter.fnl index a8918d2..1d96a13 100644 --- a/fnl/config/treesitter.fnl +++ b/fnl/config/treesitter.fnl @@ -28,7 +28,12 @@ :indent {:enable true :disable [:yaml :python :css]} :playground {:enable true}}) +(fn setup [] + (let [treesitter (require :nvim-treesitter.configs)] + (treesitter.setup opts))) + {1 :nvim-treesitter/nvim-treesitter :build ":TSUpdate" - :event :BufReadPre - :config opts} + :event :BufReadPost + :config (fn [] + (setup))} diff --git a/fnl/config/undotree.fnl b/fnl/config/undotree.fnl new file mode 100644 index 0000000..9aa8114 --- /dev/null +++ b/fnl/config/undotree.fnl @@ -0,0 +1,3 @@ +;; Tree of undo history. + +{1 :mbbill/undotree :cmd :UndotreeToggle} diff --git a/fnl/config/util.fnl b/fnl/config/util.fnl index 7665a57..dbd635f 100644 --- a/fnl/config/util.fnl +++ b/fnl/config/util.fnl @@ -1,25 +1,14 @@ ;; Utility functions. (module util {autoload {a aniseed.core nvim aniseed.nvim}}) -(defn prequire [name] - (let [(ok? plugin) (pcall require name)] - (if ok? - plugin - (vim.notify (.. "Could not load config: " plugin) - vim.log.levels.WARN)))) - -(defn setup [plugin config] - (let [plugin (prequire plugin)] - (plugin.setup config))) - (defn telescope-ext [ext fun opts] - (let [telescope (prequire :telescope) - themes (prequire :telescope.themes) + (let [telescope (require :telescope) + themes (require :telescope.themes) theme (. opts :theme)] ((. (. (. telescope :extensions) ext) fun) ((. themes theme) opts)))) (defn telescope-builtin [builtin opts] - (let [telescope (prequire :telescope.builtin) - themes (prequire :telescope.themes) + (let [telescope (require :telescope.builtin) + themes (require :telescope.themes) theme (. opts :theme)] ((. telescope builtin) ((. themes theme) opts)))) diff --git a/fnl/config/window-picker.fnl b/fnl/config/window-picker.fnl index d03d9e9..831cfe6 100644 --- a/fnl/config/window-picker.fnl +++ b/fnl/config/window-picker.fnl @@ -8,7 +8,7 @@ (let [window-picker (require :window-picker)] (let [win (window-picker.pick_window)] (if (not= win nil) - (nvim.set_current_win win))))) + (vim.api.nvim_set_current_win win))))) {1 :s1n7ax/nvim-window-picker :event :BufReadPost -- cgit v1.2.3-70-g09d2