Skip to content

Instantly share code, notes, and snippets.

@broerjuang
Last active January 5, 2020 15:18
Show Gist options
  • Save broerjuang/4de9fa2591dc093da6bd1a9de644a470 to your computer and use it in GitHub Desktop.
Save broerjuang/4de9fa2591dc093da6bd1a9de644a470 to your computer and use it in GitHub Desktop.
Vim config
" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
Plug 'liuchengxu/space-vim-theme'
"Plugin to insert and delete pair of chars
Plug 'jiangmiao/auto-pairs'
"Plugin to make it easy for commenting line like modern editor
Plug 'preservim/nerdcommenter'
"Plugin to make it easy for surrounding the selected text or lock
Plug 'tpope/vim-surround'
"Plugin to show GIT sign in your text editor
Plug 'airblade/vim-gitgutter'
"Plugin for Git
Plug 'tpope/vim-fugitive'
" Vim Clap (the do hooks willcall cargo to make fuzzy finder faster than ever!)
Plug 'liuchengxu/vim-clap'
" for autocomplete and language server in vim
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Syntax highlighting for popular language out there
Plug 'sheerun/vim-polyglot'
"Reson Syntax highlighting
Plug 'reasonml-editor/vim-reason-plus'
"The do hook is highly recommended.
" It will try to build all the optional dependency if cargo exists on your system.
Plug 'liuchengxu/vim-clap', { 'do': function('clap#helper#build_all') }
"Nice to have plugin
Plug 'lambdalisue/vim-gista'
Plug 'ryanoasis/vim-devicons'
""List ends here. Plugins become visible to Vim after this call.
call plug#end()
"Enable devicons
"set encoding=UTF-8
"Enable Number Line
set number
set relativenumber
"Set tab and space
set tabstop=2 shiftwidth=2 expandtab
"Clap
"find files using clap
nnoremap <Leader>s :Clap<Enter>
"Nerd Tree Config
let g:NERDTreeWinPos = "right"
nnoremap <Leader>t :NERDTreeToggle<Enter>
nnoremap <silent> <Leader>v :NERDTreeFind<CR>
"Airline
"let g:airline_theme='minimalist'
"Display buffers as tab
let g:airline#extensions#tabline#enabled = 1
set background=dark
colorscheme space_vim_theme
"Clap
nnoremap <Leader>s :Clap <Enter>
" =========
" COC NVIM
" =========
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
nmap <silent> gf :Format<cr>
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
" set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
" set shortmess+=c
" always show signcolumns
" set signcolumn=yes
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
function! StatusDiagnostic() abort
let info = get(b:, 'coc_diagnostic_info', {})
if empty(info) | return '' | endif
let msgs = []
if get(info, 'error', 0)
call add(msgs, 'E' . info['error'])
endif
if get(info, 'warning', 0)
call add(msgs, 'W' . info['warning'])
endif
return join(msgs, ' '). ' ' . get(g:, 'coc_status', '')
endfunction
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" format also
" nmap <silent> gf <Plug>(coc-format-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Use K to show documentation in preview window
nnoremap <silent> <cr> :call <SID>show_documentation()<CR>
nnoremap <silent> K :call <SID>show_documentation()<CR>
nnoremap <silent> gh :call <SID>show_documentation()<CR>
" Use <c-space> to trigger completion.
" inoremap <silent><expr> <c-space> coc#refresh()
" ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
" ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
let s:opam_share_dir = system("opam config var share")
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
let s:opam_configuration = {}
function! OpamConfOcpIndent()
execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
endfunction
let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')
function! OpamConfOcpIndex()
execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim"
endfunction
let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')
function! OpamConfMerlin()
let l:dir = s:opam_share_dir . "/merlin/vim"
execute "set rtp+=" . l:dir
endfunction
let s:opam_configuration['merlin'] = function('OpamConfMerlin')
let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
let s:opam_available_tools = split(system(join(s:opam_check_cmdline)))
for tool in s:opam_packages
" Respect package order (merlin should be after ocp-index)
if count(s:opam_available_tools, tool) > 0
call s:opam_configuration[tool]()
endif
endfor
" ## end of OPAM user-setup addition for vim / base ## keep this line
" ## added by OPAM user-setup for vim / ocp-indent ## 6fbdf10582293990a5323c812297e07f ## you can edit, but keep this line
if count(s:opam_available_tools,"ocp-indent") == 0
source "/home/broerjuang/.opam/4.07.0/share/ocp-indent/vim/indent/ocaml.vim"
endif
" ## end of OPAM user-setup addition for vim / ocp-indent ## keep this line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment