summaryrefslogtreecommitdiff
path: root/fnl
diff options
context:
space:
mode:
authoraktersnurra <grydholm@kth.se>2022-04-23 21:56:31 +0200
committeraktersnurra <grydholm@kth.se>2022-04-23 21:56:31 +0200
commitac5dd7d5713e1ac19ba5a33da16a4fe6c0ed42e8 (patch)
treef2df45a8ef7e1f70fd920bfab0efbe3f7760f150 /fnl
parent4ca15d0aa017119670ae454d69911e1ee0e55131 (diff)
refactor(autocmd): update 0.7 api
Diffstat (limited to 'fnl')
-rw-r--r--fnl/config/autocmd.fnl75
1 files changed, 54 insertions, 21 deletions
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 <silent> <buffer> q :close<CR>"
- "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 <silent> <buffer> q :close<CR>"}
+ :_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 <buffer> 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 <buffer> set showtabline=2"}
+ :_alpha)