-
Notifications
You must be signed in to change notification settings - Fork 3
/
autocommands.fnl
116 lines (101 loc) · 2.64 KB
/
autocommands.fnl
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(import-macros
{: >==}
:init-macros)
(local dk (require :def-keymaps))
;; (vim.api.nvim_create_autocmd :FileType
;; {:pattern :lspinfo
;; :callback #(vim.api.nvim_buf_set_keymap
;; 0
;; :n
;; :q
;; ":q<CR>"
;; {:silent true})})
;;; Dump command output in buffer
(vim.api.nvim_create_user_command
:Dump
(fn [input]
(let [cmd (.. "put =execute('" input.args "')")]
(vim.cmd cmd)))
{:nargs 1})
(local group (vim.api.nvim_create_augroup
:reovim-autocommands
{:clear true}))
;; Terminal utilities
(vim.api.nvim_create_autocmd
:TermOpen
{:pattern :*
: group
:callback
#(do
(vim.keymap.set
:t
:<Esc><Esc>
:<C-\><C-n>
{:buffer true})
(vim.cmd ":startinsert")
(vim.cmd "setlocal listchars= nonumber norelativenumber"))})
;;; Turn off hlsearch in Insert Mode
(vim.api.nvim_create_autocmd
:InsertEnter
{:pattern :*
: group
:command "setlocal nohlsearch"})
;;; Highlight yanked text
(vim.api.nvim_create_autocmd
:TextYankPost
{:pattern :*
: group
:callback #(vim.highlight.on_yank
{:higroup :IncSearch
:timeout 300})})
;;; Save Shada
(vim.api.nvim_create_autocmd
:VimLeave
{:pattern :*
: group
:command ":wshada!"})
; ;;; Change pwd when opened with a directory argument
; (vim.api.nvim_create_autocmd
; :VimEnter
; {:pattern :*
; : group
; :callback #(vim.api.nvim_set_current_dir (vim.fn.expand "%:p:h"))})
;;; Set preffered shiftwidth for some filetypes
(fn set-shiftwidth [filetype shiftwidth]
(vim.api.nvim_create_autocmd
:FileType
{:pattern filetype
: group
:callback #(vim.cmd
(string.format
" setlocal expandtab tabstop=%d shiftwidth=%d softtabstop=%d "
shiftwidth
shiftwidth
shiftwidth))}))
(>== [:haskell
:norg
:xml
:xslt
:xsd
:fennel
;; :javascript
;; :javascriptreact
;; :javascript.jsx
;; :typescript
;; :typescriptreact
;; :typescript.tsx
:json
:css
:html
:terraform
:scheme
:nix
:agda]
#(set-shiftwidth $1 2))
(>== [:yaml
:rust]
#(set-shiftwidth $1 4))
(vim.filetype.add {:pattern {"%.env%.[%w_.-]+" :sh}})
(dk :n
{:w ["<C-w>" :Window]}
{:prefix :<leader>})