forked from PegasusWang/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiletype.vim
171 lines (137 loc) · 4.67 KB
/
filetype.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
" File Types
" ---
augroup user_plugin_filetype " {{{
autocmd!
" Reload vim configuration automatically on-save
autocmd BufWritePost $VIM_PATH/{*.vim,*.yaml,vimrc} nested
\ source $MYVIMRC | redraw
" Highlight current line only on focused window, unless:
" 1. Cursor-line is already set to wanted value
" 2. Denite or Clap buffers
" 3. Preview window
" 4. Completion popup menu is visible
autocmd WinEnter,BufEnter,InsertLeave *
\ if ! &cursorline && &filetype !~# '^\(denite\|clap_\|.*quickpick\)'
\ && ! &previewwindow && ! pumvisible()
\ | setlocal cursorline
\ | endif
autocmd WinLeave,BufLeave,InsertEnter *
\ if &cursorline && &filetype !~# '^\(denite\|clap_\|.*quickpick\)'
\ && ! &previewwindow && ! pumvisible()
\ | setlocal nocursorline
\ | endif
" Automatically set read-only for files being edited elsewhere
autocmd SwapExists * nested let v:swapchoice = 'o'
" Update diff comparison once leaving insert mode
autocmd InsertLeave * if &l:diff | diffupdate | endif
" Equalize window dimensions when resizing vim window
autocmd VimResized * wincmd =
" Force write shada on leaving nvim
autocmd VimLeave * if has('nvim') | wshada! | else | wviminfo! | endif
" Check if file changed when its window is focus, more eager than 'autoread'
autocmd FocusGained * checktime
autocmd Syntax * if line('$') > 5000 | syntax sync minlines=200 | endif
" Neovim terminal settings
if has('nvim-0.5')
autocmd TermOpen * setlocal modifiable
try
autocmd TextYankPost *
\ silent! lua vim.highlight.on_yank {higroup="IncSearch", timeout=150}
endtry
endif
" Update filetype on save if empty
autocmd BufWritePost * nested
\ if &l:filetype ==# '' || exists('b:ftdetect')
\ | unlet! b:ftdetect
\ | filetype detect
\ | endif
" Reload Vim script automatically if setlocal autoread
autocmd BufWritePost,FileWritePost *.vim nested
\ if &l:autoread > 0 | source <afile> |
\ echo 'source ' . bufname('%') |
\ endif
" When editing a file, always jump to the last known cursor position.
" Credits: https://github.com/farmergreg/vim-lastplace
autocmd BufReadPost *
\ if index(['gitcommit', 'gitrebase', 'svn', 'hgcommit'], &buftype) == -1 &&
\ index(['quickfix', 'nofile', 'help'], &buftype) == -1 &&
\ ! &diff && ! &previewwindow &&
\ line("'\"") > 0 && line("'\"") <= line("$")
\| if line("w$") == line("$")
\| execute "normal! g`\""
\| elseif line("$") - line("'\"") > ((line("w$") - line("w0")) / 2) - 1
\| execute "normal! g`\"zz"
\| else
\| execute "normal! \G'\"\<c-e>"
\| endif
\| if foldclosed('.') != -1
\| execute 'normal! zvzz'
\| endif
\| endif
autocmd FileType apache setlocal path+=./;/
autocmd FileType html setlocal path+=./;/
autocmd FileType crontab setlocal nobackup nowritebackup
autocmd FileType yaml.docker-compose setlocal expandtab
autocmd FileType gitcommit setlocal spell
autocmd FileType gitcommit,qfreplace setlocal nofoldenable
autocmd FileType php setlocal matchpairs-=<:> iskeyword+=\\
autocmd FileType python
\ setlocal expandtab smarttab nosmartindent
\ | setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=120
autocmd FileType markdown
\ setlocal expandtab nospell conceallevel=0
\ | setlocal autoindent formatoptions=tcroqn2 comments=n:>
" https://webpack.github.io/docs/webpack-dev-server.html#working-with-editors-ides-supporting-safe-write
autocmd FileType css,javascript,javascriptreact setlocal backupcopy=yes
augroup END " }}}
" Internal Plugin Settings {{{
" ------------------------
" PHP {{{
let g:PHP_removeCRwhenUnix = 0
" }}}
" Python {{{
let g:python_recommended_style = 0
let g:pydoc_executable = 0
let g:python_highlight_all = 1
" let g:python_highlight_builtins = 1
" let g:python_highlight_exceptions = 1
" let g:python_highlight_string_format = 1
" let g:python_highlight_doctests = 1
" let g:python_highlight_class_vars = 1
" let g:python_highlight_operators = 1
" }}}
" Vim {{{
let g:vimsyntax_noerror = 1
let g:vim_indent_cont = &shiftwidth
" }}}
" Bash {{{
let g:is_bash = 1
let g:sh_no_error = 1
" }}}
" Java {{{
let g:java_highlight_functions = 'style'
let g:java_highlight_all = 1
let g:java_highlight_debug = 1
let g:java_allow_cpp_keywords = 1
let g:java_space_errors = 1
let g:java_highlight_functions = 1
" }}}
" JavaScript {{{
let g:SimpleJsIndenter_BriefMode = 1
let g:SimpleJsIndenter_CaseIndentLevel = -1
" }}}
" Ruby {{{
let g:ruby_no_expensive = 1
" }}}
" Folding {{{
" augroup: a
" function: f
let g:vimsyn_folding = 'af'
let g:tex_fold_enabled = 1
let g:xml_syntax_folding = 1
let g:php_folding = 2
let g:php_phpdoc_folding = 1
let g:perl_fold = 1
" }}}
" }}}
" vim: set foldmethod=marker ts=2 sw=2 tw=80 noet :