From 9dd308b444ede3a68a29961e956937d2ce402e45 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sat, 6 Aug 2022 15:33:54 +0200 Subject: Move autocmd fn back and rename --- fnl/config/autocmd.fnl | 41 ++++++++++++++++++++++------------------- fnl/config/toggleterm.fnl | 9 +++++---- fnl/util.fnl | 2 -- 3 files changed, 27 insertions(+), 25 deletions(-) (limited to 'fnl') diff --git a/fnl/config/autocmd.fnl b/fnl/config/autocmd.fnl index 28ed98d..40eb338 100644 --- a/fnl/config/autocmd.fnl +++ b/fnl/config/autocmd.fnl @@ -1,30 +1,33 @@ ;; Autocommands for nvim. (module config.autocmd {autoload {nvim aniseed.nvim a aniseed.core : util}}) -(util.autocmd :BufEnter - {:command "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif"}) +(defn create-autocmd [event opts] (nvim.create_autocmd event opts)) -(util.autocmd :FileType - {:pattern [:qf :help :man :lspinfo] - :command "nnoremap q :close"}) +(create-autocmd :BufEnter + {:command "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif"}) -(util.autocmd :TextYankPost - {:callback (lambda [] - (vim.highlight.on_yank {:timeout 200}))}) +(create-autocmd :FileType + {:pattern [:qf :help :man :lspinfo] + :command "nnoremap q :close"}) -(util.autocmd :BufWinEnter {:command "setlocal formatoptions-=cro"}) +(create-autocmd :TextYankPost + {:callback (lambda [] + (vim.highlight.on_yank {:timeout 200}))}) -(util.autocmd :FileType {:pattern :qf :command "set nobuflisted"}) +(create-autocmd :BufWinEnter {:command "setlocal formatoptions-=cro"}) -(util.autocmd :FileType - {:pattern :lir - :callback (fn [] - (tset vim.opt_local :number false) - (tset vim.opt_local :relativenumber false))}) +(create-autocmd :FileType {:pattern :qf :command "set nobuflisted"}) -(util.autocmd :FileType {:pattern [:gitcommit :markdown] :command "setlocal wrap"}) +(create-autocmd :FileType {:pattern :lir + :callback (fn [] + (tset vim.opt_local :number false) + (tset vim.opt_local :relativenumber + false))}) -(util.autocmd :FileType {:pattern [:gitcommit :markdown :org :plaintex] - :command "setlocal spell"}) +(create-autocmd :FileType {:pattern [:gitcommit :markdown] + :command "setlocal wrap"}) -(util.autocmd :VimResized {:command "tabdo wincmd ="}) +(create-autocmd :FileType {:pattern [:gitcommit :markdown :org :plaintex] + :command "setlocal spell"}) + +(create-autocmd :VimResized {:command "tabdo wincmd ="}) diff --git a/fnl/config/toggleterm.fnl b/fnl/config/toggleterm.fnl index 1aaee62..cfc9a33 100644 --- a/fnl/config/toggleterm.fnl +++ b/fnl/config/toggleterm.fnl @@ -1,5 +1,6 @@ ;; Terminal inside nvim. -(module config.toggleterm {autoload {: util nvim aniseed.nvim}}) +(module config.toggleterm + {autoload {: util nvim aniseed.nvim autocmd config.autocmd}}) (def- opts {:shade_terminals false}) @@ -10,6 +11,6 @@ (nvim.set_keymap :t : "wincmd l" {})) (util.use-config :toggleterm opts) -(util.autocmd :TermOpen - {:pattern "term://*toggleterm#*" - :callback set-terminal-keymaps}) +(autocmd.create-autocmd :TermOpen + {:pattern "term://*toggleterm#*" + :callback set-terminal-keymaps}) diff --git a/fnl/util.fnl b/fnl/util.fnl index a8ea011..555768c 100644 --- a/fnl/util.fnl +++ b/fnl/util.fnl @@ -1,8 +1,6 @@ ;; Utility functions. (module util {autoload {a aniseed.core nvim aniseed.nvim : packer}}) -(defn autocmd [event opts] (nvim.create_autocmd event opts)) - (def- path (.. (vim.fn.stdpath :data) :/site/pack/packer/start)) (def- installed-plugins (vim.fn.readdir path)) -- cgit v1.2.3-70-g09d2