-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
302 lines (256 loc) · 8.71 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
if !has('nvim')
set nocompatible
filetype off
endif
" https://github.com/junegunn/vim-plug
if has('nvim')
call plug#begin('~/.local/share/nvim/plugged')
else
call plug#begin()
endif
if !has('ide')
" save sessions between restarts ############
if has('nvim')
Plug 'thaerkh/vim-workspace'
let g:workspace_autocreate = 1
let g:workspace_session_directory = $HOME . '/.local/share/nvim/sessions/'
let g:workspace_undodir = $HOME . '/.local/share/nvim/undo/'
" else
" let g:workspace_session_directory = $HOME . '/.vim/sessions/'
" let g:workspace_undodir = $HOME . '/.vim/undo/'
endif
" " when workspace plugin doesn't work
" if has('persistent_undo')
" set undofile
" if has('nvim')
" set undodir=$HOME/.local/share/nvim/undo/
" else
" set undodir=$HOME/.vim/undo/
" endif
" endif
" ###########################################
" display marks on the left #################
Plug 'kshenoy/vim-signature'
" ###########################################
" # ##### Rrun python in buffer ###############
Plug 'thinca/vim-quickrun'
let g:quickrun_config = {
\'*': {
\'outputter/buffer/split': ':rightbelow vsplit'},}
nnoremap <silent> <F5> :w<CR> :QuickRun python3<CR>
vnoremap <silent> <F5> :w<CR> :QuickRun python3<CR>
" ###############################################
" Ipython for vim ###########################
Plug 'jpalardy/vim-slime', { 'for': 'python' }
Plug 'hanschen/vim-ipython-cell', { 'for': 'python' }
" let g:ipython_cell_delimit_cells_by = 'marks'
let g:ipython_cell_delimit_cells_by = 'tags'
let g:slime_target = 'neovim'
let g:slime_dont_ask_default = 1
function! IPythonOpen()
" open a new terminal in vertical split and run IPython
vnew|call termopen('ipython --matplotlib')
file ipython " name the new buffer
" set slime target to new terminal
if !exists('g:slime_default_config')
let g:slime_default_config = {}
end
let g:slime_default_config['jobid'] = b:terminal_job_id
wincmd p " switch to the previous buffer
endfunction
" ###########################################
if has('nvim')
" CoC ###########################################
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Recently vim can merge signcolumn and number column into one
if has("patch-8.1.1564")
set signcolumn=number
else
set signcolumn=yes
endif
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocActionAsync('doHover')
endif
endfunction
nmap <leader>rn <Plug>(coc-rename)
" ####################################################
endif
" Tabline ###########################################
Plug 'pacha/vem-tabline'
let g:vem_tabline_show = 2
let g:vem_tabline_show_number = 'buffnr'
nmap <C-PageDown> <Plug>vem_next_buffer-
nmap <C-PageUp> <Plug>vem_prev_buffer-
" ####################################################
" ############ run current files in terminal #######################
Plug 'erietz/vim-terminator'
let g:terminator_clear_default_mappings="nothing"
nnoremap <silent> <F5> :TerminatorRunFileInOutputBuffer <CR>
nnoremap <silent> <F6> :TerminatorStopRun <CR>
nnoremap <silent> <F8> :TerminatorRunFileInTerminal <CR>
" #################################################################################
endif
" ############ SMALLER PLUGINS #######################
Plug 'psf/black', {'branch': 'main'}
let g:black_linelength = 100
Plug 'sheerun/vim-polyglot'
Plug 'dhruvasagar/vim-table-mode' " auto table formatting
let g:table_mode_corner='|'
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
nnoremap <C-_> gcc
vnoremap <C-_> gcc
Plug 'tpope/vim-fugitive'
Plug 'romainl/vim-cool' "disable search highlight with movement
Plug 'fridgelord/split-term.vim'
let g:split_term_height = 10
" ####################################################
" ############ UNUSED PLUGINS #######################
" Plug 'moll/vim-bbye'
" Plug 'ActivityWatch/aw-watcher-vim' " for time tracker
" semantic highlighting for Python in Neovim
" Plug 'numirias/semshi'
" ####################################################
call plug#end()
set ignorecase " ignore case
set smartcase " but don't ignore it, when search string contains uppercase letters
if !has('ide')
nnoremap <C-n> :tabedit %<CR>
inoremap <C-n> :tabedit %<CR>
endif
inoremap <A-1> 1gt
inoremap <A-2> 2gt
inoremap <A-3> 3gt
inoremap <A-4> 4gt
inoremap <A-5> 5gt
inoremap <A-6> 6gt
inoremap <A-7> 7gt
inoremap <A-8> 8gt
inoremap <A-9> 9gt
nnoremap <A-1> 1gt
nnoremap <A-2> 2gt
nnoremap <A-3> 3gt
nnoremap <A-4> 4gt
nnoremap <A-5> 5gt
nnoremap <A-6> 6gt
nnoremap <A-7> 7gt
nnoremap <A-8> 8gt
nnoremap <A-9> 9gt
nnoremap ; :
cmap Q quit
" ctrl+v pastes from + register in insert mode
inoremap <c-v> <esc>:set paste<cr>a<c-r>=getreg('+')<cr><esc>:set nopaste<cr>mi`[=`]`ia
if has('ide')
inoremap <c-v> <esc>:set paste<cr>a<c-r>*<cr><esc>:set nopaste<cr>mi`[=`]`ia
endif
" search & replace word under cursor
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>
" C-r doesn't work in ideavim using another solution
if has('ide')
:nnoremap <Leader>s * :%s///g<Left><Left>
endif
" remove search highlighting on esc - when not using romainl's plugin
nnoremap <silent> <Esc> :noh<cr>
" map brackets and gn/gp for diffview to move to prev/next diff
" if &diff
" map gn ]c
" ap gp [c
" map ] ]c
" map [ [c
" endif
" Enable folding
set foldmethod=indent
set foldlevel=99
" Enable folding with the spacebar
nnoremap <space> za
" au BufNewFile,BufRead *.py;
" \ set tabstop=4
" \ set softtabstop=4
" \ set shiftwidth=4
" \ set textwidth=79
" \ set expandtab
" \ set autoindent
" \ set fileformat=unix
set encoding=utf-8
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set nobackup " DON'T keep a backup file
set nowritebackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set hls
set rdt=3000
set number relativenumber " line numbers relative
set cindent " guess what indent should be used (c-like)
set autoindent " cp indent from previous line
set mouse=a " use mouse in xterm
set ignorecase " ignore case
set smartcase " but don't ignore it, when search string contains uppercase letters
set hid " allow switching buffers, which have unsaved changes
set showmatch " showmatch: Show the matching bracket for the last ')'?
set nowrap " don't wrap by def
set formatoptions=1 " prevent edited lines from breaking
set nolinebreak " if wrapping do so only on whitespace
syntax on
set confirm " ask on quit
set clipboard=unnamedplus " on linux it's ctrl-c clipboard on, on win it doesn't matter
set laststatus=2 " always dispaly status line
set wildignorecase
set completeopt=menu,longest,preview
set splitbelow " open new split below current
set splitright " open new split to the right
set statusline=%{FugitiveStatusline()}%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P "char code in statusline + fugitive
set cursorline
set scrolloff=10
" webcode
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2
\ set softtabstop=2
\ set shiftwidth=2
augroup Markdown
autocmd!
autocmd FileType markdown setlocal wrap
autocmd FileType markdown setlocal linebreak
autocmd FileType markdown setlocal spell
autocmd FileType markdown setlocal spelllang=en,pl
augroup END
" important only in case of leader change or maping to esc
" set timeoutlen=1000
" set ttimeoutlen=10
" imap jj <Esc>
let g:gruvbox_italic = 1
colorscheme gruvbox
set bg=dark
" replace previous spell error with first suggestion in insert
imap <c-l> <c-g>u<Esc>[s1z=`]a<c-g>u
" don't overwrite the register when replacing selected text
vnoremap p "_dp
vnoremap P "_dP
if has('ide')
set ideajoin=true
set lookupkeys="<Tab>"
" plug surround does not work properly (ds" not working for example)
set surround
endif