summaryrefslogtreecommitdiff
path: root/fnl/conf/events.fnl
blob: 909eee11d10473994a7ea1fea0c8369bceefe4b3 (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
(vim.api.nvim_create_augroup "conf#events" {:clear true})

(let [white_space_highlight (fn []
                              (local pattern "'\\s\\+$'")
                              (vim.cmd (.. "syn match TrailingWhitespace "
                                           pattern))
                              (vim.cmd "hi link TrailingWhitespace IncSearch"))
      trim [:*.fnl
            :*.rkt
            :*.nix
            :*.md
            :*.hcl
            :*.tf
            :*.py
            :*.cpp
            :*.qml
            :*.js
            :*.txt
            :*.json
            :*.html
            :*.lua
            :*.yaml
            :*.yml
            :*.bash
            :*.sh
            :*.go]
      white_space_trim (fn []
                         (local pattern "\\s\\+$")
                         (vim.cmd (.. "%substitute/" pattern ://ge)))]
  (vim.api.nvim_create_autocmd [:BufReadPost]
                               {:pattern ["*"]
                                :callback white_space_highlight
                                :group "conf#events"})
  (vim.api.nvim_create_autocmd [:BufWritePre]
                               {:pattern trim
                                :callback white_space_trim
                                :group "conf#events"}))