-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
171 lines (138 loc) · 4.15 KB
/
.vimrc
File metadata and controls
171 lines (138 loc) · 4.15 KB
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
" Define work things
if filereadable($HOME . "/.dotfiles/vimrc")
source $HOME/.dotfiles/vimrc
endif
" UTF-8 is now
set encoding=utf8
" Default to unix EOLs, but handle others gracefully
set ffs=unix,dos,mac
" Don't try to redraw in the middle of a macro
set lazyredraw
" 256 colors and syntax highlighting
set t_Co=256
" Color scheme
set bg=dark
colorscheme lunaperche
" Override constants, because contrast is nice
highlight Constant ctermfg=LightRed
" Have the mouse work (but allow terminal mouse when in command prompt)
set mouse=nvi
" Set 'tabstop' and 'shiftwidth' to whatever you prefer and use
" 'expandtab'. This way you will always insert spaces. The
" formatting will never be messed up when 'tabstop' is changed.
set tabstop=4
set softtabstop=2
set shiftwidth=2
set shiftround
set expandtab
set autoindent
set smartindent
set report=1
set hidden
set backspace=indent,eol,start
set incsearch
set showmatch
set ignorecase smartcase
set matchpairs+=<:>
set foldmethod=indent
set foldcolumn=5
set modeline
" Show line numbers
set number
" Ignore compiled files when completing paths
set wildignore=*.o,*~,*.pyc,*.pyo,*.class,*.hi
" File type detection
filetype on
filetype plugin indent on
syntax on
" KEYBINDINGS
""""""""""""""""""""""""""""""""""""""""""""""""""
function! CleverTab()
if strpart( getline('.'), col('.')-2, 1 ) =~ '\s' || col('.') == 1
return "\<Tab>"
else
return "\<C-N>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
" Use the \ key for extra key combos
let mapleader = "\\"
let g:mapleader = "\\"
" \m = remove carriage returns (dos2unix)
noremap <leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" \ss = toggle spell check
set spellfile=$HOME/.vim/spellfile.utf-8.add
nmap <leader>ss :setlocal spell!<cr>
" \g = toggle gitgutter
nmap <leader>g :GitGutterLineHighlightsToggle<cr>
" escape insert mode
inoremap jk <esc>
inoremap kj <esc>
" PLUGINS
""""""""""""""""""""""""""""""""""""""""""""""""""
" Make :Man work
runtime ftplugin/man.vim
" Load pathogen: https://github.com/tpope/vim-pathogen
if filereadable($HOME . "/.vim/autoload/pathogen.vim")
call pathogen#infect($HOME . '/.vim/bundle')
endif
" Tree viewer init
function! NERDinit()
" Nothing to do if we don't have NERDTree
if exists(":NERDTree")
" launch the filetree browser if started without files
if !argc()
NERDTree
endif
noremap <leader>T NERDTreeToggle
endif
endfunction
" no need to leaderleader
let g:EasyMotion_leader_key = '<leader>'
" TRIGGERED ACTIONS
""""""""""""""""""""""""""""""""""""""""""""""""""
" Remember info about open buffers on close...
set viminfo^=%
" Delete trailing whitespace on save in .py files
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
" AUTOCMDs
""""""""""""""""""""""""""""""""""""""""""""""""""
" put all autocmds here, to avoid repeated invocations
if !exists("autocommands_loaded")
" Automatically reload .vimrc when it is saved
autocmd BufWritePost $MYVIMRC source $MYVIMRC
" Allow for highlighting columns beyond some threshold:
highlight OverLength ctermfg=red guifg=red
autocmd FileType python
\ setlocal indentexpr=GetGooglePythonIndent(v:lnum)
\ | setlocal omnifunc=pythoncomplete#Complete
\ | match OverLength /\%>80v.\+/
" Strip trailing whitespace
autocmd BufWrite *.py :call DeleteTrailingWS()
" return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Bind NERDTree
autocmd vimenter * :call NERDinit()
" Paste mode persists by default. I don't recall ever *wanting* this to
" happen, but I *do* sometimes get burned by this. The following autocommand
" prevents this from happening
autocmd InsertLeave * set nopaste
autocmd BufReadPost *.tsx setlocal syntax=typescript
let autocommands_loaded = 1
endif
" Enabling syntax as the last thing, for Reasons, but update the colors
" afterwards
syntax on
" Highlight the cursor
set ruler cursorline cursorcolumn
highlight clear CursorLine
highlight CursorLine ctermbg=16
highlight CursorColumn term=bold ctermbg=black
highlight SpellBad ctermbg=0
highlight link LiteralTab NONE