diff options
author | aktersnurra <grydholm@kth.se> | 2022-04-24 01:30:45 +0200 |
---|---|---|
committer | aktersnurra <grydholm@kth.se> | 2022-04-24 01:30:45 +0200 |
commit | 34eea7e836f08cae06f7c0371726dd2023a30510 (patch) | |
tree | 922d7e5126f862865686571698511bc69a5b32a8 /fnl/config | |
parent | c772ce25ea5d46704ea116792b9ebb7fea723e0c (diff) |
fix(autocmd): add v1 and v2
Diffstat (limited to 'fnl/config')
-rw-r--r-- | fnl/config/autocmd.fnl | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/fnl/config/autocmd.fnl b/fnl/config/autocmd.fnl index bb9b232..d6bdabd 100644 --- a/fnl/config/autocmd.fnl +++ b/fnl/config/autocmd.fnl @@ -4,59 +4,70 @@ a aniseed.core util util}}) +(defn- autocmd-v1 [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})) -(defn- autocmd [event opts name] +(defn- autocmd-v2 [event opts name] (nvim.create_autocmd event (a.merge! {:group (group name)} opts))) -(autocmd :FileType +(def- alpha + ["User AlphaReady set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2"]) + +(def- nvim-tree-autoclose + ["BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif"]) + +(autocmd-v1 :_alpha alpha) +(autocmd-v1 :_nvim-tree nvim-tree-autoclose) + +(autocmd-v2 :FileType {:pattern [:qf :help :man :lspinfo] :command "nnoremap <silent> <buffer> q :close<CR>"} :_general_settings) -(autocmd :TextYankPost +(autocmd-v2 :TextYankPost {:callback (lambda [] (vim.highlight.on_yank {:timeout 200}))} :_general_settings) -(autocmd :BufWinEnter +(autocmd-v2 :BufWinEnter {:command "setlocal formatoptions-=cro"} :_general_settings) -(autocmd :FileType +(autocmd-v2 :FileType {:pattern "qf" :command "set nobuflisted"} :_general_settings) -(autocmd :FileType +(autocmd-v2 :FileType {:pattern "gitcommit" :command "setlocal wrap"} :_git) -(autocmd :FileType +(autocmd-v2 :FileType {:pattern "gitcommit" :command "setlocal spell"} :_git) -(autocmd :FileType +(autocmd-v2 :FileType {:pattern "markdown" :command "setlocal wrap"} :_markdown) -(autocmd :FileType +(autocmd-v2 :FileType {:pattern "markdown" :command "setlocal spell"} :_markdown) -(autocmd :FileType +(autocmd-v2 :FileType {:pattern "markdown" :command "setlocal spell"} :_markdown) -(autocmd :VimResized +(autocmd-v2 :VimResized {:command "tabdo wincmd ="} :_auto_resize) - -(autocmd "User AlphaReady" - {:command "set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2"} - :_alpha) |