dotfiles/config/nvim/init.vim

265 lines
6.6 KiB
VimL
Raw Normal View History

2018-06-09 22:17:36 +00:00
call plug#begin("~/.nvim/bundle")
2018-08-17 12:49:53 +00:00
" Other
Plug 'prabirshrestha/async.vim'
2018-06-09 22:17:36 +00:00
" UI
Plug 'Yggdroot/indentLine'
Plug 'airblade/vim-gitgutter'
2018-08-17 12:49:53 +00:00
Plug 'haya14busa/incsearch.vim'
2018-06-09 22:17:36 +00:00
Plug 'mhinz/vim-startify'
Plug 'ryanoasis/vim-devicons'
2018-08-17 12:49:53 +00:00
Plug 'scrooloose/nerdtree'
Plug 'sjl/gundo.vim'
2018-11-26 09:43:30 +00:00
Plug 'tomasiser/vim-code-dark'
2018-08-17 12:49:53 +00:00
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
2018-06-09 22:17:36 +00:00
" Programming helpers
2018-08-17 12:49:53 +00:00
Plug 'Chiel92/vim-autoformat'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'godlygeek/tabular'
Plug 'guns/xterm-color-table.vim'
2018-06-09 22:17:36 +00:00
Plug 'majutsushi/tagbar'
2018-11-23 14:02:18 +00:00
Plug 'prabirshrestha/vim-lsp'
2018-08-17 12:49:53 +00:00
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-sleuth'
2018-11-23 14:02:18 +00:00
Plug 'tpope/vim-surround'
2018-06-09 22:17:36 +00:00
" Language support
2018-11-23 14:02:18 +00:00
Plug 'artur-shaik/vim-javacomplete2'
2018-06-09 22:17:36 +00:00
Plug 'cespare/vim-toml'
2018-08-17 12:49:53 +00:00
Plug 'hsanson/vim-android'
Plug 'justmao945/vim-clang'
2018-11-23 14:02:18 +00:00
Plug 'martinda/Jenkinsfile-vim-syntax'
2018-08-17 12:49:53 +00:00
Plug 'mitsuhiko/vim-jinja'
Plug 'natebosch/vim-lsc'
2018-06-09 22:17:36 +00:00
Plug 'plasticboy/vim-markdown'
Plug 'posva/vim-vue'
2018-08-17 12:49:53 +00:00
Plug 'rust-lang/rust.vim'
Plug 'tikhomirov/vim-glsl'
Plug 'udalov/kotlin-vim'
2018-06-09 22:17:36 +00:00
call plug#end()
" Misc
set mouse=a
set nowrap
set shell=zsh
set scrolloff=5
set ruler
set backspace=2
set cursorline
set hidden
set wildmenu
set wildmode=longest:full
set splitright
set splitbelow
let &colorcolumn="+".join(range(1, 255), ",+")
let mapleader=","
set termguicolors
nnoremap <F4> :buffers<CR>:buffer<Space>
" Gundo
nnoremap <F9> :GundoToggle<CR>
" Tagbar
nmap <silent> <F8> :TagbarOpenAutoClose<CR>
let g:tagbar_sort = 0
" Airline
set laststatus=2
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
2018-11-26 09:43:30 +00:00
let g:airline_theme = 'codedark'
2018-06-09 22:17:36 +00:00
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = '| '
let g:airline_right_sep = ''
let g:airline_right_alt_sep = '|'
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.whitespace = 'Ξ'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#show_tab_nr = 0
let g:airline#extensions#tabline#show_tab_type = 0
" Syntax coloring
syntax enable
set synmaxcol=1024
2018-11-26 09:43:30 +00:00
set background=dark
colorscheme codedark
2018-06-09 22:17:36 +00:00
hi WarningMsg ctermbg=0
hi YcmErrorSign ctermbg=18 ctermfg=1
hi YcmWarningSign ctermbg=18 ctermfg=3
" indentLine
let g:indentLine_color_term = 20
let g:indentLine_char = '│'
let g:indentLine_concealcursor = ''
let g:indentLine_indentLevel = 25
let g:indentLine_fileType = ['vhdl']
" Startify
let g:startify_session_dir = $HOME . '/.nvim/sessions'
let g:startify_session_autoload = 1
let g:startify_session_persistence = 1
" Formatting
set encoding=utf-8
set tabstop=8
set shiftwidth=4
set expandtab
set autoindent
set cino=:0
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR> " Trim trailing spaces
set list listchars=tab:\ \ ,trail:•,precedes:…,extends:…
2018-11-23 14:02:01 +00:00
" Maximum line widths
au FileType text,markdown setlocal textwidth=80
au FileType python setlocal textwidth=79
2018-06-09 22:17:36 +00:00
" Line numbering
set number
" Search
set ignorecase
set smartcase
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
set hlsearch
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
" Undos
set undofile
set undodir=~/.nvim/undo
set undolevels=1000
set undoreload=10000
" Completion
set completeopt=menu,menuone,longest,preview
let g:ycm_confirm_extra_conf = 0
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_complete_in_comments = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_python_binary_path = 'python'
2018-08-17 12:49:53 +00:00
""" Shortcuts
2018-06-09 22:17:36 +00:00
"nnoremap <silent> <F4> :wa<CR>:split<CR>:terminal make run<CR>
vnoremap <C-y> "+y
inoremap <C-p> <ESC>"+pa
map <silent> <F2> :set invpaste<CR>
if has("nvim")
tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
endif
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
nnoremap <silent> <C-t> :tabnew<CR>
nnoremap <silent> <C-n> :tabnext<CR>
nnoremap <silent> <C-p> :tabprevious<CR>
nnoremap <C-[> <C-t>
2018-08-17 12:49:53 +00:00
""" Cache
2018-06-09 22:17:36 +00:00
set backupdir=~/.nvim/backup
set directory=~/.nvim/backup
2018-08-17 12:49:53 +00:00
""" Vimpager
2018-06-09 22:17:36 +00:00
if exists("vimpager")
au BufRead * set scrolloff=0
set noruler
set nocursorline
set colorcolumn=
set nonumber
au BufRead * set laststatus=0
let g:airline#extensions#tabline#enabled = 0
endif
let vimpager_disable_ansiesc = 1
2018-08-17 12:49:53 +00:00
""" vim-markdown
2018-06-09 22:17:36 +00:00
let g:vim_markdown_folding_disabled = 1
2018-08-17 12:49:53 +00:00
""" NerdTree
2018-06-09 22:17:36 +00:00
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
2018-08-17 12:49:53 +00:00
""" vim-autoformat
"au BufWrite * :Autoformat
""" vim-lsc
let g:lsc_server_commands = {'dart': 'dart_language_server'}
""" Deoplete
let g:deoplete#enable_at_startup = 1
""" vim-clang
let g:clang_c_options = '-std=c11'
let g:clang_cpp_options = '-std=c++17'
""" syntastic
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = '-std=c++17 -Wall -Wextra -pedantic'
""" vim-lsc
" C++/C
if executable('clangd')
au User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'],
\ })
endif
2018-11-23 14:02:18 +00:00
" Python
if executable('pyls')
" pip install python-language-server
au User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'whitelist': ['python'],
\ })
endif
2018-08-17 12:49:53 +00:00
" <Tab> completion:
" 1. If popup menu is visible, select and insert next item
" 2. Otherwise, if within a snippet, jump to next input
" 3. Otherwise, if preceding chars are whitespace, insert tab char
" 4. Otherwise, start manual autocomplete
imap <silent><expr><Tab> pumvisible() ? "\<Down>"
\ : (neosnippet#jumpable() ? "\<Plug>(neosnippet_jump)"
\ : (<SID>is_whitespace() ? "\<Tab>" : deoplete#manual_complete()))
smap <silent><expr><Tab> pumvisible() ? "\<Down>"
\ : (neosnippet#jumpable() ? "\<Plug>(neosnippet_jump)"
\ : (<SID>is_whitespace() ? "\<Tab>" : deoplete#manual_complete()))
inoremap <expr><S-Tab> pumvisible() ? "\<Up>" : "\<C-h>"
function! s:is_whitespace() "{{{
let col = col('.') - 1
return ! col || getline('.')[col - 1] =~? '\s'
endfunction "}}}
" }}}
2018-08-28 21:54:12 +00:00
""" vim-javacomplete2
autocmd FileType java setlocal omnifunc=javacomplete#Complete