Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
224 lines (216 loc) · 6.88 KB
/
Copy pathvimrc
File metadata and controls
224 lines (216 loc) · 6.88 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
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
"----------PATHOGEN-
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
syntax on
filetype plugin indent on
set background=dark
colorscheme solarized
" avoid tmux|screen transparency issues
set t_Co=256
" ------------GENERAL-
" add mouse support
set mouse=a
" set clipboard
set clipboard=unnamedplus
" use utf8 as default
set encoding=utf-8
" delete recursively with netrw
let g:netrw_localrmdir="rm -r"
" tab spacing settings
set tabstop=4 softtabstop=4 shiftwidth=4 smarttab expandtab
" activating line numbers
set number
" avoiding E21: Cannot make changes, 'Modifiable' is off
set modifiable
" no warning sounds
set noerrorbells visualbell t_vb=
" autocomplete in current buffer, windows, buffers, closed buffers
set complete=.,w,b,u
" putting all swap and backup files on a specific folder
set dir=$HOME/.vim/swp/
set bdir=$HOME/.vim/bkp/
" criar diretórios se não existirem
if !isdirectory($HOME . '/.vim/swp')
call mkdir($HOME . '/.vim/swp', 'p', 0700)
endif
if !isdirectory($HOME . '/.vim/bkp')
call mkdir($HOME . '/.vim/bkp', 'p', 0700)
endif
" undo persistente
if has('persistent_undo')
set undofile
set undodir=$HOME/.vim/undo/
if !isdirectory(&undodir)
call mkdir(&undodir, 'p', 0700)
endif
endif
" automatically re-read file changed outside vim
set autoread
" look for tags in custom locations
set tags+=.git/tags,tags,$HOME/.vim/tags/eosio.tags
" when searching a word, highlight it
set hlsearch
" highlight a searching word as you type it
set incsearch
" ignore case if pattern is all lower case
set ignorecase
set smartcase
" hidden buffers
set hidden
" setting default <Leader> as a comma
let mapleader=' '
" showing trailing spaces
set list listchars=tab:\~\ ,trail:~
" http://got-ravings.blogspot.com.br/2008/08/vim-pr0n-making-statuslines-that-own.html
set statusline=%{expand('%:h')}/%t\ [%{strlen(&fenc)?&fenc:'none'},%{&ff}]\ %h%m%r%y%=%c,%l/%L\ %P
" always display statusline
set laststatus=2
set termguicolors
" performance improvements
set lazyredraw
set ttyfast
set synmaxcol=200
" navigation improvements
set scrolloff=8
set sidescrolloff=8
" wildmenu improvements
set wildmenu
set wildmode=longest:full,full
set wildignore+=*.o,*.obj,*.pyc,*.swp,*.bak,*.class,*/.git/*,*/node_modules/*
" split behavior
set splitbelow
set splitright
" timeout settings
set timeoutlen=500
set ttimeoutlen=10
" text formatting
set textwidth=0
set wrap
set linebreak
set breakindent
" security
set nomodeline
set secure
augroup abi
au!
autocmd BufNewFile,BufRead *.abi set filetype=json
augroup END
augroup AutoFormat
autocmd!
autocmd BufWritePost *.js AsyncRun -post=checktime ./node_modules/.bin/eslint --fix %
augroup END
augroup checktime
autocmd!
autocmd FocusGained,BufEnter * checktime
augroup END
"------------MAPPINGS-
nnoremap - :Ex<CR>
nnoremap 50 <C-W>=
nnoremap <C-w><C-t> :tabe<CR>
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <Leader>st :tabe $MYVIMRC<CR>
nnoremap <Leader>sz :source $MYVIMRC<CR>
nnoremap <Leader><Space> :nohlsearch<CR>
nnoremap <Leader>Q :qa<CR>
nnoremap <Leader>W :w !sudo tee % >/dev/null<CR>:e!<CR>
nnoremap <Leader>h :vertical resize +5<CR>
nnoremap <Leader>j :resize -5<CR>
nnoremap <Leader>k :resize +5<CR>
nnoremap <Leader>l :vertical resize -5<CR>
nnoremap <Leader>rs :source ~/.vim/sessions/
nnoremap <Leader>ss :mksession! ~/.vim/sessions/
nnoremap <Leader>w :w<CR>
nnoremap P :pu<CR>
nnoremap Y y$
" melhor indentação em modo visual
vnoremap < <gv
vnoremap > >gv
" centralizar ao buscar
nnoremap n nzzzv
nnoremap N Nzzzv
" mover linhas selecionadas
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" quickfix navigation
nnoremap <C-n> :cnext<CR>
nnoremap <C-p> :cprev<CR>
" Use | and _ to split windows (while preserving original behaviour of [count]bar and [count]_).
nnoremap <expr><silent> <Bar> v:count == 0 ? "<C-W>v<C-W><Right>" : ":<C-U>normal! 0".v:count."<Bar><CR>"
nnoremap <expr><silent> _ v:count == 0 ? "<C-W>s<C-W><Down>" : ":<C-U>normal! ".v:count."_<CR>"
" remove trailing spaces
nnoremap <silent> <Leader>fws :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86
cnoremap <expr> <CR> CCR()
" tab cfg switch
nnoremap <Leader>chtaa :set tabstop=8 softtabstop=8 shiftwidth=8 nosmarttab noexpandtab<CR>
nnoremap <Leader>chtab :set tabstop=4 softtabstop=4 shiftwidth=4 smarttab expandtab<CR>
"------------FUNCTIONS-
" make list-like commands more intuitive
function! CCR()
let cmdline = getcmdline()
if cmdline =~ '\v\C^(ls|files|buffers)'
" like :ls but prompts for a buffer command
return "\<CR>:b"
elseif cmdline =~ '\v\C/(#|nu|num|numb|numbe|number)$'
" like :g//# but prompts for a command
return "\<CR>:"
elseif cmdline =~ '\v\C^(dli|il)'
" like :dlist or :ilist but prompts for a count for :djump or :ijump
return "\<CR>:" . cmdline[0] . "j " . split(cmdline, " ")[1] . "\<S-Left>\<Left>"
elseif cmdline =~ '\v\C^(cli|lli)'
" like :clist or :llist but prompts for an error/location number
return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>"
elseif cmdline =~ '\C^old'
" like :oldfiles but prompts for an old file to edit
set nomore
return "\<CR>:sil se more|e #<"
elseif cmdline =~ '\C^changes'
" like :changes but prompts for a change to jump to
set nomore
return "\<CR>:sil se more|norm! g;\<S-Left>"
elseif cmdline =~ '\C^ju'
" like :jumps but prompts for a position to jump to
set nomore
return "\<CR>:sil se more|norm! \<C-o>\<S-Left>"
elseif cmdline =~ '\C^marks'
" like :marks but prompts for a mark to jump to
return "\<CR>:norm! `"
elseif cmdline =~ '\C^undol'
" like :undolist but prompts for a change to undo
return "\<CR>:u "
else
return "\<CR>"
endif
endfunction
"------------GNUPG-
" tell the GnuPG plugin to armor new files.
let g:GPGPreferArmor=1
augroup GnuPGExtra
" set extra file options.
autocmd BufReadCmd,FileReadCmd *.\(gpg\|asc\|pgp\) call SetGPGOptions()
" automatically close unmodified files after inactivity.
autocmd CursorHold *.\(gpg\|asc\|pgp\) quit
augroup END
function! SetGPGOptions()
" set updatetime to 1 minute.
set updatetime=60000
" fold at markers.
set foldmethod=marker
" automatically close all folds.
set foldclose=all
" only open folds with insert commands.
set foldopen=insert
endfunction
"---------------ALE-
let g:airline#extensions#ale#enabled = 1
let g:ale_c_parse_compile_commands=1
let g:ale_linters = {'cpp': ['clang']}
let g:ale_cpp_clang_executable = "/usr/local/eosio.cdt/bin/clang-7"
let g:ale_cpp_clang_options = "-std=c++14 -ferror-limit=0 -I/usr/local/eosio.cdt/include -I/usr/local/eosio.cdt/include/libcxx -I/usr/local/eosio.cdt/include/libc"
let g:ale_linters_explicit = 1
"---------------TERRAFORM-
let g:terraform_align=1
let g:terraform_fold_sections=1