-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
341 lines (257 loc) · 7.96 KB
/
Copy pathinit.vim
File metadata and controls
341 lines (257 loc) · 7.96 KB
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
" Declarations
let mapleader=" " "space
let vim_plug_just_installed = 0
let vim_plug_path = expand('~/.config/nvim/autoload/plug.vim')
" NERDTree options
let g:NERDTreeWinPos = "right"
let g:signify_vcs_list = [ 'git', 'hg' ]
" Airline ------------------------------
let g:airline_powerline_fonts = 1
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_skip_empty_sections = 1
" Airline symbols
let g:airline_left_sep = "\uE0C0"
let g:airline_right_sep = "\uE0C2"
let g:airline_symbols = {}
let g:airline_symbols.linenr = ''
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" Airline theme
let g:airline_solarized_bg='dark'
let g:airline_theme='molokai'
" vim-ident-guides
let g:indent_guides_enable_on_vim_startup = 1
" Dart default settings
let dart_format_on_save = 1
let dart_style_guide = 2
let g:lsc_server_commands = {'dart': 'dart_language_server'}
let dart_html_in_string=v:
" Vim-plug initialization
if !filereadable(vim_plug_path)
echo "Installing Vim-plug..."
echo ""
silent !mkdir -p ~/.config/nvim/autoload
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let vim_plug_just_installed = 1
endif
if vim_plug_just_installed
:execute 'source '.fnameescape(vim_plug_path)
endif
call plug#begin('~/.config/nvim/plugged')
"ctrlp
let g:ctrlp_working_path_mode = 0
set runtimepath^=~/.config/nvim/plugged/ctrlp/ctrlp.vim
" Code commenter
Plug 'scrooloose/nerdcommenter'
" Better file browser
Plug 'scrooloose/nerdtree'
" Search results counter
Plug 'vim-scripts/IndexedSearch'
" Airline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Paint css colors with the real color
Plug 'lilydjwg/colorizer'
" Highlight matching html tags
Plug 'valloric/MatchTagAlways'
" Git integration
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" Git/mercurial/others diff icons on the side of the file lines
Plug 'mhinz/vim-signify'
" Color scheme
Plug 'nanotech/jellybeans.vim'
" Visually displaying indent levels in code
Plug 'Yggdroot/indentLine'
"enable repeating supported plugin maps with '.'
Plug 'tpope/vim-repeat'
" Highlight briefly every yank text
Plug 'machakann/vim-highlightedyank'
" Fancy start screen for Vim
Plug 'mhinz/vim-startify'
" script for text filtering and alignment
Plug 'godlygeek/tabular'
" EditorConfig plugin for Vim
Plug 'editorconfig/editorconfig-vim'
" Sublime Text's awesome multiple selection
Plug 'terryma/vim-multiple-cursors'
" Dart Plugin
Plug 'dart-lang/dart-vim-plugin'
Plug 'thosakwe/vim-flutter'
" Typescript
Plug 'Quramy/tsuquyomi'
Plug 'leafgarland/typescript-vim'
"Plug 'HerringtonDarkholme/yats.vim'
"Prettier
Plug 'prettier/vim-prettier'
"Ack.vim
Plug 'mileszs/ack.vim'
"Python
Plug 'Vimjas/vim-python-pep8-indent'
"GraphQL file detection, syntax highlighting, and indentation
Plug 'jparise/vim-graphql'
"Plug 'Valloric/YouCompleteMe', {'for': 'php,typescript,javascript,html,css,xml'}
"Plug 'neoclide/coc.nvim', {'branch': 'release', 'for': 'dart,ptyhon'}
"Vim intellisense
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Icons
Plug 'ryanoasis/vim-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
"Whitespace highlight
Plug 'ntpeters/vim-better-whitespace'
"snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
"Fuzzy Search
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
"PHP
Plug 'stephpy/vim-php-cs-fixer'
call plug#end()
if vim_plug_just_installed
echo "Installing Bundles, please ignore key map error messages"
:PlugInstall
endif
filetype plugin indent on
"" Copy/Paste/Cut
set clipboard=unnamed
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
set directory=~/.config/nvim/temp
"set wildmode=list:full
set wildmode=list:longest
set path+=**
set cursorline
set hlsearch
set cindent
set hidden
set termguicolors
set noswapfile
set ruler
set colorcolumn=80
set smartcase
" tabs and spaces handling
set expandtab
set smarttab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set autoindent
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set bomb
set binary
set mouse=
" show line numbers
set nu
" when scrolling, keep cursor 3 lines away from screen border
set scrolloff=3
" remove ugly vertical lines on window division
set fillchars+=vert:\
" fix problems with uncommon shells (fish, xonsh) and plugins running commands
" (neomake, ...)
set shell=/bin/bash
set undofile
set undodir=/home/oscar/.vimundo/
if !exists('g:not_finish_vimplug')
colorscheme jellybeans
endif
"Nicer vertical split
hi LineNr guibg=bg
set foldcolumn=2
hi foldcolumn guibg=bg
hi VertSplit guibg=bg guifg=bg
" Floating Window colors
highlight NormalFloat cterm=NONE ctermfg=14 ctermbg=0 gui=NONE guifg=#93a1a1 guibg=#002931
" Keybindings start
" buffer movement
nmap <C-l> :bnext<CR>
nmap <C-h> :bprevious<CR>
nmap <C-d> :bdelete<CR>
" toggle comment
nmap ,c :call NERDComment(0, 'toggle');<CR>
vmap ,c :call NERDComment(0, 'toggle');<CR>
" clear search results
nnoremap <silent> // :noh<CR>
" Kill flutter pid
nmap <leader>f :!kill -SIGUSR1 $(pgrep -f flutter_tools.snapshot) &> /dev/null<CR>
" Git
noremap <leader>b :Gblame<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <leader>v :tabe $MYVIMRC<CR>
" NERDTree -----------------------------
" open nerdtree with the current file selected
nmap <leader>t :NERDTreeFind<CR>
nmap ,t :call ToggleNERDTree()<CR><Esc>
" mappings
map <C-q> :Ack! '<C-r>=expand("<cword>")<CR>'<CR>
"fuzzy mappings
nmap <C-b> :Buffers<CR>
nmap <C-f> :Files<CR>
" Keybindings end
" save as sudo
ca w!! w !sudo tee "%"
autocmd FileType typescript nmap <buffer> <C-]> <Plug>(coc-definition)
autocmd FileType dart nmap <buffer> <C-]> <Plug>(coc-definition)
autocmd FileType python nmap <buffer> <C-]> <Plug>(coc-definition)
autocmd FileType javascript nmap <buffer> <C-]> <Plug>(coc-definition)
autocmd FileType php nmap <buffer> <C-]> <Plug>(coc-definition)
"autocmd FileType typescript nmap <buffer> <C-]> :YcmCompleter GoTo<CR>
"autocmd FileType javascript nmap <buffer> <C-]> :YcmCompleter GoTo<CR>
"autocmd BufWritePre *.dart silent! :FlutterHotReload
autocmd BufWritePre *.dart silent! :!kill -SIGUSR1 $(pgrep -f flutter_tools.snapshot) &> /dev/null
autocmd BufWritePre *.php,*.html,*.css,*.js silent! :%s/\s\+$//e
autocmd BufWritePre *.php,*.html,*.css,*.js silent! :%s///g
"autocmd BufWritePre *.ts :Prettier
"autocmd BufWritePre *.js :Prettier
"autocmd BufWritePre *.json :Prettier
autocmd BufWritePre *.yaml :Prettier
autocmd BufWritePre *.html :Prettier
"Credits to
"https://kassioborges.dev/2019/04/10/neovim-fzf-with-a-floating-window.html
" Reverse the layout to make the FZF list top-down
let $FZF_DEFAULT_OPTS='--layout=reverse'
" Using the custom window creation function
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
" Function to create the custom floating window
function! FloatingFZF()
" creates a scratch, unlisted, new, empty, unnamed buffer
" to be used in the floating window
let buf = nvim_create_buf(v:false, v:true)
" 90% of the height
let height = float2nr(&lines * 0.9)
" 60% of the height
let width = float2nr(&columns * 0.6)
" horizontal position (centralized)
let horizontal = float2nr((&columns - width) / 2)
" vertical position (one line down of the top)
let vertical = 1
let opts = {
\ 'relative': 'editor',
\ 'row': vertical,
\ 'col': horizontal,
\ 'width': width,
\ 'height': height
\ }
" open the new window, floating, and enter to it
call nvim_open_win(buf, v:true, opts)
endfunction
function! ToggleNERDTree()
if g:NERDTree.IsOpen()
:NERDTreeToggle
else
:NERDTreeFind
":vertical resize 50
endif
endfunction