Skip to content

Commit

Permalink
vimrc adjustments
Browse files Browse the repository at this point in the history
* More language supports (plugins)
* More Typescript support
* Added coc.nvim for autocompletion and syntax checks
* Changed theme to iceberg as nord has a bug with Typescript (see nordtheme/vim#163)
* Some minor adjustments
  • Loading branch information
BennyLi committed Aug 23, 2019
1 parent 620a0fd commit 5994ae8
Showing 1 changed file with 188 additions and 30 deletions.
218 changes: 188 additions & 30 deletions vim/vimrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
" General settings {{{1
nnoremap <SPACE> <Nop>
let mapleader=' '

set number
set cursorline
set nocompatible
filetype plugin on
syntax on

set expandtab
let shiftwidth=2
let tabstop=2
set autoindent

" Folding {{{2
set foldenable
set foldmethod=marker
nnoremap <leader><space> za
" Plugin configuration {{{1

if empty(glob('~/.vim/autoload/plug.vim'))
Expand All @@ -30,16 +10,23 @@ call plug#begin('~/.vim/plugged')

Plug 'itchyny/lightline.vim'
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'ctrlpvim/ctrlp.vim'

" Language support
" Language and filetype support
" i3 config files
Plug 'mboughaba/i3config.vim'
" CSS Color highlight
Plug 'ap/vim-css-color'
" > Ansible
Plug 'pearofducks/ansible-vim'
" > JavaScript
Plug 'Quramy/vim-js-pretty-template'
" Plug 'Quramy/vim-js-pretty-template'
" > TypeScript
Plug 'leafgarland/typescript-vim'
Plug 'Quramy/tsuquyomi' " Completion
"Plug 'Quramy/tsuquyomi' " Completion
"
Plug 'neoclide/coc.nvim', {'branch': 'release'}


" Git integration
Expand All @@ -49,14 +36,17 @@ Plug 'vimwiki/vimwiki'
"Plug 'tbabej/taskwiki'

" Colorscheme
Plug 'arcticicestudio/nord-vim'
" Plug 'arcticicestudio/nord-vim'
" Plug 'altercation/vim-colors-solarized'
Plug 'ajh17/Spacegray.vim'
Plug 'cocopon/iceberg.vim'

call plug#end()

" Plugin config for: lightline {{{2
set laststatus=2
let g:lightline={
\ 'colorscheme': 'nord' }
\ 'colorscheme': 'iceberg' }
let g:lightline.active = {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'relativepath', 'modified' ] ],
Expand All @@ -73,15 +63,22 @@ let g:lightline.tabline = {


" Plugin config for: Nerdtree {{{2
let g:NERDTreeWinSize=50
map <C-n> :NERDTreeToggle<CR>
nnoremap gn :NERDTreeFind<CR>
" Plugin config for: vimwiki {{{2
let wiki_private = {}
let wiki_private.path = '~/Documents/Notizen'
let wiki_private.syntax = 'markdown'
let wiki_private.ext = 'md'

let wiki_iteratec = {}
let wiki_iteratec.path = '~/Documents/iteratec/Notes'
let wiki_iteratec.syntax = 'markdown'
let wiki_iteratec.ext = 'md'

let g:vimwiki_list = [wiki_iteratec]
let g:vimwiki_list = [wiki_private,wiki_iteratec]
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
let g:vimwiki_folding = 'expr'

Expand All @@ -100,10 +97,12 @@ let g:vimwiki_folding = 'expr'
" Plugin config for: CtrlP {{{2
" Setup some default ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site)$',
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site|build|buildSrc|node_modules)$',
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg)$',
\}

let g:ctrlp_max_files = 50000

" Use the nearest .git directory as the cwd
" This makes a lot of sense if you are working on a project that is in version
" control. It also supports works with .svn, .hg, .bzr.
Expand All @@ -117,14 +116,173 @@ nmap <leader>bb :CtrlPBuffer<cr>
nmap <leader>bm :CtrlPMixed<cr>
nmap <leader>bs :CtrlPMRU<cr>
" Plugin config for: coc.nvim {{{2
" if hidden is not set, TextEdit might fail.
set hidden
" 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

" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction

" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" 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)
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction

" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')

" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
" xmap <leader>f <Plug>(coc-format-selected)
" nmap <leader>f <Plug>(coc-format-selected)

augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>f :CocFix<CR>
" Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
nmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')

" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)

" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')

" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}

" Using CocList
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>

" Plugin config for: vim-js-pretty-template {{{2
autocmd FileType typescript JsPreTmpl
autocmd FileType typescript syn clear foldBraces " For leafgarland/typescript-vim users only. Please see #1 for details.
"autocmd FileType typescript JsPreTmpl
"autocmd FileType typescript syn clear foldBraces " For leafgarland/typescript-vim users only. Please see #1 for details.

" Plugin config for: tsuquyomi {{{2
" nnoremap <leader>td :TsuDefinition<enter>
" nnoremap <leader>tt :TsuTypeDefinition<enter>
" nnoremap <leader>tr :TsuReferences<enter>
" nnoremap <leader>ti :TsuImplementation<enter>
" nnoremap <leader>tf :TsuSearch<space>

" Plugin config for: nord-vim {{{2
let g:nord_cursor_line_number_background = 1
let g:nord_bold_vertical_split_line = 1
let g:nord_uniform_diff_background = 1
colorscheme nord
"colorscheme nord

" Plugin config for: solorarized theme {{{2
"syntax enable
"set background=dark
"colorscheme solarized


" Plugin config for: iceberg theme {{{2
colorscheme iceberg

" General settings {{{1
nnoremap <SPACE> <Nop>
let mapleader=' '

set number
set cursorline
set nowrap

filetype plugin on
syntax on

set shiftwidth=2
set tabstop=2
set expandtab

set autoindent
set smartindent

set listchars=tab:>-,trail:~,extends:>,precedes:<
set list

" Folding {{{2
set foldenable
set foldmethod=marker
nnoremap <leader><space> za

0 comments on commit 5994ae8

Please sign in to comment.