Skip to content

Commit 40f632e

Browse files
New vim resource using Plug
Uses: * coc.nvim for diagnostics, syntax & error checking * NERDTree for project tree view * fzf (silversearch-ag) for searching fuzzy file searching * vimade for dimming unfocused window panes * vim-commentary for code commenting
1 parent e8929fe commit 40f632e

File tree

1 file changed

+99
-204
lines changed

1 file changed

+99
-204
lines changed

.vimrc

+99-204
Original file line numberDiff line numberDiff line change
@@ -1,217 +1,112 @@
1-
set nocompatible " be iMproved, required
2-
filetype off " required
3-
4-
" set the runtime path to include Vundle and initialize
5-
set rtp+=~/.vim/bundle/Vundle.vim
6-
set rtp+=~/.fzf
7-
8-
call vundle#begin()
9-
" alternatively, pass a path where Vundle should install plugins
10-
"call vundle#begin('~/some/path/here')
11-
12-
" let Vundle manage Vundle, required
13-
Plugin 'VundleVim/Vundle.vim'
14-
15-
" The following are examples of different formats supported.
16-
" Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo
17-
Plugin 'tpope/vim-fugitive'
18-
Plugin 'scrooloose/nerdtree'
19-
Plugin 'scrooloose/syntastic'
20-
Plugin 'scrooloose/nerdcommenter'
21-
Plugin 'vim-airline/vim-airline'
22-
Plugin 'vim-airline/vim-airline-themes'
23-
Plugin 'airblade/vim-gitgutter'
24-
Plugin 'dracula/vim'
25-
Plugin 'altercation/vim-colors-solarized'
26-
Plugin 'morhetz/gruvbox'
27-
Plugin 'acoustichero/simple_dark'
28-
Plugin 'junegunn/goyo.vim'
29-
Plugin 'tomasr/molokai'
30-
Plugin 'lifepillar/vim-mucomplete'
31-
Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
32-
Plugin 'junegunn/fzf.vim'
33-
" plugin from http://vm-scripts.org/vim/scripts.html
34-
" Plugin 'L9'
35-
" Git plugin not hosted on GitHub
36-
" Plugin 'git://git.wincent.com/command-t.git'
37-
" git repos on your local machine (i.e. when working on your own plugin)
38-
" Plugin 'file:///home/gmarik/path/to/plugin'
39-
" The sparkup vim script is in a subdirectory of this repo called vim.
40-
" Pass the path to set the runtimepath properly.
41-
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
42-
" Install L9 and avoid a Naming conflict if you've already installed a
43-
" different version somewhere else.
44-
" Plugin 'ascenator/L9', {'name': 'newL9'}
45-
" All of your Plugins must be added before the following line
46-
call vundle#end() " required
47-
filetype plugin indent on " required
48-
" To ignore plugin indent changes, instead use:
49-
"filetype plugin on
50-
" Brief help
51-
" :PluginList - lists configured plugins
52-
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
53-
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
54-
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
55-
"
56-
" see :h vundle for more details or wiki for FAQ
57-
" Put your non-Plugin stuff after this line
58-
59-
set number "relativenumber
60-
set textwidth=99
1+
call plug#begin()
2+
Plug 'neoclide/coc.nvim', {'branch': 'release'}
3+
Plug 'tpope/vim-fugitive'
4+
Plug 'tpope/vim-commentary'
5+
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
6+
Plug 'junegunn/fzf.vim'
7+
Plug 'tadaa/vimade'
8+
Plug 'joshdick/onedark.vim'
9+
Plug 'scrooloose/nerdtree'
10+
Plug 'junegunn/goyo.vim'
11+
call plug#end()
12+
13+
" === Configurations ===
14+
set number " Show line number
15+
set mouse=a " Use mouse to scroll
16+
set smartindent
6117
set autoindent
62-
"set colorcolumn=101
6318
set nowrap
64-
set softtabstop=4 shiftwidth=4 expandtab
65-
set background=dark
19+
set background=light
6620
set title
6721
set hlsearch
68-
set incsearch
69-
set clipboard=unnamed
22+
set incsearch " Focus search string while typing
23+
set softtabstop=4 shiftwidth=4 expandtab
24+
set clipboard=exclude:.* " Don't connect to X display
7025
set showcmd
71-
" Auto indent when copy pasting
72-
set pastetoggle=<F3>
73-
" Fuzzy file built-in
74-
set path+=**
75-
set wildmenu
76-
set wildignore+=*/min/*,*/vendor/*,*/node_modules/*,*/bower_components/*,*/storage/*
77-
set backupdir=~/.vim/tmp//,.
26+
set pastetoggle=<F3> " Auto indent when copy & pasting
27+
set backupdir=~/.vim/tmp//,. " Set swap files directory
7828
set directory=~/.vim/tmp//,.
7929

80-
" Airline config
81-
let g:airline_powerline_fonts=1
82-
83-
" AirlineTheme config
84-
let g:airline_theme='luna'
85-
86-
" Signify config
87-
let g:signify_vcs_list=['git']
88-
let g:signify_line_highlight=1
89-
90-
" Tagbar
91-
let g:tagbar_ctags_bin="/usr/local/bin/ctags"
92-
93-
" Faster CtrlP search
94-
"let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
95-
96-
"let g:solarized_termcolors=256
97-
98-
" MuComplete
99-
set completeopt+=menuone,noselect
100-
let g:mucomplete#enable_auto_at_startup=1
101-
102-
" Default fzf layout
103-
" - down / up / left / right
104-
let g:fzf_layout = { 'down': '~40%' }
105-
let $FZF_DEFAULT_COMMAND=' (git ls-tree -r --name-only HEAD || find . -path "*/\.*" -prune -o -type f -print -o -type l -print | sed s/^..//) 2> /dev/null'
106-
107-
" Customize fzf colors to match your color scheme
108-
let g:fzf_colors =
109-
\ { 'fg': ['fg', 'Normal'],
110-
\ 'bg': ['bg', 'Normal'],
111-
\ 'hl': ['fg', 'Comment'],
112-
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
113-
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
114-
\ 'hl+': ['fg', 'Statement'],
115-
\ 'info': ['fg', 'PreProc'],
116-
\ 'border': ['fg', 'Ignore'],
117-
\ 'prompt': ['fg', 'Conditional'],
118-
\ 'pointer': ['fg', 'Exception'],
119-
\ 'marker': ['fg', 'Keyword'],
120-
\ 'spinner': ['fg', 'Label'],
121-
\ 'header': ['fg', 'Comment'] }
122-
123-
" let dimension=&colorcolumn + 5
124-
"
125-
" " Indent config
126-
" let g:indentLine_char_list = ['|', '¦', '┆', '┊']
127-
"
128-
" "Goyo config
129-
" let g:goyo_width=dimension
130-
" let g:goyo_height=95
131-
" let g:goyo_linenr=1
132-
133-
" NERDCommenter config
134-
let g:NERDSpaceDelims=1
135-
let g:NERDCustomDelimiters={'c':{ 'left': '/**', 'right': '*/'}}
136-
let g:NERDCommentEmptyLines=1
137-
138-
" Syntastic config
139-
set statusline+=%#warningmsg#
140-
set statusline+=%{SyntasticStatuslineFlag()}
141-
set statusline+=%*
142-
143-
let g:syntastic_always_populate_loc_list = 1
144-
let g:syntastic_auto_loc_list = 1
145-
let g:syntastic_check_on_open = 1
146-
let g:syntastic_check_on_wq = 0
147-
148-
if &term =~ '256color' || &term == 'screen'
149-
" Disable Background Color Erase (BCE) so that color schemes
150-
" " work properly when Vim is used inside tmux and GNU screen.
151-
set t_ut=
152-
set t_Co=256
30+
" Disable Background Color Erase
31+
" Removes color reside on scroll
32+
if &term =~ '256color'
33+
set t_ut=
15334
endif
15435

155-
if &term == 'linux' || &term == 'screen'
156-
" colorscheme solarized
157-
else
158-
" colorscheme dracula
159-
endif
36+
" CoC Configurations
37+
set hidden
38+
set cmdheight=2
39+
set updatetime=300
40+
set shortmess+=c
41+
set signcolumn=yes
42+
set nobackup
43+
set nowritebackup
44+
45+
" Vimade Configurations
46+
let g:vimade = {}
47+
let g:vimade.fadelevel = 0.4
48+
let g:vimade.enablesigns = 1
49+
50+
" === Key Bindings ===
51+
" FZF
52+
nmap <C-P> :Files<CR>
16053
161-
au BufRead,BufNewFile *.vue set filetype=html
162-
autocmd FileType html setlocal shiftwidth=2 softtabstop=2 expandtab
163-
autocmd FileType vue setlocal shiftwidth=2 softtabstop=2 expandtab
164-
autocmd FileType js setlocal shiftwidth=4 softtabstop=4 expandtab
165-
"Allow transparent bg
166-
"autocmd ColorScheme * highlight Normal ctermbg=None
54+
" NERDTree
55+
map <C-F7> :NERDTreeToggle<CR>
56+
57+
" CoC
58+
" Use K to show documentation
59+
nnoremap <silent> K :call <SID>show_documentation()<CR>
60+
function! s:show_documentation()
61+
if (index(['vim','help'], &filetype) >= 0)
62+
execute 'h '.expand('<cword>')
63+
else
64+
call CocActionAsync('doHover')
65+
endif
66+
endfunction
67+
68+
" Use TAB to trigger completion
69+
inoremap <silent><expr> <TAB>
70+
\ pumvisible() ? "\<C-n>" :
71+
\ <SID>check_back_space() ? "\<TAB>" :
72+
\ coc#refresh()
73+
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
74+
75+
function! s:check_back_space() abort
76+
let col = col('.') - 1
77+
return !col || getline('.')[col - 1] =~# '\s'
78+
endfunction
79+
80+
" Use <c-space> to trigger completion.
81+
inoremap <silent><expr> <c-@> coc#refresh()
82+
83+
" Remap keys for gotos
84+
nmap <silent> gd <Plug>(coc-definition)
85+
nmap <silent> gy <Plug>(coc-type-definition)
86+
nmap <silent> gi <Plug>(coc-implementation)
87+
nmap <silent> gr <Plug>(coc-references)
88+
89+
" === Commands ===
90+
" Disable auto comment
91+
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=
92+
" FZF Preview
93+
com! -bar -bang Ag call fzf#vim#ag(<q-args>, fzf#vim#with_preview({'options': '--delimiter=: --nth=4..'}, 'right'), <bang>0)
16794

168-
"autocmd ColorScheme * highlight Comment cterm=italic
95+
" Open NERDTree on startup
96+
autocmd VimEnter * NERDTree
97+
" Change focus to next window
98+
autocmd VimEnter * 2wincmd w
16999

170-
"let g:mucomplete#enable_auto_at_startup = 0
171-
syntax enable
172-
" colorscheme github
173-
" colorscheme gruvbox
174-
" colorscheme solarized
175-
colorscheme simple_dark
100+
" Close vim if NERDTree is last window
101+
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
102+
103+
" Vue Indentation
104+
au BufRead,BufNewFile *.vue set filetype=vue
105+
autocmd FileType vue setlocal shiftwidth=2 softtabstop=2 expandtab
106+
" === Color Highlights ===
107+
108+
highlight clear SignColumn
109+
highlight PMenu ctermbg=235 ctermfg=145
110+
highlight CocFloating ctermbg=235 ctermfg=145
111+
highlight LineNr ctermfg=8
176112

177-
" FZF Key Bindings
178-
nmap <C-P> :Files<CR>
179-
nmap <F7> :NERDTreeToggle<CR>
180-
nmap <F8> :TagbarToggle<CR>
181-
nmap <C-S-F> :Ag<CR>
182-
183-
" Auto Session
184-
" function! MakeSession()
185-
" let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
186-
" if (filewritable(b:sessiondir) != 2)
187-
" exe 'silent !mkdir -p ' b:sessiondir
188-
" redraw!
189-
" endif
190-
" let b:filename = b:sessiondir . '/session.vim'
191-
" exe "mksession! " . b:filename
192-
" endfunction
193-
"
194-
" function! LoadSession()
195-
" let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
196-
" let b:sessionfile = b:sessiondir . "/session.vim"
197-
" if (filereadable(b:sessionfile))
198-
" exe 'source ' b:sessionfile
199-
" else
200-
" echo "No session loaded."
201-
" endif
202-
" endfunction
203-
204-
" if (argc() == 0)
205-
" au VimEnter * nested :call LoadSession()
206-
" endif
207-
208-
augroup VCenterCursor
209-
au!
210-
au BufEnter,WinEnter,WinNew,VimResized *,*.*
211-
\ let &scrolloff=winheight(win_getid())/2
212-
augroup END
213-
214-
" au VimLeave * :call MakeSession()
215-
" au BufRead,BufEnter,BufNewFile * IndentLinesReset
216-
" au VimEnter * Goyo
217-
com! -bar -bang Ag call fzf#vim#ag(<q-args>, fzf#vim#with_preview({'options': '--delimiter=: --nth=4..'}, 'right'), <bang>0)

0 commit comments

Comments
 (0)