-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
369 lines (303 loc) · 9.57 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
" Starts vim in non-vi mode
set nocompatible
" Disable search highlighting
set nohlsearch
" Enable incremental search
set incsearch
" Ignore casing when searching unless..
set ignorecase
" Intentionally searches for upper letters
set smartcase
" set leader to space
nnoremap <SPACE> <Nop>
let mapleader=" "
filetype off
set noshowmode
" map Ctrl-K to Esc
imap <C-K> <Esc>
" allow system clipboard
" set clipboard=unnamedplus
" make Y yank cursor till end of line, matching D and C logic
nnoremap Y y$
" make backspace work like most other apps
set backspace=2
" shows horizontal and vertical line where the cursor is in the file
set cursorline cursorcolumn
" set linenumbers
set relativenumber
set number
" linebreaks after long line are indented correctly
set wrap
set breakindent
" sets character encoding
set encoding=utf8
" show syntax
syntax enable
" set magic regex matching
set magic
" disable creating of all sort of swapfiles
set nobackup
set nowb
set noswapfile
" i want to see at least x lines above/below the cursor
set scrolloff=10
set history=999
set showmatch
" shows number of columns and lines in powerbar
set ruler
" sets width for shifting with >> or << and tablength and converts tab to
" spaces
set smartindent
set shiftwidth=4
set tabstop=4
set expandtab
" default split below and right
set splitbelow
set splitright
" New autosuggest scroll/accept keybindings
inoremap <expr> <C-l> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<Up>"
" reoder tabs
nnoremap <silent> <Leader>t :tabmove +1<CR>
nnoremap <silent> <Leader>T :tabmove -1<CR>
" resize horizontal splits quicker
nnoremap <silent> <Leader>+ :resize +5<CR>
nnoremap <silent> <Leader>- :resize -5<CR>
" resize vertical splits quicker
nnoremap <silent> <Leader>> :vertical resize +5<CR>
nnoremap <silent> <Leader>< :vertical resize -5<CR>
" todo vsplit (below)/ hsplit (riht) shortcuts
:command Vtodo 20sp todos.md
:command Htodo 30vsp todos.md
" shortcuts to open/close todos
noremap <localleader>tv :Vtodo<CR>
noremap <localleader>th :Htodo<CR>
noremap <localleader>tc :bd todos.md<CR>
filetype plugin on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
" The bundles you install will be listed here
Plugin 'bling/vim-airline' " add improved statusbar
Plugin 'scrooloose/nerdtree' " file explorer in vim
Plugin 'ryanoasis/vim-devicons' " add icons to Nerdtree
Plugin 'christoomey/vim-sort-motion' " add sorting verb 'gs'
Plugin 'tpope/vim-commentary' " add commenting verb 'gc'
Plugin 'tpope/vim-fugitive' " Git support with ':Git (add|commit|...)'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround' " add predicate for surrounding 's'
Plugin 'tpope/vim-markdown' " markdown support
" Plugin 'christoomey/vim-system-copy' " copy/ paste to global system clipboard
" also adds 'cp' and 'cv' copy and paste verbs + 'cP'/'cV' to copy current
" line and paste system clipboard to next line
Plugin 'kana/vim-textobj-user'
Plugin 'rbonvall/vim-textobj-latex' " add textobj for latex
Plugin 'lervag/vimtex'
Plugin 'arcticicestudio/nord-vim'
Plugin 'skielbasa/vim-material-monokai'
Plugin 'sonph/onehalf', {'rtp': 'vim/'}
Plugin 'kristijanhusak/vim-hybrid-material'
Plugin 'vim-airline/vim-airline-themes'
" Writing focused plugins
Plugin 'preservim/vim-pencil'
Plugin 'preservim/vim-colors-pencil'
Plugin 'preservim/vim-lexical'
Plugin 'preservim/vim-litecorrect'
Plugin 'preservim/vim-textobj-sentence'
Plugin 'preservim/vim-textobj-quote'
Plugin 'junegunn/goyo.vim'
Plugin 'junegunn/limelight.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
" filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just
" :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" _______________________________________________________________________
" The rest of your config follows here
" enable filetype detection
filetype on
filetype plugin on
filetype indent on
" set colourscheme
set background=dark
set t_Co=256
"colorscheme molokai_dark
"colorscheme material-monokai
"colorscheme pencil
colorscheme nord
" __________________________________ PLUGIN SETTINGS ______________________________________
"=> Airline setup
" """"""""""""""""""""""""""""""
" " Always show the status line
set laststatus=2
" "let g:airline#extensions#tabline#enabled = 1
" fancy powerline fonts
let g:airline_powerline_fonts = 1
"let g:airline_theme='angr'
let g:airline_theme='nord'
"let g:airline_theme = 'pencil'
"let g:airline_left_sep = ''
"let g:airline_right_sep = ''
"disableing showing of trailing in current file
let g:airline#extensions#whitespace#show_message = 0
"include PencilMode in airline status
let g:airline_section_x = '%{PencilMode()}'
set guifont=MesloLGL\ Nerd\ Font\ 10
" testing rounded separators (extra-powerline-symbols):
let g:airline_left_sep = "\uE0B4"
let g:airline_right_sep = "\uE0B6"
" set the CN (column number) symbol:
let g:airline_section_z = airline#section#create(["\uE0A1" . '%{line(".")}' . "\uE0A3" . '%{col(".")}'])
" NERDTree setup
"""""""""""""""""""""""""""""
" toggle NerdTree
map <F2> :NERDTreeToggle<CR>
" Start NERDTree when Vim starts with a directory argument.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
" Toggle Prose Mode
"""""""""""""""""""""""""""""
let w:ProseModeOn = 0
function EnableProseMode()
setlocal spell spelllang=en_gb
SoftPencil
" Goyo 60
" Limelight
echo "Prose Mode On"
endfu
function DisableProseMode()
NoPencil
" Goyo!
" Limelight!
setlocal nospell
echo "Prose Mode Off"
endfu
function ToggleProseMode()
if w:ProseModeOn == 0
call EnableProseMode()
let w:ProseModeOn = 1
else
call DisableProseMode()
endif
endfu
command Prose call EnableProseMode()
command UnProse call DisableProseMode()
command ToggleProse call ToggleProseMode()
" Pencil setup
"""""""""""""""""""""""""""""
let g:pencil#wrapModeDefault = 'soft' " default is 'hard'
let g:pencil#textwidth = 74 " default width of textlines
let g:pencil#mode_indicators = {'hard': 'H', 'auto': 'A', 'soft': 'S', 'off': '',}
" format current paragraph
nnoremap <leader>q gqap
augroup pencil
autocmd!
autocmd FileType markdown,mkd call pencil#init()
" autocmd FileType text call pencil#init({'wrap': 'hard'})
augroup END
" Lexical setup
""""""""""""""""""""""""""""""
augroup lexical
autocmd!
autocmd FileType markdown,mkd call lexical#init()
" autocmd FileType textile call lexical#init()
" autocmd FileType text call lexical#init({ 'spell': 0 })
augroup END
let g:lexical#spelllang = ['en_gb']
let g:lexical#thesaurus = ['~/.vim/thesaurus/mthesaur.txt',]
let g:lexical#spell_key = '<leader>s'
let g:lexical#thesaurus_key = '<leader>t'
" Goyo setup
"""""""""""""""""""""""""""""
function! s:goyo_enter()
set noshowcmd
set scrolloff=999
" Limelight
endfunction
function! s:goyo_leave()
set showcmd
set scrolloff=10
" Limelight!
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
function! s:auto_goyo()
if &ft == 'markdown'
Goyo 80
elseif exists('#goyo')
let bufnr = bufnr('%')
Goyo!
execute 'b '.bufnr
endif
endfunction
" augroup goyo_markdown
" autocmd!
" autocmd BufNewFile,BufRead * call s:auto_goyo()
" augroup END
" Limelight setup
"""""""""""""""""""""""""""""
" Color name (:help cterm-colors) or ANSI code
let g:limelight_conceal_ctermfg = '240'
" Color name (:help gui-colors) or RGB color
let g:limelight_conceal_guifg = '#3B4252'
" Default: 0.5
let g:limelight_default_coefficient = 0.7
" Number of preceding/following paragraphs to include (default: 0)
let g:limelight_paragraph_span = 0
" Vim Textobj sentence setup
"""""""""""""""""""""""""""""
augroup textobj_sentence
autocmd!
autocmd FileType markdown call textobj#sentence#init()
autocmd FileType textile call textobj#sentence#init()
augroup END
" go to end of current sentence: g)
" go to end of previous sentence: g(
" Vim Textobj quote setuo
"""""""""""""""""""""""""""""
augroup textobj_quote
autocmd!
autocmd FileType markdown call textobj#quote#init()
autocmd FileType textile call textobj#quote#init()
autocmd FileType text call textobj#quote#init({'educate': 0})
augroup END
let g:textobj#quote#doubleMotion = 'q'
let g:textobj#quote#singleMotion = 'Q'
" Vim litecorrect
"""""""""""""""""""""""""""""
augroup litecorrect
autocmd!
autocmd FileType markdown,mkd call litecorrect#init()
autocmd FileType textile call litecorrect#init()
augroup END
" Vim Tex
"""""""""""""""""""""""""""""
let g:vimtex_quickfix_mode = 0
let g:vimtex_view_method = 'zathura'
" Close viewers when VimTeX buffers are closed
function! CloseViewers()
if executable('xdotool')
\ && exists('b:vimtex.viewer.xwin_id')
\ && b:vimtex.viewer.xwin_id > 0
call system('xdotool windowclose '. b:vimtex.viewer.xwin_id)
endif
endfunction
augroup vimtex_event_2
au!
au User VimtexEventQuit call CloseViewers()
augroup END