From ac5dd7d5713e1ac19ba5a33da16a4fe6c0ed42e8 Mon Sep 17 00:00:00 2001 From: aktersnurra Date: Sat, 23 Apr 2022 21:56:31 +0200 Subject: refactor(autocmd): update 0.7 api --- fnl/config/autocmd.fnl | 75 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 21 deletions(-) (limited to 'fnl') diff --git a/fnl/config/autocmd.fnl b/fnl/config/autocmd.fnl index 8cf1e1f..bb9b232 100644 --- a/fnl/config/autocmd.fnl +++ b/fnl/config/autocmd.fnl @@ -1,29 +1,62 @@ ;; A customizable greeter. -(module config.autocmd {autoload {nvim aniseed.nvim util util}}) +(module config.autocmd + {autoload {nvim aniseed.nvim + a aniseed.core + 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")) +(defn- group [name] + (nvim.create_augroup name {:clear true})) -(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"]) +(defn- autocmd [event opts name] + (nvim.create_autocmd event (a.merge! {:group (group name)} opts))) -(def- git ["FileType gitcommit setlocal wrap" - "FileType gitcommit setlocal spell"]) +(autocmd :FileType + {:pattern [:qf :help :man :lspinfo] + :command "nnoremap q :close"} + :_general_settings) -(def- markdown ["FileType markdown setlocal wrap" - "FileType markdown setlocal spell"]) +(autocmd :TextYankPost + {:callback (lambda [] (vim.highlight.on_yank {:timeout 200}))} + :_general_settings) -(def- auto-resize ["VimResized * tabdo wincmd ="]) +(autocmd :BufWinEnter + {:command "setlocal formatoptions-=cro"} + :_general_settings) -(def- alpha - ["User AlphaReady set showtabline=0 | autocmd BufUnload set showtabline=2"]) +(autocmd :FileType + {:pattern "qf" + :command "set nobuflisted"} + :_general_settings) -(autocmd :_general_settings general-settings) -(autocmd :_git git) -(autocmd :_markdown markdown) -(autocmd :_auto_resize auto-resize) -(autocmd :_alpha alpha) +(autocmd :FileType + {:pattern "gitcommit" + :command "setlocal wrap"} + :_git) + +(autocmd :FileType + {:pattern "gitcommit" + :command "setlocal spell"} + :_git) + +(autocmd :FileType + {:pattern "markdown" + :command "setlocal wrap"} + :_markdown) + +(autocmd :FileType + {:pattern "markdown" + :command "setlocal spell"} + :_markdown) + +(autocmd :FileType + {:pattern "markdown" + :command "setlocal spell"} + :_markdown) + +(autocmd :VimResized + {:command "tabdo wincmd ="} + :_auto_resize) + +(autocmd "User AlphaReady" + {:command "set showtabline=0 | autocmd BufUnload set showtabline=2"} + :_alpha) -- cgit v1.2.3-70-g09d2