dotfiles/config/nvim/init.vim

343 lines
9.5 KiB
VimL
Raw Permalink 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
2019-11-02 15:52:29 +00:00
Plug 'bronson/vim-visual-star-search'
2018-08-17 12:49:53 +00:00
Plug 'prabirshrestha/async.vim'
2020-03-04 12:27:36 +00:00
Plug 'tweekmonster/startuptime.vim'
2018-08-17 12:49:53 +00:00
2018-06-09 22:17:36 +00:00
" UI
2020-05-07 02:04:47 +00:00
Plug 'airblade/vim-gitgutter' " A Vim plugin which shows a git diff in the sign column.
Plug 'Asheq/close-buffers.vim' " This plug-in allows you to quickly bdelete several buffers at once.
Plug 'ctrlpvim/ctrlp.vim' " Full path fuzzy file, buffer, mru, tag, ... finder for Vim.
Plug 'haya14busa/incsearch.vim' " incsearch.vim incrementally highlights ALL pattern matches unlike default 'incsearch'.
Plug 'mhinz/vim-startify' " This plugin provides a start screen for Vim and Neovim.
2020-05-10 01:07:32 +00:00
Plug 'nightsense/snow'
2020-05-07 02:04:47 +00:00
Plug 'ryanoasis/vim-devicons' " Adds file type icons to Vim plugins
Plug 'scrooloose/nerdtree' " A tree explorer plugin for vim.
2020-05-10 01:07:32 +00:00
Plug 'sjl/gundo.vim'
2018-08-17 12:49:53 +00:00
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
2019-10-17 08:08:13 +00:00
Plug 'Yggdroot/indentLine'
2020-08-07 14:40:20 +00:00
Plug 'rakr/vim-one'
2018-06-09 22:17:36 +00:00
" Programming helpers
2020-08-11 22:18:22 +00:00
"Plug 'dense-analysis/ale'
"Plug 'deoplete-plugins/deoplete-jedi'
"Plug 'sebastianmarkow/deoplete-rust'
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
2020-05-07 02:04:47 +00:00
Plug 'bkad/CamelCaseMotion'
2020-08-11 22:18:22 +00:00
Plug 'Chiel92/vim-autoformat'
2020-03-04 12:27:36 +00:00
Plug 'easymotion/vim-easymotion'
2018-08-17 12:49:53 +00:00
Plug 'godlygeek/tabular'
2020-05-07 02:04:47 +00:00
Plug 'junegunn/vim-easy-align'
Plug 'majutsushi/tagbar'
2020-08-11 22:18:22 +00:00
Plug 'neoclide/coc.nvim', {'branch': 'release'}
2020-03-04 12:27:36 +00:00
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-eunuch'
2020-05-07 02:04:47 +00:00
Plug 'tpope/vim-fugitive'
2020-03-04 12:27:36 +00:00
Plug 'tpope/vim-git'
2018-08-17 12:49:53 +00:00
Plug 'tpope/vim-sleuth'
2020-03-04 12:27:36 +00:00
Plug 'tpope/vim-speeddating'
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'
2019-11-02 15:52:29 +00:00
Plug 'coc-extensions/coc-svelte'
2020-03-04 12:27:36 +00:00
Plug 'cstrahan/vim-capnp'
2019-10-17 08:08:13 +00:00
Plug 'digitaltoad/vim-pug'
2019-11-02 15:52:29 +00:00
Plug 'evanleck/vim-svelte'
2019-10-17 08:08:13 +00:00
Plug 'gryf/kickass-syntax-vim'
2020-03-04 12:27:36 +00:00
Plug 'hiphish/jinja.vim'
2018-08-17 12:49:53 +00:00
Plug 'hsanson/vim-android'
2020-08-11 22:18:22 +00:00
Plug 'jceb/vim-orgmode'
Plug 'keith/swift.vim'
2019-10-17 08:08:13 +00:00
Plug 'leafgarland/typescript-vim'
2020-03-04 12:27:36 +00:00
Plug 'lervag/vimtex'
2018-11-23 14:02:18 +00:00
Plug 'martinda/Jenkinsfile-vim-syntax'
2020-03-04 12:27:36 +00:00
Plug 'MaxMEllon/vim-jsx-pretty'
2020-03-04 15:56:12 +00:00
Plug 'mitsuhiko/vim-jinja'
2020-08-11 22:18:22 +00:00
Plug 'othree/yajs.vim'
2020-03-04 12:27:36 +00:00
Plug 'peitalin/vim-jsx-typescript'
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'
2019-10-17 08:08:13 +00:00
Plug 'ziglang/zig.vim'
2018-06-09 22:17:36 +00:00
call plug#end()
" Misc
set mouse=a
2020-03-04 12:27:36 +00:00
set wrap linebreak
set shell=fish
2018-06-09 22:17:36 +00:00
set scrolloff=5
set ruler
set backspace=2
set cursorline
set hidden
set wildmenu
set wildmode=longest:full
set splitright
set splitbelow
2019-11-02 15:52:29 +00:00
set relativenumber
2018-06-09 22:17:36 +00:00
let &colorcolumn="+".join(range(1, 255), ",+")
set termguicolors
nnoremap <F4> :buffers<CR>:buffer<Space>
2020-03-04 12:27:36 +00:00
let maplocalleader="\<space>"
2020-08-11 22:18:22 +00:00
let mapleader=","
2018-06-09 22:17:36 +00:00
" 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
2020-08-07 14:40:20 +00:00
let g:airline_theme = 'one'
2020-03-04 12:27:36 +00:00
let g:airline_left_sep = ''
2018-06-09 22:17:36 +00:00
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#show_tab_nr = 0
let g:airline#extensions#tabline#show_tab_type = 0
2020-03-04 12:27:36 +00:00
let g:airline#extensions#ale#enabled = 1
2018-06-09 22:17:36 +00:00
" Syntax coloring
syntax enable
set synmaxcol=1024
2020-08-07 14:40:20 +00:00
colorscheme one
set background=light
let g:one_allow_italics = 1
2018-06-09 22:17:36 +00:00
hi WarningMsg ctermbg=0
" indentLine
let g:indentLine_color_term = 20
let g:indentLine_char = '│'
let g:indentLine_concealcursor = ''
let g:indentLine_indentLevel = 25
2020-03-04 12:27:36 +00:00
let g:indentLine_fileType = ['vhdl', 'vim', 'tex', 'plaintex', 'cpp', 'cpp.jinja']
2018-06-09 22:17:36 +00:00
" Startify
let g:startify_session_dir = $HOME . '/.nvim/sessions'
let g:startify_session_autoload = 1
let g:startify_session_persistence = 1
2020-03-04 12:27:36 +00:00
let g:startify_change_to_dir = 0
let g:startify_change_to_vcs_root = 1
2018-06-09 22:17:36 +00:00
" Formatting
set encoding=utf-8
2020-03-04 12:27:36 +00:00
set tabstop=4
2018-06-09 22:17:36 +00:00
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
2019-11-02 15:52:29 +00:00
au FileType python setlocal textwidth=88
2020-03-04 12:27:36 +00:00
au FileType javascript setlocal textwidth=90
2019-11-02 15:52:29 +00:00
au FileType swift setlocal textwidth=120
2020-08-07 14:40:20 +00:00
au FileType zig setlocal textwidth=100
2020-03-04 12:27:36 +00:00
au FileType tex setlocal textwidth=90
au FileType cpp,cpp.jinja setlocal textwidth=90
" Formatters
au FileType javascript setlocal formatprg=prettier
au FileType javascript.jsx setlocal formatprg=prettier
2018-11-23 14:02:01 +00:00
2018-06-09 22:17:36 +00:00
" Line numbering
set number
" Search
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
2020-05-07 02:04:47 +00:00
set completeopt=menu,menuone,longest,noselect
2018-06-09 22:17:36 +00:00
2020-03-04 12:27:36 +00:00
" Open files at where they were closed.
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
2018-08-17 12:49:53 +00:00
""" Shortcuts
2018-06-09 22:17:36 +00:00
map <silent> <F2> :set invpaste<CR>
if has("nvim")
2020-03-04 12:27:36 +00:00
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
2018-06-09 22:17:36 +00:00
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")
2020-03-04 12:27:36 +00:00
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
2018-06-09 22:17:36 +00:00
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
""" Deoplete
2020-08-11 22:18:22 +00:00
"let g:deoplete#enable_at_startup = 1
"call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' })
2020-03-04 12:27:36 +00:00
""" ale
2020-08-11 22:18:22 +00:00
"let g:ale_linters = { 'python': ['flake8', 'mypy'], 'go': ['gopls'], 'cpp': ['clangcheck'] }
"let g:ale_fixers = {
"\ 'python': ['black'],
"\ 'cpp': ['clang-format'],
"\ 'javascript': ['eslint', 'prettier'],
"\ 'yaml': ['prettier'],
"\ 'go': ['gofmt', 'goimports'],
"\ }
"let g:ale_python_flake8_options='--max-line-length=88'
"let g:ale_python_mypy_options='--ignore-missing-imports'
"let g:ale_c_parse_compile_commands = 1
"let g:ale_c_build_dir_names = ['build', 'bin', '.']
"let g:ale_completion_enabled = 0
"set omnifunc=ale#completion#OmniFunc
2018-08-17 12:49:53 +00:00
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-28 21:54:12 +00:00
""" vim-javacomplete2
autocmd FileType java setlocal omnifunc=javacomplete#Complete
""" rust.vim
let g:rustfmt_autosave = 1
2019-10-17 08:08:13 +00:00
2020-03-04 12:27:36 +00:00
""" jinja.vim
autocmd! BufRead,BufNewFile *.cpp,*.html call jinja#AdjustFiletype()
2019-11-02 15:52:29 +00:00
" command! Workman set langmap=LO,OL,JN,NJ,KE,EK,HY,YH,lo,ol,jn,nj,ke,ek,hy,yh
" command! Qwerty set langmap=
2020-03-04 12:27:36 +00:00
""" Snippets
au FileType tex,plaintex nnoremap ,fig :-1read ~sijmen/.config/nvim/snippets/figure.tex<CR>j/[{:]}<CR>
au FileType tex,plaintex nnoremap ,lst :-1read ~sijmen/.config/nvim/snippets/listing.tex<CR>j/<Bslash>([=:]<Bslash>(,<Bslash><Bar>$<Bslash>)<Bslash><Bar>{}<Bslash><Bar>^$<Bslash>)<CR>
""" CamelCaseMotion
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
map <silent> ge <Plug>CamelCaseMotion_ge
sunmap w
sunmap b
sunmap e
sunmap ge
""" latex
let g:tex_conceal = 'adgms'
2020-08-07 14:41:49 +00:00
let g:tex_flavor = 'latex'
2020-03-04 12:27:36 +00:00
2019-11-02 15:52:29 +00:00
set path=$PWD/**
2020-03-04 15:56:12 +00:00
set wrap linebreak showbreak=↳\ " keep whitespace
set breakindent breakindentopt=shift:4
let g:ctrlp_map = '<c-p>'
2020-05-07 02:04:47 +00:00
""" vim-easy-align
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
2020-08-07 14:41:49 +00:00
let g:easy_align_delimiters = {
\ '\': { 'pattern': '\\' }
\ }
2020-05-07 02:04:47 +00:00
""" vim-go
let g:go_imports_autosave = 1
let g:go_auto_type_info = 1
2020-08-11 22:18:22 +00:00
""" coc
function! s:cocActionsOpenFromSelected(type) abort
execute 'CocCommand actions.open ' . a:type
endfunction
xmap <silent> <leader>c :<C-u>execute 'CocCommand actions.open ' . visualmode()<CR>
nmap <silent> <leader>c :<C-u>set operatorfunc=<SID>cocActionsOpenFromSelected<CR>g@
nmap <expr> <silent> <C-d> <SID>select_current_word()
function! s:select_current_word()
if !get(g:, 'coc_cursors_activated', 0)
return "\<Plug>(coc-cursors-word)"
endif
return "*\<Plug>(coc-cursors-word):nohlsearch\<CR>"
endfunc
nmap <leader>rn <Plug>(coc-rename)
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current)
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)
command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
""" ctrlp
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']