-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
224 lines (186 loc) · 8.25 KB
/
vimrc
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
" ----------------------------------------------------------------------------
" FILE: .vimrc
" DESCRIPTION: vim configuration file
" AUTHOR: Zoltán Király <[email protected]>
" ----------------------------------------------------------------------------
source ~/dotfiles/packages.vim
source ~/dotfiles/digraphs.vim
" ----------------------------------------------------------------------------
" Important
" ----------------------------------------------------------------------------
set pastetoggle=<f5> " Toggle paste option on and off
" ----------------------------------------------------------------------------
" Moving around, searching and patterns
" ----------------------------------------------------------------------------
set incsearch " Incremental search
set ignorecase " Ignore case in search patterns
" ----------------------------------------------------------------------------
" Syntax, highlighting and spelling
" ----------------------------------------------------------------------------
set termguicolors
set background=dark
silent! colorscheme gruvbox8
syntax on " Enable syntax highlighting
set hlsearch " Highlight searches
set spelllang=en_us " Set region to US English
" Shortcut to rapidly toggle spell checking
nmap <silent> <leader>s :set spell!<CR>
" ----------------------------------------------------------------------------
" Multiple windows
" ----------------------------------------------------------------------------
set laststatus=2 " Always display the status line
set hidden " Allow unsaved background buffers
set splitbelow " Horizontally split below
set splitright " Vertically split to the right
" ----------------------------------------------------------------------------
" Terminal
" ----------------------------------------------------------------------------
set title " Show title in console title bar
" ----------------------------------------------------------------------------
" Using the mouse
" ----------------------------------------------------------------------------
set mouse=nv " Enable the mouse in normal and visual mode
" ----------------------------------------------------------------------------
" Messages and info
" ----------------------------------------------------------------------------
"set shortmess+=I " Remove the intro message when starting vim
set showcmd " Show (partial) command keys in the status line
set noshowmode " Don't show the current mode in the status line
set ruler " Show the line and column number of the cursor position
set visualbell " Use a visual bell instead of beeping
" ----------------------------------------------------------------------------
" Editing text
" ----------------------------------------------------------------------------
set backspace=indent,eol,start " Allow backspace in insert mode
set nrformats-=octal " Don't treat numbers with leading zeros as octal
set nojoinspaces " Don't use two spaces after '.' when joining
" ----------------------------------------------------------------------------
" Tabs and indenting
" ----------------------------------------------------------------------------
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab " Insert space characters instead of a tab character
set autoindent " Copy indent from current line when starting a new line
" ----------------------------------------------------------------------------
" Folding
" ----------------------------------------------------------------------------
set foldlevelstart=99
" ----------------------------------------------------------------------------
" Mapping
" ----------------------------------------------------------------------------
set ttimeoutlen=100 " Make Esc work faster
" ----------------------------------------------------------------------------
" Displaying text
" ----------------------------------------------------------------------------
set number " Print the line number in front of each line
set linebreak
" Shortcut to rapidly toggle set list
nmap <silent> <leader>l :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
" ----------------------------------------------------------------------------
" Reading and writing files
" ----------------------------------------------------------------------------
set autoread " Auto read externally modified files
" ----------------------------------------------------------------------------
" Swap file
" ----------------------------------------------------------------------------
set noswapfile
" ----------------------------------------------------------------------------
" Command line editing
" ----------------------------------------------------------------------------
set history=1000 " Keep 1000 lines of command line history
set wildmenu
" ----------------------------------------------------------------------------
" Multi-byte characters
" ----------------------------------------------------------------------------
set encoding=utf-8 " Set default encoding to UTF-8
" ----------------------------------------------------------------------------
" Autocommands
" ----------------------------------------------------------------------------
if has("autocmd")
augroup Misc
" Jump to the last known position when reopening a file
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
if has("nvim")
" Switch to insert mode when entering a terminal buffer
autocmd TermOpen,BufEnter term://* startinsert
endif
augroup END
endif
" ----------------------------------------------------------------------------
" Custom functions
" ----------------------------------------------------------------------------
" Strip trailing spaces
function! Preserve(command)
let l:save = winsaveview()
execute a:command
call winrestview(l:save)
endfunction
command! TrimWhitespace call Preserve("%s/\\s\\+$//e")
nmap _$ :TrimWhitespace<CR>
" Mute search highlighting
nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l>
" Shortcut to rapidly toggle set colorcolumn
nnoremap <silent> <leader>c :execute "set cc=" . (&cc == "" ? "80" : "")<CR>
" ----------------------------------------------------------------------------
" Various
" ----------------------------------------------------------------------------
" Disable Q for entering Ex mode
nnoremap Q <Nop>
" ----------------------------------------------------------------------------
" Neovim specific
" ----------------------------------------------------------------------------
if has('nvim')
set inccommand=nosplit " Incremental substitution
endif
" ----------------------------------------------------------------------------
" Plugin specific
" ----------------------------------------------------------------------------
" ale
let g:ale_linters_explicit = 1
let g:ale_lint_on_text_changed = "never"
let g:ale_lint_on_filetype_changed = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_enter = 0
let g:ale_set_highlights = 0
let g:ale_sign_column_always = 1
" UltiSnips
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" vim-airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_min_count = 2
let g:airline_powerline_fonts = 1
let g:airline_theme = "tomorrow"
" delimitMate
let g:delimitMate_expand_cr = 1
" vim-json
let g:vim_json_syntax_conceal = 0
" pgsql.vim
let g:sql_type_default = 'pgsql'
" vim-startify
let g:startify_custom_header = []
" vim-grepper
nnoremap <silent> <leader>g :Grepper<CR>
" fzf.vim
nnoremap <silent> <C-p> :<C-u>FZF<CR>
let g:fzf_colors = {
\ 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }