Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 1 | " LLVM coding guidelines conformance for VIM |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 2 | " |
| 3 | " Maintainer: The LLVM Team, http://llvm.org |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 4 | " WARNING: Read before you source in all these commands and macros! Some |
Misha Brukman | 2bb5508 | 2005-05-12 21:41:48 +0000 | [diff] [blame] | 5 | " of them may change VIM behavior that you depend on. |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 6 | " |
| 7 | " You can run VIM with these settings without changing your current setup with: |
| 8 | " $ vim -u /path/to/llvm/utils/vim/vimrc |
| 9 | |
| 10 | " It's VIM, not VI |
| 11 | set nocompatible |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 12 | |
| 13 | " Wrap text at 80 cols |
| 14 | set textwidth=80 |
| 15 | |
| 16 | " A tab produces a 2-space indentation |
Dan Gohman | f225d2e | 2009-01-04 00:05:43 +0000 | [diff] [blame] | 17 | set softtabstop=2 |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 18 | set shiftwidth=2 |
| 19 | set expandtab |
| 20 | |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 21 | " Highlight trailing whitespace |
| 22 | highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow |
| 23 | match WhitespaceEOL /\s\+$/ |
| 24 | |
Dan Gohman | 5e59c27 | 2009-01-21 21:30:25 +0000 | [diff] [blame] | 25 | " Enable filetype detection |
| 26 | filetype on |
| 27 | |
Misha Brukman | 2bb5508 | 2005-05-12 21:41:48 +0000 | [diff] [blame] | 28 | " Optional |
| 29 | " C/C++ programming helpers |
Dan Gohman | 5e59c27 | 2009-01-21 21:30:25 +0000 | [diff] [blame] | 30 | augroup csrc |
| 31 | au! |
| 32 | autocmd FileType * set nocindent smartindent |
| 33 | autocmd FileType c,cpp set cindent |
| 34 | augroup END |
Dan Gohman | a0741ba | 2009-01-04 18:59:55 +0000 | [diff] [blame] | 35 | " Set a few indentation parameters. See the VIM help for cinoptions-values for |
| 36 | " details. These aren't absolute rules; they're just an approximation of |
| 37 | " common style in LLVM source. |
Dan Gohman | acb75a9 | 2010-01-09 17:15:21 +0000 | [diff] [blame^] | 38 | set cinoptions=:0,g0,(0,Ws,l1 |
Misha Brukman | 2bb5508 | 2005-05-12 21:41:48 +0000 | [diff] [blame] | 39 | " Add and delete spaces in increments of `shiftwidth' for tabs |
| 40 | set smarttab |
| 41 | |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 42 | " Highlight syntax in programming languages |
| 43 | syntax on |
| 44 | |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 45 | " LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile, |
| 46 | " so it's important to categorize them as such. |
| 47 | augroup filetype |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 48 | au! BufRead,BufNewFile *Makefile* set filetype=make |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 49 | augroup END |
| 50 | |
| 51 | " In Makefiles, don't expand tabs to spaces, since we need the actual tabs |
| 52 | autocmd FileType make set noexpandtab |
| 53 | |
| 54 | " Useful macros for cleaning up code to conform to LLVM coding guidelines |
| 55 | |
| 56 | " Delete trailing whitespace and tabs at the end of each line |
Misha Brukman | 5539a1e | 2009-01-08 02:17:30 +0000 | [diff] [blame] | 57 | command! DeleteTrailingWs :%s/\s\+$// |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 58 | |
| 59 | " Convert all tab characters to two spaces |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 60 | command! Untab :%s/\t/ /g |
Dan Gohman | 789da27 | 2009-01-21 21:47:51 +0000 | [diff] [blame] | 61 | |
| 62 | " Enable syntax highlighting for LLVM files. To use, copy |
| 63 | " utils/vim/llvm.vim to ~/.vim/syntax . |
| 64 | augroup filetype |
| 65 | au! BufRead,BufNewFile *.ll set filetype=llvm |
| 66 | augroup END |
| 67 | |
| 68 | " Enable syntax highlighting for tablegen files. To use, copy |
| 69 | " utils/vim/tablegen.vim to ~/.vim/syntax . |
| 70 | augroup filetype |
| 71 | au! BufRead,BufNewFile *.td set filetype=tablegen |
| 72 | augroup END |