-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
290 lines (251 loc) · 8.32 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
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin ("~/.config/nvim/plugged")
Plug 'dracula/vim'
Plug 'joshdick/onedark.vim'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'dikiaap/minimalist'
Plug 'tyrannicaltoucan/vim-quantum'
Plug 'morhetz/gruvbox'
Plug 'sainnhe/sonokai'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
Plug 'arcticicestudio/nord-vim'
Plug 'hzchirs/vim-material'
Plug 'preservim/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'scrooloose/nerdcommenter'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'godlygeek/tabular' " needed for vim-markdown
Plug 'plasticboy/vim-markdown'
Plug 'junegunn/goyo.vim'
Plug 'suan/vim-instant-markdown'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
"Plug 'cloudhead/neovim-fuzzy'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
let g:coc_global_extensions = ['coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-tsserver', 'coc-eslint', 'coc-rls']
" Plug 'prettier/vim-prettier', {
" \ 'do': 'yarn install',
" \ 'branch': 'release/0.x'
" \ }
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'elzr/vim-json'
Plug 'mxw/vim-jsx'
Plug 'posva/vim-vue'
Plug 'pangloss/vim-javascript'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'tveskag/nvim-blame-line'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'romainl/vim-cool'
Plug 'mattn/emmet-vim'
Plug 'machakann/vim-highlightedyank'
" TEST FEATURE
call plug#end()
" General settings
set termguicolors
let g:quantum_black=1
let g:quantum_italics=1
colorscheme nord
set number
set nu relativenumber
set clipboard=unnamedplus
set cursorline
set guioptions+=a
set nowrap
syntax enable
set laststatus=2 " show the satus line all the time
set ttyfast " for faster redrawing
set diffopt+=vertical " for faster redrawing
set nosol " to prevent cursor from jumping to the start of the line while switching buffers
set autoread " to reload the files i.e. when the git branch is changed
set timeoutlen=1000 ttimeoutlen=0 "To avoid typing characters after pressing escape
set showtabline=2 "always show tabline
hi Normal guibg=NONE ctermbg=NONE
" hi CursorLine guibg=#333111
" hi CursorColumn guibg=#333111
" hi CursorLineNR guibg=#333111
" hi Search guibg=#eeeeee
" hi CocErrorFloat guifg=#eeeeee
map <Esc> :noh <CR>
set tabstop=4 " number of visual spaces per tab
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4
set smarttab
nnoremap Y y$
noremap H ^
noremap L $
set ignorecase
set hlsearch
set scrolloff=30
set shortmess+=c
set wrap
set linebreak
let g:AutoPairsShortcutToggle = ''
let &fcs='eob: ' " remove tildas
" Enable Italics
let &t_ZH = "\e[3m"
let &t_ZR = "\e[23m"
"NORD THEME
let g:nord_cursor_line_number_background = 0
let g:nord_uniform_status_lines = 1
let g:nord_bold_vertical_split_line = 1
let g:nord_uniform_diff_background = 1
let g:nord_italic = 1
let g:nord_italic_comments = 0
let g:nord_underline = 1
"Blameline settings
autocmd BufEnter * EnableBlameLine
let g:blameLineVirtualTextFormat = ' // %s'
"Prettier Settings
" let g:prettier#exec_cmd_async = 1 " Force asynchronous formatting
" let g:prettier#autoformat = 0 " Enable autoformatting
" let g:prettier#autoformat_require_pragma = 0 " Run on save even on files without @format tag
" autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
"Setting default vim directories so the swap files do not pollute the current
"folders
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//
"Buffer options
set hidden
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=500
set signcolumn=yes
highlight SignColumn guibg=#111
nnoremap <Space> :bn<CR>
nnoremap <C-Space> :bp<CR>
nnoremap qq :bp<bar>sp<bar>bn<bar>bd<CR>
" if (has("termguicolors"))
" set termguicolors
" endif
if &term =~# '256color' && ( &term =~# '^screen' || &term =~# '^tmux' )
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" Disable folding for markdown files
let g:vim_markdown_folding_disabled = 1
set t_Co=256
" COC options
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
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
inoremap <silent><expr> <c-space> coc#refresh()
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
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)
" 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
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" end of COC options
"Split options
set splitbelow
set splitright
nnoremap [[ 20<c-><
nnoremap ]] 20<c-w>>
nnoremap <c-[> 20<c-w>+
nnoremap <c-{> 20<c-w>+
noremap <C-l> <C-W>l
noremap <C-h> <C-W>h
" NERDTree
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
" let g:NERDTreeDirArrowExpandable = '?'
" let g:NERDTreeDirArrowCollapsible = '?'
let g:NERDTreeDirArrowExpandable = '‚ñ∏'
let g:NERDTreeDirArrowCollapsible = '‚ñæ'
" Automaticaly close nvim if NERDTree is only thing left open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nnoremap <silent> <C-n> :NERDTreeToggle<CR>
" open new split panes to right and below
set splitright
set splitbelow
" turn terminal to normal mode with escape
tnoremap <Esc> <C-\><C-n>
" start terminal in insert mode
au BufEnter * if &buftype == 'terminal' | :startinsert | endif
" open terminal on ctrl+t
function! OpenTerminal()
split term://bash
resize 10
endfunction
nnoremap <C-t> :call OpenTerminal()<CR>
" fuzzy find files in the working directory (where you launched Vim from)
let $FZF_DEFAULT_OPTS .= ' --no-height'
autocmd! FileType fzf tnoremap <buffer> <esc> <c-c>
command! -nargs=* W w
nnoremap <silent> ff :Files<cr>|
nnoremap <silent> fg :FuzzyGrep<cr>|
" Closing tags in react/jsx
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
let g:closetag_filenames = '*.html,*.xhtml,*.xml,*.js,*.html.erb,*.md'
autocmd BufNewFile,BufRead *.js set filetype=javascript.jsx
autocmd BufNewFile,BufRead *.ts set filetype=typescript
autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
"Airline fixes - shows name of the file instead of UTF8
let g:airline_section_y = ''
let g:airline_section_z = ''
let g:webdevicons_enable_airline_statusline_fileformat_symbols = 1
let g:airline_powerline_fonts = 1
let g:airline_section_warning = 0
let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#left_sep = ' '
" let g:airline#extensions#tabline#left_alt_sep = ' '
let g:airline_detect_paste=1
let g:airline#extensions#coc#enabled = 1
let g:airline_theme='minimalist'
let g:webdevicons_enable_airline_tabline = 0
"NERDCommenter setup
let g:NERDSpaceDelims = 1
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1
nmap <C-p> <Plug>NERDCommenterToggle <Esc>
vmap <C-p> <Plug>NERDCommenterToggle<CR>gv
let g:NERDCompactSexyComs = 1