summaryrefslogtreecommitdiff
path: root/fnl/config/autocmd.fnl
blob: d6bdabdf292f28e87919aa03dc2746ac9c45550e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;; A customizable greeter.
(module config.autocmd
  {autoload {nvim aniseed.nvim
             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-v2 [event opts name]
  (nvim.create_autocmd event (a.merge! {:group (group name)} opts)))

(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-v2 :TextYankPost
         {:callback (lambda [] (vim.highlight.on_yank {:timeout 200}))}
         :_general_settings)

(autocmd-v2 :BufWinEnter
         {:command "setlocal formatoptions-=cro"}
         :_general_settings)

(autocmd-v2 :FileType
         {:pattern "qf"
          :command "set nobuflisted"}
         :_general_settings)

(autocmd-v2 :FileType
         {:pattern "gitcommit"
          :command "setlocal wrap"}
         :_git)

(autocmd-v2 :FileType
         {:pattern "gitcommit"
          :command "setlocal spell"}
         :_git)

(autocmd-v2 :FileType
         {:pattern "markdown"
          :command "setlocal wrap"}
         :_markdown)

(autocmd-v2 :FileType
         {:pattern "markdown"
          :command "setlocal spell"}
         :_markdown)

(autocmd-v2 :FileType
         {:pattern "markdown"
          :command "setlocal spell"}
         :_markdown)

(autocmd-v2 :VimResized
         {:command "tabdo wincmd ="}
         :_auto_resize)