Install improvements
This commit is contained in:
@@ -1,27 +1,32 @@
|
||||
|
||||
" ============================================================================ "
|
||||
" === PLUGINS === "
|
||||
" ============================================================================ "
|
||||
|
||||
" check whether vim-plug is installed and install it if necessary
|
||||
let plugpath = expand('<sfile>:p:h'). '/autoload/plug.vim'
|
||||
if !filereadable(plugpath)
|
||||
if executable('curl')
|
||||
let plugurl = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||
call system('curl -fLo ' . shellescape(plugpath) . ' --create-dirs ' . plugurl)
|
||||
if v:shell_error
|
||||
echom "Error downloading vim-plug. Please install it manually.\n"
|
||||
exit
|
||||
endif
|
||||
else
|
||||
echom "vim-plug not installed. Please install it manually or install curl.\n"
|
||||
exit
|
||||
endif
|
||||
endif
|
||||
|
||||
call plug#begin('~/.config/nvim/plugged')
|
||||
|
||||
" === Editing Plugins === "
|
||||
" Sensible (?) defaults
|
||||
Plug 'tpope/vim-sensible'
|
||||
|
||||
" colorscheme
|
||||
Plug 'gilgigilgil/anderson.vim'
|
||||
silent! colorscheme anderson
|
||||
|
||||
|
||||
" lint
|
||||
Plug 'dense-analysis/ale'
|
||||
let g:ale_fix_on_save = 1
|
||||
|
||||
" Intellisense Engine
|
||||
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
|
||||
|
||||
" Denite - Fuzzy finding, buffer management
|
||||
if has('nvim')
|
||||
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
|
||||
else
|
||||
Plug 'Shougo/denite.nvim'
|
||||
Plug 'roxma/nvim-yarp'
|
||||
Plug 'roxma/vim-hug-neovim-rpc'
|
||||
endif
|
||||
|
||||
" Trailing whitespace highlighting & automatic fixing
|
||||
Plug 'ntpeters/vim-better-whitespace'
|
||||
|
||||
@@ -31,12 +36,6 @@ Plug 'rstacruz/vim-closer'
|
||||
" Improved motion in Vim
|
||||
Plug 'easymotion/vim-easymotion'
|
||||
|
||||
" Intellisense Engine
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
|
||||
" Denite - Fuzzy finding, buffer management
|
||||
Plug 'Shougo/denite.nvim'
|
||||
|
||||
" Snippet support
|
||||
Plug 'Shougo/neosnippet'
|
||||
Plug 'Shougo/neosnippet-snippets'
|
||||
@@ -74,12 +73,10 @@ Plug 'othree/yajs.vim'
|
||||
" File explorer
|
||||
Plug 'scrooloose/nerdtree'
|
||||
|
||||
" Colorscheme
|
||||
Plug 'tomasiser/vim-code-dark'
|
||||
|
||||
" Customized vim status line
|
||||
Plug 'vim-airline/vim-airline'
|
||||
Plug 'vim-airline/vim-airline-themes'
|
||||
let g:airline_theme='onedark'
|
||||
|
||||
" Icons
|
||||
Plug 'ryanoasis/vim-devicons'
|
||||
@@ -88,3 +85,253 @@ Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
|
||||
" Initialize plugin system
|
||||
call plug#end()
|
||||
|
||||
|
||||
|
||||
" ============================================================================ "
|
||||
" === PLUGIN SETUP === "
|
||||
" ============================================================================ "
|
||||
|
||||
" Wrap in try/catch to avoid errors on initial install before plugin is available
|
||||
try
|
||||
" === Denite setup ==="
|
||||
" Use ripgrep for searching current directory for files
|
||||
" By default, ripgrep will respect rules in .gitignore
|
||||
" --files: Print each file that would be searched (but don't search)
|
||||
" --glob: Include or exclues files for searching that match the given glob
|
||||
" (aka ignore .git files)
|
||||
"
|
||||
call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git'])
|
||||
|
||||
" Use ripgrep in place of "grep"
|
||||
call denite#custom#var('grep', 'command', ['rg'])
|
||||
|
||||
" Custom options for ripgrep
|
||||
" --vimgrep: Show results with every match on it's own line
|
||||
" --hidden: Search hidden directories and files
|
||||
" --heading: Show the file name above clusters of matches from each file
|
||||
" --S: Search case insensitively if the pattern is all lowercase
|
||||
call denite#custom#var('grep', 'default_opts', ['--hidden', '--vimgrep', '--heading', '-S'])
|
||||
|
||||
" Recommended defaults for ripgrep via Denite docs
|
||||
call denite#custom#var('grep', 'recursive_opts', [])
|
||||
call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
|
||||
call denite#custom#var('grep', 'separator', ['--'])
|
||||
call denite#custom#var('grep', 'final_opts', [])
|
||||
|
||||
" Remove date from buffer list
|
||||
call denite#custom#var('buffer', 'date_format', '')
|
||||
|
||||
" Custom options for Denite
|
||||
" auto_resize - Auto resize the Denite window height automatically.
|
||||
" prompt - Customize denite prompt
|
||||
" direction - Specify Denite window direction as directly below current pane
|
||||
" winminheight - Specify min height for Denite window
|
||||
" highlight_mode_insert - Specify h1-CursorLine in insert mode
|
||||
" prompt_highlight - Specify color of prompt
|
||||
" highlight_matched_char - Matched characters highlight
|
||||
" highlight_matched_range - matched range highlight
|
||||
let s:denite_options = {'default' : {
|
||||
\ 'split': 'floating',
|
||||
\ 'start_filter': 1,
|
||||
\ 'auto_resize': 1,
|
||||
\ 'source_names': 'short',
|
||||
\ 'prompt': 'λ ',
|
||||
\ 'highlight_matched_char': 'QuickFixLine',
|
||||
\ 'highlight_matched_range': 'Visual',
|
||||
\ 'highlight_window_background': 'Visual',
|
||||
\ 'highlight_filter_background': 'DiffAdd',
|
||||
\ 'winrow': 1,
|
||||
\ 'vertical_preview': 1
|
||||
\ }}
|
||||
|
||||
" Loop through denite options and enable them
|
||||
function! s:profile(opts) abort
|
||||
for l:fname in keys(a:opts)
|
||||
for l:dopt in keys(a:opts[l:fname])
|
||||
call denite#custom#option(l:fname, l:dopt, a:opts[l:fname][l:dopt])
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
call s:profile(s:denite_options)
|
||||
catch
|
||||
echo 'Denite not installed. It should work after running :PlugInstall'
|
||||
endtry
|
||||
|
||||
" === Coc.nvim === "
|
||||
" use <tab> for trigger completion and navigate to next complete item
|
||||
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()
|
||||
|
||||
"Close preview window when completion is done.
|
||||
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
|
||||
|
||||
" Allow use of :Prettier
|
||||
command! -nargs=0 Prettier :CocCommand prettier.formatFile
|
||||
|
||||
" === NeoSnippet === "
|
||||
" Map <C-k> as shortcut to activate snippet if available
|
||||
imap <C-k> <Plug>(neosnippet_expand_or_jump)
|
||||
smap <C-k> <Plug>(neosnippet_expand_or_jump)
|
||||
xmap <C-k> <Plug>(neosnippet_expand_target)
|
||||
|
||||
" Load custom snippets from snippets folder
|
||||
let g:neosnippet#snippets_directory='~/.config/nvim/snippets'
|
||||
|
||||
" Hide conceal markers
|
||||
let g:neosnippet#enable_conceal_markers = 0
|
||||
|
||||
" === NERDTree === "
|
||||
" Show hidden files/directories
|
||||
let g:NERDTreeShowHidden = 1
|
||||
|
||||
" Remove bookmarks and help text from NERDTree
|
||||
let g:NERDTreeMinimalUI = 1
|
||||
|
||||
" Custom icons for expandable/expanded directories
|
||||
let g:NERDTreeDirArrowExpandable = ''
|
||||
let g:NERDTreeDirArrowCollapsible = ''
|
||||
|
||||
" Hide certain files and directories from NERDTree
|
||||
let g:NERDTreeIgnore = ['^\.DS_Store$', '^tags$', '\.git$[[dir]]', '\.idea$[[dir]]', '\.sass-cache$']
|
||||
|
||||
" Wrap in try/catch to avoid errors on initial install before plugin is available
|
||||
try
|
||||
|
||||
" === Vim airline ==== "
|
||||
" Enable extensions
|
||||
let g:airline_extensions = ['branch', 'hunks', 'coc']
|
||||
|
||||
" Update section z to just have line number
|
||||
let g:airline_section_z = airline#section#create(['linenr'])
|
||||
|
||||
" Do not draw separators for empty sections (only for the active window) >
|
||||
let g:airline_skip_empty_sections = 1
|
||||
|
||||
" Smartly uniquify buffers names with similar filename, suppressing common parts of paths.
|
||||
let g:airline#extensions#tabline#formatter = 'unique_tail'
|
||||
|
||||
" Custom setup that removes filetype/whitespace from default vim airline bar
|
||||
let g:airline#extensions#default#layout = [['a', 'b', 'c'], ['x', 'z', 'warning', 'error']]
|
||||
|
||||
" Customize vim airline per filetype
|
||||
" 'nerdtree' - Hide nerdtree status line
|
||||
" 'list' - Only show file type plus current line number out of total
|
||||
let g:airline_filetype_overrides = {
|
||||
\ 'nerdtree': [ get(g:, 'NERDTreeStatusline', ''), '' ],
|
||||
\ 'list': [ '%y', '%l/%L'],
|
||||
\ }
|
||||
|
||||
" Enable powerline fonts
|
||||
let g:airline_powerline_fonts = 1
|
||||
|
||||
" Enable caching of syntax highlighting groups
|
||||
let g:airline_highlighting_cache = 1
|
||||
|
||||
" Define custom airline symbols
|
||||
if !exists('g:airline_symbols')
|
||||
let g:airline_symbols = {}
|
||||
endif
|
||||
|
||||
" Don't show git changes to current file in airline
|
||||
let g:airline#extensions#hunks#enabled=0
|
||||
|
||||
catch
|
||||
echo 'Airline not installed. It should work after running :PlugInstall'
|
||||
endtry
|
||||
|
||||
" === echodoc === "
|
||||
" Enable echodoc on startup
|
||||
let g:echodoc#enable_at_startup = 1
|
||||
|
||||
" === vim-javascript === "
|
||||
" Enable syntax highlighting for JSDoc
|
||||
let g:javascript_plugin_jsdoc = 1
|
||||
|
||||
" === vim-jsx === "
|
||||
" Highlight jsx syntax even in non .jsx files
|
||||
let g:jsx_ext_required = 0
|
||||
|
||||
" === javascript-libraries-syntax === "
|
||||
let g:used_javascript_libs = 'underscore,requirejs,chai,jquery'
|
||||
|
||||
" === Signify === "
|
||||
let g:signify_sign_delete = '-'
|
||||
|
||||
|
||||
" ============================================================================ "
|
||||
" === CUSTOM COLORSCHEME CHANGES === "
|
||||
" ============================================================================ "
|
||||
"
|
||||
" Add custom highlights in method that is executed every time a colorscheme is sourced
|
||||
" See https://gist.github.com/romainl/379904f91fa40533175dfaec4c833f2f for details
|
||||
function! TrailingSpaceHighlights() abort
|
||||
" Hightlight trailing whitespace
|
||||
highlight Trail ctermbg=red guibg=red
|
||||
call matchadd('Trail', '\s\+$', 100)
|
||||
endfunction
|
||||
|
||||
function! s:custom_jarvis_colors()
|
||||
" coc.nvim color changes
|
||||
hi link CocErrorSign WarningMsg
|
||||
hi link CocWarningSign Number
|
||||
hi link CocInfoSign Type
|
||||
|
||||
" Make background transparent for many things
|
||||
hi Normal ctermbg=NONE guibg=NONE
|
||||
hi NonText ctermbg=NONE guibg=NONE
|
||||
hi LineNr ctermfg=NONE guibg=NONE
|
||||
hi SignColumn ctermfg=NONE guibg=NONE
|
||||
hi StatusLine guifg=#16252b guibg=#6699CC
|
||||
hi StatusLineNC guifg=#16252b guibg=#16252b
|
||||
|
||||
" Try to hide vertical spit and end of buffer symbol
|
||||
hi VertSplit gui=NONE guifg=#17252c guibg=#17252c
|
||||
hi EndOfBuffer ctermbg=NONE ctermfg=NONE guibg=#17252c guifg=#17252c
|
||||
|
||||
" Customize NERDTree directory
|
||||
hi NERDTreeCWD guifg=#99c794
|
||||
|
||||
" Make background color transparent for git changes
|
||||
hi SignifySignAdd guibg=NONE
|
||||
hi SignifySignDelete guibg=NONE
|
||||
hi SignifySignChange guibg=NONE
|
||||
|
||||
" Highlight git change signs
|
||||
hi SignifySignAdd guifg=#99c794
|
||||
hi SignifySignDelete guifg=#ec5f67
|
||||
hi SignifySignChange guifg=#c594c5
|
||||
endfunction
|
||||
|
||||
autocmd! ColorScheme * call TrailingSpaceHighlights()
|
||||
autocmd! ColorScheme codedark call s:custom_jarvis_colors()
|
||||
|
||||
" Call method on window enter
|
||||
augroup WindowManagement
|
||||
autocmd!
|
||||
autocmd WinEnter * call Handle_Win_Enter()
|
||||
augroup END
|
||||
|
||||
" Change highlight group of preview window when open
|
||||
function! Handle_Win_Enter()
|
||||
if &previewwindow
|
||||
setlocal winhighlight=Normal:MarkdownError
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" Reload icons after init source
|
||||
if exists('g:loaded_webdevicons')
|
||||
call webdevicons#refresh()
|
||||
endif
|
||||
|
||||
" Disable deprecated python2 provider
|
||||
let g:loaded_python_provider = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user