From 55e022631c16fbcda4cd7d2b2785eb30790a9649 Mon Sep 17 00:00:00 2001 From: sefidel Date: Sat, 19 Feb 2022 19:10:16 +0900 Subject: feat(macro)!: use more standard name for autocmd/groups --- fnl/nvrc/events.fnl | 36 ++++++++++++++++++------------------ fnl/nvrc/macro/event.fnl | 8 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'fnl') diff --git a/fnl/nvrc/events.fnl b/fnl/nvrc/events.fnl index 278e721..c5b4d8e 100644 --- a/fnl/nvrc/events.fnl +++ b/fnl/nvrc/events.fnl @@ -1,5 +1,5 @@ -(import-macros {: au! - : ac!} :nvrc.macro.event) +(import-macros {: ag! + : au!} :nvrc.macro.event) (import-macros {: set! : setl!} :nvrc.macro.set) (local {: echo!} (require :nvrc.lib.io)) @@ -10,38 +10,38 @@ (fn bufexists? [...] (= (vim.fn.bufexists ...) 1)) ; Restore cursor style to beam on exit -(au! restore-cursor - (ac! VimLeave * #(set! guicursor ["a:ver75-blinkon0"]))) +(ag! restore-cursor + (au! VimLeave * #(set! guicursor ["a:ver75-blinkon0"]))) ; Restore the last cursor line -(au! restore-last-cursor-line - (ac! BufReadPost * #(if (and (> (line "'\"") 1) +(ag! restore-last-cursor-line + (au! BufReadPost * #(if (and (> (line "'\"") 1) (<= (line "'\"") (line "$"))) (cmd! "normal! g'\"")))) ; Resize splits on window resize -(au! resize-splits-on-resize - (ac! VimResized * "wincmd =")) +(ag! resize-splits-on-resize + (au! VimResized * "wincmd =")) ;; Read file when it changes on disk -(au! read-file-on-disk-change - (ac! [FocusGained BufEnter CursorHold CursorHoldI] * +(ag! read-file-on-disk-change + (au! [FocusGained BufEnter CursorHold CursorHoldI] * #(if (and (not= :c (mode)) (not (bufexists? "[Command Line]"))) (cmd! "checktime"))) - (ac! FileChangedShellPost * + (au! FileChangedShellPost * #(echo! "File changed on disk. Buffer reloaded."))) -(au! terminal-options - ;; Enter Terminal-mode (insert) automatically - (ac! TermOpen * "startinsert") +(ag! terminal-options + ;; Enter Terminal-mode (insert) agtomatically + (au! TermOpen * "startinsert") ;; Disables line number on terminal buffers - (ac! TermOpen * #(do + (au! TermOpen * #(do (setl! nonumber) (setl! norelativenumber))) ;; Disables spell on terminal buffers - (ac! TermOpen * #(setl! nospell)) + (au! TermOpen * #(setl! nospell)) ;; Disables sign column on terminal buffers - (ac! TermOpen * #(setl! signcolumn :no)) + (au! TermOpen * #(setl! signcolumn :no)) ;; Disables colorcolumn on terminal buffers - (ac! TermOpen * #(setl! colorcolumn []))) + (au! TermOpen * #(setl! colorcolumn []))) diff --git a/fnl/nvrc/macro/event.fnl b/fnl/nvrc/macro/event.fnl index 3453431..0727969 100644 --- a/fnl/nvrc/macro/event.fnl +++ b/fnl/nvrc/macro/event.fnl @@ -15,7 +15,7 @@ (accumulate [is? false _ v (ipairs xs) :until is?] (= v x))) -(lambda au! [name ...] +(lambda ag! [name ...] "Defines an autocommand group using the vim API." `(do (vim.cmd ,(format "augroup %s" name)) @@ -24,7 +24,7 @@ ,...) (vim.cmd "augroup END"))) -(lambda aub! [name ...] +(lambda agb! [name ...] "Defines a buffer-local autocommand group using the vim API." `(do (vim.cmd ,(format "augroup %s" name)) @@ -33,7 +33,7 @@ ,...) (vim.cmd "augroup END"))) -(lambda ac! [events pattern ...] +(lambda au! [events pattern ...] "Defines an autocommand using the vim API." (let [events (as-> [$ events] (if (sequence? $) $ [$]) (icollect [_ v (ipairs $)] @@ -60,4 +60,4 @@ "autocmd %s %s ++nested %s" "autocmd %s %s %s") events pattern command))))) -{: au! : aub! : ac!} +{: ag! : agb! : au!} -- cgit 1.4.1