-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
273 lines (223 loc) · 6.91 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
" VimPlug plugin manager
" Call :PlugInstall to run
call plug#begin('~/.config/nvim/plugged')
Plug 'ntpeters/vim-better-whitespace'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-speeddating'
Plug 'scrooloose/nerdtree'
Plug 'w0rp/ale'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'kassio/neoterm'
Plug 'neoclide/coc.nvim', {'tag': '*', 'do': { -> coc#util#install()}}
" Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
" Plug 'sebdah/vim-delve'
Plug 'jiangmiao/auto-pairs'
Plug 'vimwiki/vimwiki'
Plug 'arcticicestudio/nord-vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'ianks/vim-tsx', {'for': 'typescript.tsx'}
Plug 'mhartington/nvim-typescript', {'do': './install.sh'}
Plug 'Valloric/ListToggle'
Plug 'chaoren/vim-wordmotion'
Plug 'tpope/vim-projectionist'
Plug 'kshenoy/vim-signature'
Plug 'mattn/emmet-vim'
Plug 'majutsushi/tagbar'
Plug 'junegunn/goyo.vim'
call plug#end()
" Enable syntax highlighting
syntax on
" Recognize filetypes, indent and load plugins accordingly
filetype plugin indent on
" Set Omni-completion
set nocompatible
" Set color
colorscheme gotham256
" Map space as leader
let mapleader = "\<Space>"
" Better command-line completion
set wildmenu
" Highlight searches
set hlsearch
" Use case insensitive searches except when using capital letters
set ignorecase
set smartcase
" Keep the same indent as the line you're currently on
set autoindent
" Always display the the status line
set laststatus=2
" Instead of failing command because of unsaved files, instead ask if I want
" to save files
set confirm
" Enable use of mouse for all modes
" Turned it off to be able to use urxvt+tmux+vim clipboard
" set mouse=a
" Set command window height to 2 lines
set cmdheight=1
" Display line numbers
set number
" Fix backspace issue (won't delete line breaks)
set backspace=indent,eol,start
" Change column color
set colorcolumn=110
" Default indentation rules
" Expand tab makes tab key insert spaces
set expandtab
"set ts=2
set shiftwidth=2
set softtabstop=2
set ai
set si
" Map arrow keys to text shifting
nmap <Left> <<
nmap <Right> >>
vmap <Left> <gv
vmap <Right> >gv
nmap <Up> [e
nmap <Down> ]e
vmap <Up> [egv
vmap <Down> ]egv
" Splits
nnoremap <leader>v <C-w>v<C-w>l
nnoremap <leader>s <C-w>s<C-w>j
nnoremap <leader>c <C-w>c
nnoremap <C-Left> <C-w>h
nnoremap <C-Right> <C-w>l
nnoremap <C-Up> <C-w>k
nnoremap <C-Down> <C-w>j
" Comments
nmap <C-_> gcc
vmap <C-_> gc
" Use real lines
map j gj
map k gk
" Autocomplete case sensitive
set infercase
" Strip whitespace on save
autocmd BufWritePre * StripWhitespace
set incsearch
" Instant searching
" Set path
set path=.,**
" Set numbers relative
set relativenumber
" Folding
set foldmethod=indent
set foldlevelstart=20
" Highlight current line
set cursorline
" NerdTree
"https://stackoverflow.com/questions/33465357/one-mapping-to-toggle-nerdtree-and-open-to-current-file-when-toggling-on
nnoremap <silent> <expr> <C-n> g:NERDTree.IsOpen() ? "\:NERDTreeClose<CR>" : bufexists(expand('%')) ? "\:NERDTreeFind<CR>" : "\:NERDTree<CR>"
" Typescript support
autocmd BufRead,BufNewFile *.tsx set ft=typescript
let g:nvim_typescript#diagnostics_enable = 0
let g:typescript_compiler_options = "--lib esnext --lib dom --jsx react"
" clear highlights
nnoremap <silent> <C-c> :noh<cr>
" Airline
let g:airline_skip_empty_sections = 1
let g:airline_powerline_fonts = 1
let g:airline_theme='luna'
let g:airline_section_b=''
let g:airline_section_x=''
let g:airline_section_y=''
let g:airline_section_z=''
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_tab_count = 0
let g:airline#extensions#tabline#exclude_preview = 0
let g:airline#extensions#tabline#show_tab_type = 0
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#tab_min_count = 2
let g:airline#extensions#tabline#buffer_min_count = 2
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#tab_nr_type = 1
let g:airline#extensions#tabline#show_splits = 0
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
" Closing error windows before creating new windows
autocmd WinEnter * if winnr('$') > 1|lclose|endif
" Neoterm
tnoremap <Esc> <C-\><C-n>
let g:neoterm_autojump = 1
let g:neoterm_default_mod = 'rightbelow'
nnoremap <silent> <f10> :TREPLSendFile<cr>
nnoremap <silent> <f9> :TREPLSendLine<cr>
vnoremap <silent> <f9> :TREPLSendSelection<cr>
" open terminal
nnoremap <silent> <leader>t :Ttoggle<cr><C-w>j
" hide/close terminal
nnoremap <silent> <leader>h :Tclose<cr>
" kills the current job (send a <c-c>)
nnoremap <silent> <leader>k :Tkill<cr>
" Quickfix tools (taken from vim-go tutorial)
" let g:go_list_type = \"quickfix"
" map <C-k> :cnext<CR>
" map <C-m> :cprevious<CR>
" nnoremap <leader>a :cclose<CR>
" vim-go tutorial suggestions
" set autowrite " Writes content of file when calling ':make'
" autocmd FileType go nmap <leader>b <Plug>(go-build)
" autocmd FileType go nmap <leader>r <Plug>(go-run)
" let g:go_highlight_types = 1
" let g:go_highlight_fields = 1
" let g:go_highlight_functions = 1
" let g:go_highlight_methods = 1
" let g:go_highlight_operators = 1
" let g:go_highlight_extra_types = 1
" autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
" let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
" let g:go_metalinter_autosave = 1
" ZoomWin replacement
map <silent> <leader>f :tab split<cr>
" Toggle tmux status line off
autocmd VimEnter,VimLeave * silent !tmux set status
" Auto loaded (no idea by who)
let g:python_host_prog = '/usr/bin/python'
" Vimwiki
:map >> <Plug>VimwikiIncreaseLvlSingleItem
:map >>> <Plug>VimwikiIncreaseLvlWholeItem
" Ale
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
let g:ale_fixers = {'typescript': ['prettier', 'tslint']}
let g:ale_fix_on_save = 1
let g:ale_list_window_size = 5
let g:ale_lint_on_enter = 1
" fzf
nnoremap <silent> <C-p> :GFiles<CR>
nnoremap <silent> <C-h> :History<CR>
nnoremap <C-f> :Ag<CR>
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%'),<bang>0)
command! -bang -nargs=* GFiles
\ call fzf#vim#gitfiles(<q-args>,fzf#vim#with_preview('right:50%'),<bang>0)
" Projectionist
nnoremap <leader>a :AV<CR>
" Show buffer list
" nnoremap <leader>\ :ls<CR>:b<space>
nnoremap <leader>\ :bd<CR>
" Disable annoying ex mode
map q: <Nop>
nnoremap Q <nop>
" Newtab
nnoremap <leader>n :tabedit<CR>
" Clipboard copy
vnoremap <C-c> "+y
" coc.nvim
nnoremap <C-T> :CocList symbols<CR>
nnoremap <C-Y> :CocList yank<CR>