-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
234 lines (199 loc) · 6.64 KB
/
init.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
call plug#begin('~/.config/nvim/plugged')
" Plugins {
" ctrl-p is a fuzzy file finder.
Plug 'ctrlpvim/ctrlp.vim'
" airline is a better status line and a tab-bar for nvim.
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Cobalt colorscheme. Seems to work the best for me.
"Plug 'herrbischoff/cobalt2.vim'
" neomake is a code linting tool that runs in the background.
Plug 'neomake/neomake'
" rails plugins
Plug 'tpope/vim-rails'
" git wrapper (:Gblame :Gstatus etc)
Plug 'tpope/vim-fugitive'
" syntax support for haml templates
Plug 'tpope/vim-haml'
" syntax support for slim templates
Plug 'slim-template/vim-slim'
" adds `end` automatically
Plug 'tpope/vim-endwise'
" comment lines with :gc
Plug 'tpope/vim-commentary'
" opens current line in GitHub
Plug 'ruanyl/vim-gh-line'
" autocomplete"
Plug 'ervandew/supertab'
" browse current directory (<leader>-)
Plug 'tpope/vim-vinegar'
" time tracker
Plug 'wakatime/vim-wakatime'
" }
call plug#end()
" Map the leader key to ,
let mapleader="\<SPACE>"
" General {
"set noautoindent " I indent my code myself.
"set nocindent " I indent my code myself.
set smartindent " Or I let the smartindent take care of it.
set ttimeout
set ttimeoutlen=100
" }
" Search {
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set gdefault " Use 'g' flag by default with :s/foo/bar/.
set magic " Use 'magic' patterns (extended regular expressions).
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
" }
" Formatting {
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set showmode " Show current mode.
set ruler " Show the line and column numbers of the cursor.
set number " Show the line numbers on the left side.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set expandtab " Insert spaces when TAB is pressed.
set tabstop=2 " Render TABs using this many spaces.
set shiftwidth=2 " Indentation amount for < and > commands.
set noerrorbells " No beeps.
set modeline " Enable modeline.
"set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
if !&scrolloff
set scrolloff=3 " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
endif
set nostartofline " Do not jump to first character with page commands.
" Tell Vim which characters to show for expanded TABs,
" trailing whitespace, and end-of-lines. VERY useful!
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
set list " Show problematic characters.
" }
" Configuration {
set autochdir " Switch to current file's parent directory.
set clipboard=unnamed
" Remove special characters for filename
set isfname-=:
set isfname-==
set isfname-=+
" Map ; to :
nnoremap ; :
if &undolevels < 200
set undolevels=200 " Number of undo levels.
endif
" Path/file expansion in colon-mode.
set wildmode=list:longest
set wildchar=<TAB>
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux'
set t_Co=16
endif
" Remove trailing spaces.
function! TrimWhitespace()
let l:save = winsaveview()
%s/\s\+$//e
call winrestview(l:save)
endfunction
" FIXME: Do not call this on makefile and sv files.
autocmd BufWritePre * call TrimWhitespace()
nnoremap <leader>W :call TrimWhitespace()<CR>
" Diff options
set diffopt+=iwhite
" Keep selected the text after moving with < or >
vnoremap < <gv
vnoremap > >gv
" Quickly select the text that was just pasted. This allows you to, e.g.,
" indent it after pasting.
noremap gV `[v`]
" }
" UI Options {
" Colorscheme options.
set bg=dark
"colorscheme cobalt2
" Also highlight all tabs and trailing whitespace characters.
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+$\|\t/
" Relative numbering
function! NumberToggle()
if(&relativenumber == 1)
set nornu
set number
else
set rnu
endif
endfunc
" Toggle between normal and relative numbering.
nnoremap <leader>r :call NumberToggle()<cr>
" }
" Keybindings {
" Save file
nnoremap <Leader>w :w<CR>
" Copy and paste from system clipboard (Might require xsel/xclip install)
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
" Move between buffers
nmap <Leader>l :bnext<CR>
nmap <Leader>h :bprevious<CR>
" }
" Experimental {
" Search and Replace
nmap <Leader>s :%s//g<Left><Left>
" }
" Plugin Settings {
" Airline {
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
let g:airline#extensions#tabline#right_sep = ''
let g:airline#extensions#tabline#right_alt_sep = ''
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_theme= 'cobalt2'
" }
" CtrlP {
" Open file menu
nnoremap <Leader>o :CtrlP<CR>
" Open buffer menu
nnoremap <Leader>b :CtrlPBuffer<CR>
" Open most recently used files
nnoremap <Leader>f :CtrlPMRUFiles<CR>
" }
" neomake {
autocmd! BufWritePost * Neomake
"nnoremap <Leader>l :lopen<CR>
" }
" neomake {
let g:netrw_liststyle=3 " tree (change to 0 for thin)
let g:netrw_banner=0 " no banner
let g:netrw_altv=1 " open files on right
let g:netrw_winsize=80 " only use 20% screen for netrw
" FIXME: Preview opens to left and is very narrow
let g:netrw_preview=1 " open previews vertically
" }
"Vinegar {
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' " exclude dot files (Press gh to toggle dot files hiding)
" }
" }
" vim:set ft=vim sw=2 ts=2: