-
Notifications
You must be signed in to change notification settings - Fork 1
/
autocmd.vim
38 lines (31 loc) · 1.11 KB
/
autocmd.vim
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
vim9script
import autoload "./autoload/utils.vim" as Utils
# Functions [[[1
def JumpToLastPosition() # [[[2
const last_pos = getpos("'\"")
if last_pos[1] >= 1 && last_pos[1] <= line('$')
setpos('.', getpos("'\""))
endif
enddef
# Autocmd [[[1
augroup vimrc
autocmd FocusLost * :silent! wa
autocmd FocusGained * silent! checktime
autocmd TerminalWinOpen * setlocal nonu nornu nolist signcolumn=no
autocmd BufReadPost * JumpToLastPosition()
augroup END
# FileType
for ft in ['vim', 'sh', 'zsh', 'bash', 'css', 'html', 'javascript', 'typescript', 'ps1', 'lisp']
autocmd_add([{ event: 'FileType', pattern: ft, group: 'vimrc', cmd: 'Utils.SetTabWidth(2, true)' }])
endfor
for ft in ['python']
autocmd_add([{ event: 'FileType', pattern: ft, group: 'vimrc', cmd: 'Utils.SetTabWidth(4, true)' }])
endfor
for ft in ['go']
autocmd_add([{ event: 'FileType', pattern: ft, group: 'vimrc', cmd: 'Utils.SetTabWidth(4, false)' }])
endfor
for ft in ['make', 'snippets']
autocmd_add([{ event: 'FileType', pattern: ft, group: 'vimrc', cmd: 'Utils.SetTabWidth(8, false, 0)' }])
endfor
# ]]]
# vim:fdm=marker:fmr=[[[,]]]:ft=vim