-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
227 lines (181 loc) · 5.67 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
225
226
227
" Read custom after configuration
if filereadable($HOME . '/.vim/manual/before.vim')
source <sfile>:h/.vim/manual/before.vim
endif
" Python3 for neovim
" virtualenv -p python3 ~/venv/neovim
" . ~/venv/neovim/bin/activate
" pip install -U setuptools
" pip install neovim jedi
" or apt-get install python3-neovim
if empty($VIRTUAL_ENV)
let g:python3_host_prog = $HOME . '/venv/neovim/bin/python3' " Include default system config
else
let g:python3_host_prog = $VIRTUAL_ENV . '/bin/python3' " Include default system config
" FIXME: flake8 version is frozen due to multiple issues like:
" https://github.com/aleGpereira/flake8-mock/issues/10
call system($VIRTUAL_ENV . '/bin/pip install -U setuptools')
call system($VIRTUAL_ENV . '/bin/pip install neovim jedi mypy black flake8==4.0.1 python-lsp-server[all] pylint pynvim python-language-server[all] ruff-lsp')
endif
autocmd FileType go call system('GO111MODULE=on go get golang.org/x/tools/gopls')
if filereadable("/etc/vim/vimrc")
source /etc/vim/vimrc
endif
if filereadable($HOME . "/.vim/autoload/pathogen.vim")
execute pathogen#infect()
endif
set termguicolors
" Ctrl-C doesn't trigger InsertLeave event, so doesn't work well with LSP
inoremap <C-c> <Esc>
" Go to the previous open file with backspace
nnoremap <BS> <C-^>
" Disable go to tag on Ctrl+Click. Used to open links
nnoremap <C-LeftMouse> <Esc>
nnoremap <C-LeftMouse> <Esc>
" Set autoindent and key to disable it during paste
set autoindent
set pastetoggle=<F3>
" Set number of spaces to replace \t
set tabstop=4
set shiftwidth=4
set smarttab
if has("autocmd")
filetype plugin indent on
endif
" Autoreplace tab by default
set et
" Disable automatic visual mode on mouse select
" (breaks identation and other stuff)
" set mouse-=a
" set mouse=
set mouse=nv
" Show us the command we're typing
set showcmd
" More space for errors
set cmdheight=2
" Make autocomplete and other things more responsive
set updatetime=100
" Show line numbers
set number
" Preserve undo history https://neovim.io/doc/user/options.html#'undofile'
set undofile
" Try to show at least three lines and two columns of context when
" scrolling
set scrolloff=3
set sidescrolloff=2
" Use the cool tab complete menu
set wildmenu
set wildignore=*.o,*~,tmp/*,*.so,*.swp,*.zip,*.json,*.html,*.pb.go,*.pb.[a-z]*.go,*_pb2.py,*_pb2_grpc.py,plz-out/*
" Enable folds
" set foldenable
set foldcolumn=1
set foldlevel=99
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
" Autocompletion requires nopaste
set nopaste
" Enable ruler
set ruler
set et
" Save position in file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Use X clipboard
" set clipboard+=unnamed
" Search settings
set showmatch
set hlsearch
set incsearch
set ignorecase
" Don't jump to the next search item on *
nnoremap * *``
" Order of encondings application
set ffs=unix,dos,mac
set fencs=utf-8,cp1251,koi8-r,ucs-2,cp866
set encoding=UTF-8
" Enable syntax highlighting
syntax on
let python_highlight_all=1
" Necesary for lots of cool vim things
set nocompatible
" Enable reading config from file header
set modeline
set modelines=2
set backspace=indent,eol,start
set encoding=utf-8
set fileencoding=utf8
" Enable folding
" set foldmethod=indent
" set foldlevel=99
set conceallevel=2
" Disable annoying recording which I don't use anyway
map q <Nop>
" Remap leader
let mapleader = ","
"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Enable folding with the spacebar
nnoremap <space> za
if !empty(glob("~/.vim/bundle/Vundle.vim"))
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
call vundle#end()
filetype plugin indent on
endif
" Disable expandtab for Makefiles
autocmd FileType make set noexpandtab
" Set some filetypes
au BufNewFile,BufRead *.sls setf yaml
au BufNewFile,BufRead *.build_defs setf python
" Set yaml tab indentation to 2
au BufNewFile,BufRead *.js setl sw=2 sts=2 et
au BufNewFile,BufRead *.ts setl sw=2 sts=2 et
autocmd BufWritePost *.ts EslintFixAll
au BufNewFile,BufRead *.sls setl sw=2 sts=2 et
au BufNewFile,BufRead *.yaml setl sw=2 sts=2 et
au BufNewFile,BufRead *.yml setl sw=2 sts=2 et
au BufNewFile,BufRead *.php setl sw=2 sts=2 et
au BufNewFile,BufRead *.cpp setl sw=2 sts=2 et
au BufNewFile,BufRead *.lua setl sw=2 sts=2 et
au BufNewFile,BufRead *.go setl noet
au BufNewFile,BufRead tnsnames.ora setl sw=2 sts=2 et syn=lisp
" json
augroup json_autocmd
autocmd!
autocmd FileType json set formatoptions=tcq2l
autocmd FileType json set textwidth=78 shiftwidth=2
autocmd FileType json set softtabstop=2 tabstop=8
autocmd FileType json set expandtab
" autocmd FileType json set foldmethod=syntax
augroup END
" Extend copy buffer
set viminfo='20,<1000
" Increase the number of open tabs limit
set tabpagemax=999
" Close preview window when done with completions
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | silent! pclose | endif
" Default menu
" TODO: merge this into the lsp config
aunmenu PopUp
nmenu PopUp.LSP\ Definition gd
nmenu PopUp.LSP\ Type\ Definition <space>D
nmenu PopUp.LSP\ Peek\ Definition gp
nmenu PopUp.LSP\ Peek\ Type\ Definition gtp
nmenu PopUp.LSP\ Declaration gD
nmenu PopUp.LSP\ Rename <space>rn
nmenu PopUp.LSP\ References gr
nmenu PopUp.LSP\ Implementation gi
nmenu PopUp.LSP\ Find\ Symbol gf
nmenu PopUp.LSP\ Code\ Action <space>ca
nmenu PopUp.LSP\ Incoming\ Calls <leader>ci
nmenu PopUp.LSP\ Outgoing\ Calls <leader>co
" anoremenu PopUp.-1- <Nop>
" Read custom after configuration
if filereadable($HOME . '/.vim/manual/after.vim')
source <sfile>:h/.vim/manual/after.vim
endif