145 lines
4.4 KiB
Plaintext
145 lines
4.4 KiB
Plaintext
" ----------------------------------------------------------------------------
|
|
" vundle essentials
|
|
" ----------------------------------------------------------------------------
|
|
|
|
set nocompatible
|
|
filetype off
|
|
|
|
" set the runtime path to include Vundle and initialize
|
|
set rtp+=~/.vim/bundle/Vundle.vim
|
|
|
|
call vundle#begin()
|
|
|
|
" let vundle manage vundle...
|
|
Plugin 'VundleVim/Vundle.vim'
|
|
|
|
" Basic plugins
|
|
Plugin 'jiangmiao/auto-pairs'
|
|
Plugin 'preservim/nerdtree'
|
|
Plugin 'jeetsukumaran/vim-buffergator'
|
|
|
|
" IDE like plugins
|
|
Plugin 'prabirshrestha/asyncomplete.vim'
|
|
Plugin 'prabirshrestha/vim-lsp'
|
|
Plugin 'prabirshrestha/asyncomplete-lsp.vim'
|
|
Plugin 'mattn/vim-lsp-settings'
|
|
"Plugin 'yami-beta/asyncomplete-omni.vim'
|
|
Plugin 'prabirshrestha/asyncomplete-file.vim'
|
|
|
|
" Language autocomplete for English
|
|
Plugin 'htlsne/asyncomplete-look'
|
|
|
|
" an additional colorscheme I like
|
|
Plugin 'altercation/vim-colors-solarized'
|
|
|
|
let _plugins_list = _vimrc_dir . "/" . $USER . "_plugins.list"
|
|
if filereadable(_plugins_list)
|
|
"echomsg "found user plugins " . _plugins_list
|
|
execute 'source '.fnameescape(_plugins_list)
|
|
endif
|
|
|
|
call vundle#end()
|
|
|
|
filetype plugin indent on
|
|
|
|
" ----------------------------------------------------------------------------
|
|
" plugin configuration
|
|
" ----------------------------------------------------------------------------
|
|
|
|
" NERDTree
|
|
" --------
|
|
|
|
" map a keyboard shortcut to show and hide NERDTree
|
|
nnoremap <C-t> :NERDTreeToggle<CR>
|
|
|
|
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
|
|
|
" vim-lsp
|
|
" -------
|
|
|
|
" general vim-lsp settings
|
|
" ------------------------
|
|
|
|
" maps quite q few keyboad shortcuts
|
|
" this is taken staight off the github page with one added shortcut to peak at
|
|
" the definition of a function or class
|
|
function! s:on_lsp_buffer_enabled() abort
|
|
setlocal omnifunc=lsp#complete
|
|
setlocal signcolumn=no " messes with some autocomplete!
|
|
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
|
|
nmap <buffer> gd <plug>(lsp-definition)
|
|
nmap <buffer> gpd <plug>(lsp-peek-definition)
|
|
nmap <buffer> gs <plug>(lsp-document-symbol-search)
|
|
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
|
|
nmap <buffer> gr <plug>(lsp-references)
|
|
nmap <buffer> gi <plug>(lsp-implementation)
|
|
nmap <buffer> gt <plug>(lsp-type-definition)
|
|
nmap <buffer> <leader>rn <plug>(lsp-rename)
|
|
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
|
|
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
|
|
nmap <buffer> K <plug>(lsp-hover)
|
|
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
|
|
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
|
|
|
|
let g:lsp_format_sync_timeout = 2000
|
|
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
|
|
endfunction
|
|
|
|
augroup lsp_install
|
|
au!
|
|
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
|
|
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
|
|
augroup END
|
|
|
|
" asyncomplete
|
|
" ------------
|
|
|
|
" make tab complete work
|
|
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
inoremap <expr> <cr> pumvisible() ? asyncomplete#close_popup() : "\<cr>"
|
|
|
|
" force refresh with CTRL-SPACE
|
|
imap <c-@> <Plug>(asyncomplete_force_refresh)
|
|
|
|
" asyncomplete-file
|
|
" -----------------
|
|
|
|
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
|
|
\ 'name': 'file',
|
|
\ 'allowlist': ['*'],
|
|
\ 'priority': 10,
|
|
\ 'completor': function('asyncomplete#sources#file#completor')
|
|
\ }))
|
|
|
|
" asyncomplete-omni
|
|
" -----------------
|
|
|
|
"autocmd User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({
|
|
" \ 'name': 'omni',
|
|
" \ 'allowlist': ['*'],
|
|
" \ 'blocklist': ['c', 'cpp', 'html'],
|
|
" \ 'completor': function('asyncomplete#sources#omni#completor'),
|
|
" \ 'config': {
|
|
" \ 'show_source_kind': 1,
|
|
" \ },
|
|
" \ }))
|
|
|
|
" asyncomplete-look
|
|
" -----------------
|
|
|
|
au User asyncomplete_setup call asyncomplete#register_source({
|
|
\ 'name': 'look',
|
|
\ 'allowlist': ['text', 'markdown'],
|
|
\ 'completor': function('asyncomplete#sources#look#completor'),
|
|
\ })
|
|
|
|
" source the additional config
|
|
|
|
let _plugins_list = _vimrc_dir . "/" . $USER . "_plugins.vimrc"
|
|
if filereadable(_plugins_list)
|
|
"echomsg "found user plugin configuration " . _plugins_list
|
|
execute 'source '.fnameescape(_plugins_list)
|
|
endif
|