-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
183 lines (135 loc) · 4.38 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
"
" Enforce
"
if &compatible
set nocompatible
endif
"
" General
"
color lettuce
"color iceberg
filetype on
filetype indent on
filetype plugin on
syntax on
"
" Directories
"
set backupdir=$HOME/.vim/backup//
set directory=$HOME/.vim/swapfiles//
"
" Overrides
"
let mapleader=','
"
" Settings
"
set autoindent " automatically indent based on previous line
set autoread " automatically reload if changed outside of vim
set foldmethod=syntax " folding
set hidden " enable switching from unsaved buffers
set history=10000 " set history count
set laststatus=2 " always show a status bar
set winwidth=80 " minimal number of columns for the current window
set mouse=a " enable mouse
set nu " show line numbers
set ignorecase smartcase " enable case-sensitive search only if case is detected
set nobackup " disable backup files
set noequalalways " disable resize on close
set nowritebackup " disable temp backup before overwriting a file
set nojoinspaces " disable multiple spaces after joining lines ending with punctuation
set showcmd " show incomplete commands
set showmatch " show closing bracket when a bracket is inserted
set switchbuf=useopen " jump to buffer window
set wildmenu " emacs like tab completion
set wildmode=longest,list " bash like tab completion
" backspace
set backspace=indent,eol,start " allow backspace over everything in insert mode
" encoding
set encoding=utf-8 " ensure encoding is utf-8
set fileencoding=utf-8 " ensure files written as utf-8
" fix slow O inserts
set timeout
set timeoutlen=1000
set ttimeoutlen=100
" search
set incsearch " show live matches
set hlsearch " highlight all matches
" soft tabs
set expandtab " use spaces to insert tabs
set smarttab " tabs in front of a line inserts blanks according to shiftwidth
set shiftround " round indents to multiple of shiftwidth
set softtabstop=2 " number of spaces a tab counts for during editing
set shiftwidth=2 " number of spaces to use for each step of (auto) indent
set tabstop=2 " number of spaces a tab in the file counts for
" status line
set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
"
" Plugins
"
call plug#begin()
" Color
"Plug 'cocopon/iceberg.vim'
" General
Plug 'junegunn/vim-easy-align'
Plug 'preservim/nerdcommenter'
" Completion
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'ycm-core/YouCompleteMe', { 'do': 'python3 install.py --all' }
" Git
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" Golang
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Rust
Plug 'rust-lang/rust.vim'
" Toml
Plug 'cespare/vim-toml', { 'branch': 'main' }
" Typescript
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'jparise/vim-graphql'
" Formatters
Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
Plug 'vim-autoformat/vim-autoformat'
call plug#end()
"
" Configurations
"
" close buffer and keep the split
nnoremap <C-c> :bp\|bd #<CR>
" Autoformat
let g:formatdef_autopep8 = "'autopep8 - --max-line-length 120 --range '.a:firstline.' '.a:lastline"
let g:formatters_python = ['autopep8']
au BufWrite *py :Autoformat
" Easy Align
xmap <leader>a <Plug>(EasyAlign)
nmap <leader>a <Plug>(EasyAlign)
" FZF
nnoremap <silent> <C-p> :GFiles<CR>
nnoremap <silent> <Leader>f :Ag -g<CR>
nnoremap <silent> <Leader>b :Buffers<CR>
" Fugitive
nnoremap <Leader>ga :Git add %:p<CR><CR>
nnoremap <Leader>gt :Git commit -S -v -q %:p<CR>
" Prettier
let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0
" NERDCommenter
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:NERDSpaceDelims = 1
" YCM
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
nnoremap <leader>yjd :YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap <silent> <leader>yrr <cmd>execute 'YcmCompleter RefactorRename' input( 'Rename to: ' )<CR>
"
" Utils
"
augroup myvimrc
au!
au BufWritePost .vimrc source $MYVIMRC | if has('gui_running') | source $MYGVIMRC | endif
augroup END