-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
350 lines (270 loc) · 9.18 KB
/
init.vim
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
" vim plug
call plug#begin('~/.config/nvim/plugged')
"coc
Plug 'neoclide/coc.nvim', {'tag': '*', 'branch': 'release'}
"fzf
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
"lightline
Plug 'itchyny/lightline.vim'
Plug 'mengelbrecht/lightline-bufferline'
"dirvish
Plug 'justinmk/vim-dirvish'
"theme
Plug 'dracula/vim', { 'as': 'dracula' }
"tpope suite
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-vinegar'
"vim-polyglot
Plug 'sheerun/vim-polyglot'
Plug 'lumiliet/vim-twig'
"startify
Plug 'mhinz/vim-startify'
call plug#end()
"neovim defaults
if !has('nvim')
set nocompatible
syntax on
set autoindent
set autoread
set backspace=indent,eol,start
set belloff=all
set complete-=i
set display=lastline
set formatoptions=tcqj
set history=10000
set incsearch
set laststatus=2
set ruler
set sessionoptions-=options
set showcmd
set sidescroll=1
set smarttab
set ttimeoutlen=50
set ttyfast
set viminfo+=!
set wildmenu
endif
"------------myStandards-------------"
set autowriteall "Auto write the file when switching buffers.
set clipboard^=unnamedplus "use shared system clipboard
set cursorline "Highlight line under cursor. It helps with navigation
set expandtab "Insert spaces when TAB is pressed.
set formatoptions+=o "Continue comment marker in new lines.
set history=500 "Set how many lines of history nvim should remember
set ignorecase "Make searching case insensitive
set iskeyword+=- "Use dash as word separator
let mapleader = ',' "The default is \, but a comma is much better.
"Move between buffers with tab and shift-tab
nnoremap <silent> <tab> :if &modifiable && !&readonly && &modified <CR> :write<CR> :endif<CR>:bnext<CR>
nnoremap <silent> <s-tab> :if &modifiable && !&readonly && &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
"Auto center on matched string
noremap n nzz
noremap N Nzz
set nojoinspaces "prevents inserting two spaces after punctuation on a join (J)
set nomodeline "don't parse modelines
set noshowmode "don't show mode
set noswapfile "remove swap
set nowrap "no wrapping please, just a box
set number "Show the line numbers on the left side.
set path+=.,** "mah path
set relativenumber "relative numbers!
set showmatch "show matching brackets.
set shiftwidth=2 "1 tab == 2 spaces
set smartcase "unless the query has capital letters.
set showtabline=2
set tabstop=2 "1 tab == 2 spaces
set wildmode=longest,full "For autocompletion, complete as much as you can
"-------------Colorscheme--------------"
"set term gui colors if exist
if (has("termguicolors"))
set termguicolors
endif
"colorscheme edits to make my eyes not hurt
"augroup themeColors
"autocmd!
"autocmd ColorScheme * highlight Normal guibg=00000
"autocmd ColorScheme * highlight CursorLineNr guifg=fffff
"autocmd ColorScheme * highlight SignColumn guibg=00000
"autocmd ColorScheme * highlight LineNr guifg=000000 guibg=00000
"augroup END
"colorscheme
colorscheme dracula
"Nord Colorscheme
"let g:nord_cursor_line_number_background = 1
"let g:nord_uniform_diff_background = 1
"-------------Split Management--------------"
" More natural splits
set splitbelow "horizontal split below current.
set splitright "vertical split to right of current.
if !&scrolloff
set scrolloff=3 "show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 "show next 5 columns while side-scrolling.
endif
set nostartofline "do not jump to first character with page commands.
set list "show problematic characters.
"also highlight all tabs and trailing whitespace characters.
highlight ExtraWhitespace ctermbg=white guibg=darkgreen
match ExtraWhitespace /\s\+$\|\t/
"get rid of ugly split borders.
hi vertsplit guifg=bg guibg=bg
"open splits
nmap vs :vsplit<cr>
set splitbelow "Make splits default to below...
set splitright "And to the right. This feels more natural.
"we'll set simpler mappings to switch between splits.
nmap <C-J> <C-W><C-J>
nmap <C-K> <C-W><C-K>
nmap <C-H> <C-W><C-H>
nmap <C-L> <C-W><C-L>
"reize windows with plus and minus and window management a lot easier
if bufwinnr(1)
map > <C-W>5>
map < <C-W>5<
map = <C-W>=
endif
"-------------Mappings--------------"
"Make it easy to edit the Vimrc file.
nmap <Leader>ev :e $MYVIMRC<cr>
"Fast saves.
nmap <leader>ww :w!<cr>
"Fast saves and quits
nmap <leader>qq :wq!<cr>
"Easy escaping to normal mode
imap kj <esc>
inoremap <C-c> <esc>
"Add simple highlight removal.
nmap <Leader><space> :nohlsearch<cr>
"Open terminal window
nmap <leader>t :te zsh<cr>
"Remove mapping of up down left right keys
nmap <Up> <Nop>
nmap <Down> <Nop>
nmap <Left> <Nop>
nmap <Right> <Nop>
"Sort styles tags
nmap <leader>sv vi{ <bar> :sort<cr>
" Basic par completion
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
"-------------Plugins--------------"
"/
"/ coc
"/
let g:coc_global_extensions = ['coc-css', 'coc-html', 'coc-json', 'coc-prettier', 'coc-tsserver', 'coc-vetur']
command! -nargs=0 Prettier :call CocActionAsync('runCommand', 'prettier.formatFile')
nmap <leader>f :Prettier<CR>
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" 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
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
"/
"/ netrw
"/
nmap <leader>p :Vexplore<cr>
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 0
let g:netrw_altv = 1
let g:netrw_winsize = 25
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'
"/
"/lightline
"/
let g:lightline#bufferline#filename_modifier = ':t'
let g:lightline = {
\ 'colorscheme': 'dracula',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'currentfunction' ] ],
\ 'right': [ [ 'percent', 'lineinfo' ],
\ [ 'gitbranch'] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head',
\ 'cocstatus': 'coc#status',
\ 'currentfunction': 'CocCurrentFunction',
\ },
\ }
let g:lightline.tabline = {'left': [['buffers']], 'right': [['none']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type = {'buffers': 'tabsel'}
let s:palette = g:lightline#colorscheme#{g:lightline.colorscheme}#palette
let s:palette.normal.middle = [ [ 'NONE', 'NONE', 'NONE', 'NONE' ] ]
let s:palette.visual.middle = s:palette.normal.middle
let s:palette.insert.middle = s:palette.normal.middle
let s:palette.inactive.middle = s:palette.normal.middle
let s:palette.tabline.middle = s:palette.normal.middle
"Startify
let g:startify_custom_header = []
"/
"/fzf
"
nnoremap <C-p> :FZF<CR>
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\}
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -bang -nargs=* Find call fzf#vim#grep(
\'rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always"
\'.shellescape(<q-args>), 1, <bang>0)
"-------------Auto-Commands--------------"
"Automatically source the Vimrc file on save.
augroup autosourcing
autocmd!
autocmd BufWritePost ~/.config/nvim/init.vim source %
augroup END
" Automatically change the current directory
autocmd BufEnter * silent! lcd %:p:h
"Auto reload if file was changed somewhere else (for autoread)
au CursorHold * checktime
"-------------Notes and other stuff----------------"
" cs"' to replace " with '
" cs'<q> to change ' to <q></q>
" to remove ds"
" change a word ysiw<em>
" type :bp to see previous buffers
" type :ls to see list of buffers