From 3542e120015fa32a4c62c2b6eba036eb5252731c Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 11 Apr 2022 20:44:55 +0200 Subject: fix(autocmd): hopefully fix bug --- fnl/config/autocmd.fnl | 87 ++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 49 deletions(-) (limited to 'fnl/config') diff --git a/fnl/config/autocmd.fnl b/fnl/config/autocmd.fnl index ecec60a..e168bd5 100644 --- a/fnl/config/autocmd.fnl +++ b/fnl/config/autocmd.fnl @@ -1,50 +1,39 @@ ;; A customizable greeter. -(module config.autocmd {autoload {util util}}) - -(util.autocmd :FileType {:pattern [:qf :help :man :lspinfo] - :command "nnoremap q :close" - :group :_general_settings}) - -(util.autocmd :TextYankPost - {:pattern ["*"] - :callback (lambda [] - (vim.highlight.on_yank {:timeout 200})) - :group :_general_settings}) - -(util.autocmd :BufWinEnter - {:pattern ["*"] - :command ":set formatoptions-=cro" - :group :_general_settings}) - -(util.autocmd :FileType {:pattern [:qf] - :command "set nobuflisted" - :group :_general_settings}) - -(util.autocmd :FileType {:pattern [:gitcommit] - :command "setlocal wrap" - :group :_git}) - -(util.autocmd :FileType {:pattern [:gitcommit] - :command "setlocal spell" - :group :_git}) - -(util.autocmd :FileType {:pattern [:markdown] - :command "setlocal wrap" - :group :_markdown}) - -(util.autocmd :FileType {:pattern [:markdown] - :command "setlocal spell" - :group :_markdown}) - -(util.autocmd :VimResized {:pattern ["*"] - :command "tabdo wincmd =" - :group :_auto_resize}) - -(util.autocmd :User {:pattern [:AlphaReady] - :command "set showtabline=0 | autocmd BufUnload set showtabline=2" - :group :_alpha}) - -(util.autocmd :BufWritePost - {:pattern [:plugins.fnl] - :command "source | PackerSync" - :group :packer_user_config}) +(module config.autocmd {autoload {nvim aniseed.nvim util util}}) + +(defn autocmd [group cmds] + (nvim.command (.. "augroup " group)) + (nvim.command "autocmd!") + (each [_ cmd (ipairs cmds)] + (nvim.command (.. "autocmd " cmd))) + (nvim.command "augroup end")) + +(def- general-settings [ + "FileType qf,help,man,lspinfo nnoremap q :close" + "TextYankPost * silent!lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})" + "BufWinEnter * :set formatoptions-=cro" + "FileType qf set nobuflisted"]) + +(def- git [ + "FileType gitcommit setlocal wrap" + "FileType gitcommit setlocal spell"]) + +(def- markdown [ + "FileType markdown setlocal wrap" + "FileType markdown setlocal spell"]) + +(def- auto-resize [ + "VimResized * tabdo wincmd ="]) + +(def- alpha [ + "User AlphaReady set showtabline=0 | autocmd BufUnload set showtabline=2"]) + +(def- packer [ + "BufWritePost plugins.lua source | PackerSync"]) + +(autocmd "_general_settings" general-settings) +(autocmd "_git" git) +(autocmd "_markdown" markdown) +(autocmd "_auto_resize" auto-resize) +(autocmd "_alpha" alpha) +(autocmd "packer_user_config" packer) -- cgit v1.2.3-70-g09d2