Enable lua-based filetype detection
[vimconf.git] / init.vim
1 " My personal vim, nvim, gvim configuration
2 " Author: Stefan Huber <shuber@sthu.org>
3
4
5 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
6 " Some global settings
7
8 set nocompatible
9 set number
10 set cursorline
11 set scrolloff=5
12
13 set encoding=utf-8
14
15 set fillchars=vert:│,fold:\
16 set listchars=tab:»­,trail:·,eol:$
17 set virtualedit=block
18
19 " use filetype.lua and do not use filetype.vim for >=neovim-0.7.2
20 let g:do_filetype_lua = 1
21 let g:did_load_filetypes = 0
22 filetype plugin indent on
23
24 set tabstop=4
25 set shiftwidth=4
26 set expandtab
27 set smarttab
28
29 set autoindent
30 set smartindent
31
32 set incsearch
33 set hlsearch
34
35 set foldcolumn=4
36 set foldlevelstart=20
37
38 set colorcolumn=+1
39 set mouse=a
40 set wildmenu
41 set wildmode=longest,list:full
42 set showcmd
43
44 set tabpagemax=100
45
46 syntax on
47
48 if filereadable($HOME . '/.vim/lowendbox')
49 let g:lowendbox = 1
50 else
51 let g:lowendbox = 0
52 endif
53
54 runtime macros.vim
55 runtime keymaps.vim
56 runtime plugsetup.vim
57
58
59 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
60 " Some filetype-specific settings
61
62 au FileType text,markdown,asciidoc,mail,gitcommit,mediawiki,vimwiki,tex setlocal spell
63 au FileType text,markdown,asciidoc,mail,gitcommit,mediawiki,vimwiki setlocal formatoptions+=n
64 au Filetype mail setlocal formatoptions+=o
65 " Add | for block quotation, such that gq respects it
66 au Filetype mail setlocal comments+=n:\|,
67
68 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
69 au Filetype tex setlocal shiftwidth=2 tabstop=2
70
71 au FileType mediawiki setlocal wrap linebreak textwidth=0
72
73 "git scissor line
74 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
75 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
76
77 " Line wrap crippled with numbers shown
78 au Filetype man setlocal nonumber
79
80 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
81
82 au FileType cpp,c packadd termdebug
83
84 augroup autofoldcolumn
85 au!
86 au CursorHold,BufWinEnter * AutoOrigamiFoldColumn
87 augroup END
88
89
90 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
91 " General settings
92
93
94 " Attention: Must be run after plugsetup.vim
95 " Trailing whitespace
96 highlight default link BadWhitespace SpellCap
97
98 " Setup BadWhitespace syntax match expressions.
99 function SetBadWhitespaceSyntax()
100 " Do not expose bad whitespace in help buffers or for man pages. Or, more
101 " generally, if we open the file readonly.
102 "if &ft != "help" && &ft != "man"
103 if !&readonly
104 " Make trailing whitespace be flagged as bad.
105 syn match BadWhitespace /\s\+$/ containedin=ALL
106 " Make space before tab be flagged as bad and vice versa
107 syn match BadWhitespace / \+\t/ containedin=ALL
108 syn match BadWhitespace /\t \+/ containedin=ALL
109 endif
110 endfunction
111
112 " Make trailing whitespace be flagged as bad.
113 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
114
115 " termdebug split windows
116 let g:termdebug_wide = 1
117 let termdebugger = $HOME . '/.vim/gdb.sh'
118
119
120 if filereadable($HOME . '/.vim/init-local.vim')
121 source ~/.vim/init-local.vim
122 endif