diff --git a/init.fnl b/init.fnl index ef4f493..2dacc8d 100644 --- a/init.fnl +++ b/init.fnl @@ -10,6 +10,27 @@ (when desc (tset opts :desc desc)) `(vim.keymap.set ,mode ,key ,cmd ,opts))) +;; Better autocommands +(macro hook! [hooks ?patterns callback] + (let [hook_table (if (= (type hooks) :table) + hooks + [ hooks ]) + pattern_table (if (not ?patterns) + [] + (= (type ?patterns) :table) + ?patterns + [ ?patterns ])] + (var group "config-hook") + (each [_ hook (ipairs hook_table)] + (set group (.. group "-" hook))) + (each [_ pattern (ipairs pattern_table)] + (set group (.. group "-" patterns))) + `(vim.api.nvim_create_autocmd ,hook_table + { :group + (vim.api.nvim_create_augroup ,group + { :clear true }) + :pattern ,pattern_table + :callback ,callback }))) ;; Make space leader (set vim.g.mapleader " ") @@ -459,7 +480,9 @@ :enable false }}}))) (use! :neovim/nvim-lspconfig :after :cmp-nvim-lsp - :config lsp_config_callback)) + :config lsp_config_callback) + (use! :mfussenegger/nvim-jdtls + :after :nvim-lspconfig)) (vim.cmd.packadd "packer.nvim") (let [packer (require :packer)]