2019-05-10 17:44:12 +02:00
|
|
|
|
let $VIMHOME = expand('~/.vim')
|
|
|
|
|
" check if in tty
|
|
|
|
|
let g:is_tty = system('case $(tty) in (/dev/tty[0-9]) echo 1;; (*) echo 0;; esac')
|
|
|
|
|
|
|
|
|
|
" vim-plug init
|
|
|
|
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
2019-05-13 12:28:47 +02:00
|
|
|
|
system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
|
2019-05-10 17:44:12 +02:00
|
|
|
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call plug#begin('~/.vim/bundle')
|
|
|
|
|
|
|
|
|
|
""" Install Plugs
|
2019-05-13 12:28:47 +02:00
|
|
|
|
" vim-rooter
|
|
|
|
|
Plug 'airblade/vim-rooter'
|
|
|
|
|
|
|
|
|
|
" win-resizer
|
|
|
|
|
Plug 'simeji/winresizer'
|
2019-05-10 17:44:12 +02:00
|
|
|
|
|
|
|
|
|
" Deoplete.vim
|
|
|
|
|
Plug 'Shougo/deoplete.nvim'
|
|
|
|
|
Plug 'roxma/nvim-yarp'
|
|
|
|
|
Plug 'roxma/vim-hug-neovim-rpc'
|
|
|
|
|
let g:deoplete#enable_at_startup = 1
|
|
|
|
|
|
2019-05-13 12:28:47 +02:00
|
|
|
|
" neosnippets
|
|
|
|
|
Plug 'Shougo/neosnippet.vim'
|
|
|
|
|
Plug 'Shougo/neosnippet-snippets'
|
|
|
|
|
|
|
|
|
|
" deoplete-go
|
|
|
|
|
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make' }
|
|
|
|
|
|
|
|
|
|
" deoplete-jedi
|
|
|
|
|
Plug 'deoplete-plugins/deoplete-jedi'
|
|
|
|
|
|
2019-05-10 17:44:12 +02:00
|
|
|
|
" fzf
|
|
|
|
|
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
|
|
|
|
Plug 'junegunn/fzf.vim'
|
|
|
|
|
|
|
|
|
|
" NERDTree
|
|
|
|
|
Plug 'scrooloose/nerdtree'
|
|
|
|
|
Plug 'Xuyuanp/nerdtree-git-plugin'
|
|
|
|
|
|
|
|
|
|
" tagbar
|
|
|
|
|
Plug 'majutsushi/tagbar'
|
|
|
|
|
|
|
|
|
|
" vim-fugitive
|
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
|
|
|
|
|
|
" ALE
|
2019-05-13 12:28:47 +02:00
|
|
|
|
let g:ale_completion_enabled = 0
|
2019-05-10 17:44:12 +02:00
|
|
|
|
Plug 'w0rp/ale'
|
|
|
|
|
|
|
|
|
|
" vim-airline
|
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
|
|
|
|
|
|
|
|
" Colorschemes
|
|
|
|
|
Plug 'junegunn/seoul256.vim'
|
|
|
|
|
Plug 'scwood/vim-hybrid'
|
|
|
|
|
Plug 'kristijanhusak/vim-hybrid-material'
|
|
|
|
|
Plug 'srcery-colors/srcery-vim'
|
|
|
|
|
Plug 'nightsense/cosmic_latte'
|
|
|
|
|
Plug 'rafi/awesome-vim-colorschemes'
|
|
|
|
|
|
2019-05-13 18:30:52 +02:00
|
|
|
|
" indent-guides
|
|
|
|
|
Plug 'nathanaelkane/vim-indent-guides'
|
|
|
|
|
|
2019-05-10 17:44:12 +02:00
|
|
|
|
" Dockerfile.vim
|
|
|
|
|
Plug 'ekalinin/Dockerfile.vim'
|
|
|
|
|
|
|
|
|
|
" YAML
|
|
|
|
|
Plug 'mrk21/yaml-vim'
|
|
|
|
|
|
|
|
|
|
" Python
|
|
|
|
|
Plug 'ambv/black'
|
|
|
|
|
|
|
|
|
|
" TOML
|
|
|
|
|
Plug 'cespare/vim-toml'
|
|
|
|
|
|
|
|
|
|
" Autoclose
|
|
|
|
|
Plug 'jiangmiao/auto-pairs'
|
|
|
|
|
|
|
|
|
|
" vim-go
|
|
|
|
|
Plug 'fatih/vim-go'
|
|
|
|
|
|
|
|
|
|
" vim-multiple-cursor
|
|
|
|
|
Plug 'terryma/vim-multiple-cursors'
|
|
|
|
|
|
|
|
|
|
" rust.vim
|
|
|
|
|
Plug 'rust-lang/rust.vim'
|
|
|
|
|
|
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
2019-05-13 12:28:47 +02:00
|
|
|
|
""" vim-rooter
|
|
|
|
|
|
|
|
|
|
"let g:rooter_change_directory_for_non_project_files = 'current':
|
|
|
|
|
|
|
|
|
|
""" neosnippets
|
|
|
|
|
|
|
|
|
|
" Plugin key-mappings.
|
|
|
|
|
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
|
|
|
|
|
imap <C-k> <Plug>(neosnippet_expand_or_jump)
|
|
|
|
|
smap <C-k> <Plug>(neosnippet_expand_or_jump)
|
|
|
|
|
xmap <C-k> <Plug>(neosnippet_expand_target)
|
|
|
|
|
|
|
|
|
|
" SuperTab like snippets behavior.
|
|
|
|
|
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
|
|
|
|
|
"imap <expr><TAB>
|
|
|
|
|
" \ pumvisible() ? "\<C-n>" :
|
|
|
|
|
" \ neosnippet#expandable_or_jumpable() ?
|
|
|
|
|
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
|
|
|
|
|
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
|
|
|
|
|
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
|
|
|
|
|
|
|
|
|
|
" For conceal markers.
|
|
|
|
|
if has('conceal')
|
|
|
|
|
set conceallevel=2 concealcursor=niv
|
|
|
|
|
endif
|
|
|
|
|
|
2019-05-10 17:44:12 +02:00
|
|
|
|
""" ALE configuration
|
|
|
|
|
|
|
|
|
|
let g:ale_sign_error = '->'
|
|
|
|
|
let g:ale_sign_warning = '~>'
|
|
|
|
|
|
|
|
|
|
let g:ale_linters = {
|
|
|
|
|
\ 'javascript': ['eslint'],
|
|
|
|
|
\ 'golang': ['gopls', 'gofmt'],
|
2019-05-13 12:28:47 +02:00
|
|
|
|
\ 'python': ['pylint'],
|
2019-05-10 17:44:12 +02:00
|
|
|
|
\ 'rust': ['cargo'],
|
|
|
|
|
\}
|
|
|
|
|
|
|
|
|
|
let g:ale_fixers = {
|
|
|
|
|
\ 'javascript': ['prettier'],
|
|
|
|
|
\ 'golang': ['gopls', 'gofmt', 'goimports'],
|
|
|
|
|
\ 'python': ['black', 'python-language-server'],
|
2019-05-13 12:28:47 +02:00
|
|
|
|
\ 'rust': ['cargo', 'rustfmt'],
|
2019-05-10 17:44:12 +02:00
|
|
|
|
\}
|
|
|
|
|
|
|
|
|
|
let g:ale_echo_msg_error_str = 'Err'
|
|
|
|
|
let g:ale_echo_msg_warning_str = 'Warn'
|
|
|
|
|
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
|
|
|
|
|
|
|
|
|
|
let g:ale_go_langserver_executable = 'gopls'
|
2019-05-13 12:28:47 +02:00
|
|
|
|
let g:airline#extensions#ale#enabled = 1
|
|
|
|
|
|
|
|
|
|
""" deoplete
|
|
|
|
|
|
|
|
|
|
" let g:deoplete#sources = {'go': ['deoplete-go'], 'python': ['deoplete-jedi']}
|
2019-05-13 16:05:18 +02:00
|
|
|
|
call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' })
|
2019-05-10 17:44:12 +02:00
|
|
|
|
|
|
|
|
|
""" Themes and colors
|
|
|
|
|
|
|
|
|
|
set background=dark
|
|
|
|
|
colorscheme hybrid_reverse
|
|
|
|
|
let g:airline_theme='hybrid'
|
|
|
|
|
set number
|
|
|
|
|
let g:enable_bold_font = 1
|
|
|
|
|
let g:enable_italic_font = 1
|
|
|
|
|
|
|
|
|
|
" air-line
|
|
|
|
|
let g:airline_powerline_fonts = 1
|
|
|
|
|
|
|
|
|
|
if !exists('g:airline_symbols') && !g:is_tty
|
|
|
|
|
let g:airline_symbols = {}
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" unicode symbols
|
|
|
|
|
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.branch = '⎇'
|
|
|
|
|
let g:airline_symbols.paste = 'ρ'
|
|
|
|
|
" let g:airline_symbols.paste = 'Þ'
|
|
|
|
|
" let g:airline_symbols.paste = '∥'
|
|
|
|
|
let g:airline_symbols.whitespace = 'Ξ'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" FZF
|
|
|
|
|
|
|
|
|
|
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
|
|
|
|
|
|
|
|
|
|
let g:fzf_action = {
|
|
|
|
|
\ 'ctrl-t': 'tabedit',
|
|
|
|
|
\ 'ctrl-v': 'vsplit',
|
|
|
|
|
\ 'ctrl-x': 'split' }
|
|
|
|
|
let g:fzf_buffers_jump = 1
|
|
|
|
|
|
|
|
|
|
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
|
|
|
|
|
|
|
|
|
|
""" NERDTree
|
|
|
|
|
|
|
|
|
|
" Close NERDTree automatically after opening a file with it.
|
|
|
|
|
let g:NERDTreeQuitOnOpen = 1
|
|
|
|
|
" Use a single click for opening things in NERDTree
|
|
|
|
|
let g:NERDTreeMouseMode = 3
|
|
|
|
|
let g:NERDTreeMapActivateNode = '<Space>'
|
|
|
|
|
let g:NERDTreeIgnore = [
|
|
|
|
|
\ '\.pyc$',
|
|
|
|
|
\ '^__pycache__$',
|
|
|
|
|
\]
|
|
|
|
|
|
|
|
|
|
" ripgrep
|
|
|
|
|
if executable('rg')
|
|
|
|
|
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
|
|
|
|
|
set grepprg=rg\ --vimgrep
|
|
|
|
|
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Search in files with ripgrep + preview with bat
|
|
|
|
|
function! Fzf_dev()
|
|
|
|
|
let l:fzf_files_options = '--preview "bat --style=numbers,changes --color always {2..-1} | head -'.&lines.'"'
|
|
|
|
|
|
|
|
|
|
function! s:files()
|
|
|
|
|
let l:files = split(system($FZF_DEFAULT_COMMAND), '\n')
|
|
|
|
|
return s:format_list(l:files)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:format_list(candidates)
|
|
|
|
|
let l:result = []
|
|
|
|
|
for l:candidate in a:candidates
|
|
|
|
|
let l:filename = fnamemodify(l:candidate, ':p:t')
|
|
|
|
|
let l:icon = ">-"
|
|
|
|
|
call add(l:result, printf('%s %s', l:icon, l:candidate))
|
|
|
|
|
endfor
|
|
|
|
|
|
|
|
|
|
return l:result
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:edit_file(item)
|
|
|
|
|
let l:pos = stridx(a:item, ' ')
|
|
|
|
|
let l:file_path = a:item[pos+1:-1]
|
|
|
|
|
execute 'silent e' l:file_path
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
call fzf#run({
|
|
|
|
|
\ 'source': <sid>files(),
|
|
|
|
|
\ 'sink': function('s:edit_file'),
|
|
|
|
|
\ 'options': '-m ' . l:fzf_files_options,
|
|
|
|
|
\ 'down': '40%' })
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
""" general
|
|
|
|
|
|
|
|
|
|
set nospell
|
2019-05-13 12:28:47 +02:00
|
|
|
|
" restore screen after quitting
|
|
|
|
|
" au VimLeave * :!clear
|
2019-05-10 17:44:12 +02:00
|
|
|
|
|
|
|
|
|
packloadall
|
|
|
|
|
|
|
|
|
|
silent! helptags ALL
|
|
|
|
|
|
|
|
|
|
" Enable persistent undo
|
|
|
|
|
set undodir=$VIMHOME/.undo//
|
|
|
|
|
set undofile
|
|
|
|
|
set undolevels=1000 "maximum number of changes that can be undone
|
|
|
|
|
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
|
|
|
|
|
|
|
|
|
|
" Automatically re-open files after they have changed without prompting.
|
|
|
|
|
" This can be a little more destructive, but a lot less annoying.
|
|
|
|
|
set autoread
|
|
|
|
|
|
|
|
|
|
set autoindent
|
|
|
|
|
set showmatch
|
|
|
|
|
|
|
|
|
|
" Put all special files in the right place
|
|
|
|
|
set backupdir=$VIMHOME/.backup//
|
|
|
|
|
set directory=$VIMHOME/.swp//
|
|
|
|
|
|
|
|
|
|
" Draw tabs and trailing spaces.
|
|
|
|
|
" set listchars=tab:<->
|
2019-05-13 18:30:52 +02:00
|
|
|
|
let g:indent_guides_enable_on_vim_startup = 1
|
|
|
|
|
let g:indent_guides_start_level = 2
|
|
|
|
|
let g:indent_guides_guide_size = 1
|
2019-05-10 17:44:12 +02:00
|
|
|
|
set listchars=tab:›\ ,trail:•,extends:#,nbsp:.
|
2019-05-13 18:30:52 +02:00
|
|
|
|
hi IndentGuidesOdd ctermbg=white
|
|
|
|
|
hi IndentGuidesEven ctermbg=lightgrey
|
2019-05-10 17:44:12 +02:00
|
|
|
|
set list
|
|
|
|
|
|
|
|
|
|
" Set the right margin.
|
|
|
|
|
set colorcolumn=89
|
|
|
|
|
" Automatically split words at the margin.
|
2019-05-13 12:28:47 +02:00
|
|
|
|
" set wrap
|
2019-05-10 17:44:12 +02:00
|
|
|
|
|
|
|
|
|
" Default to spaces instead of tabs
|
|
|
|
|
set expandtab
|
|
|
|
|
|
|
|
|
|
" Set tab width to 4.
|
|
|
|
|
set tabstop=4
|
|
|
|
|
set shiftwidth=4
|
|
|
|
|
" Setting this will make backspace delete space indents
|
|
|
|
|
set softtabstop=4
|
|
|
|
|
|
|
|
|
|
" Disable automatic wrapping.
|
|
|
|
|
set textwidth=0
|
|
|
|
|
|
|
|
|
|
" Make :Q and :W work like :q and :w
|
|
|
|
|
command! W w
|
|
|
|
|
command! Q q
|
|
|
|
|
|
|
|
|
|
" Make completion smarter.
|
|
|
|
|
set ignorecase
|
|
|
|
|
set smartcase
|
|
|
|
|
|
|
|
|
|
" viminfo settings
|
|
|
|
|
" '100 : Remember marks for 100 previously edited files.
|
|
|
|
|
" <50 : ???
|
|
|
|
|
" s10 : ???
|
|
|
|
|
" h : ???
|
|
|
|
|
" "100 : Save 100 lines for each register
|
|
|
|
|
" :50 : Remember 50 lines of command history
|
|
|
|
|
set viminfo='100,<50,s10,h,\"100,:50
|
|
|
|
|
|
|
|
|
|
" Jump at last opened cursor position position, if valid
|
|
|
|
|
if has("autocmd")
|
|
|
|
|
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
|
|
|
|
|
\| exe "normal! g'\"" | endif
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Warn about not being able to write to .viminfo, which messes up restoring
|
|
|
|
|
" the cursor position when editing.
|
|
|
|
|
let s:info_filename = expand('~/.viminfo')
|
|
|
|
|
|
|
|
|
|
if !empty(glob(s:info_filename)) && !filewritable(s:info_filename)
|
|
|
|
|
echoerr 'The .viminfo file cannot be written to!'
|
|
|
|
|
endif
|
|
|
|
|
|
2019-06-26 11:13:04 +02:00
|
|
|
|
""" powerline
|
|
|
|
|
let g:powerline_pycmd = "py3"
|
2019-05-10 17:44:12 +02:00
|
|
|
|
|
|
|
|
|
""" keybindings
|
|
|
|
|
|
|
|
|
|
let mapleader = ','
|
|
|
|
|
nnoremap <silent> <C-d> :bd<CR>
|
|
|
|
|
nnoremap <C-e> :NERDTree<CR>
|
2019-05-13 16:04:43 +02:00
|
|
|
|
nnoremap <leader>r :redo<CR>
|
2019-05-10 17:44:12 +02:00
|
|
|
|
nnoremap <C-h> <C-w><Left>
|
|
|
|
|
nnoremap <C-j> <C-w><Down>
|
|
|
|
|
nnoremap <C-k> <C-w><Up>
|
|
|
|
|
nnoremap <C-l> <C-w><Right>
|
|
|
|
|
nnoremap <C-t> :Tagbar<CR>
|
|
|
|
|
nnoremap <leader>b :Gblame<CR>
|
|
|
|
|
nnoremap <C-p> :FZF<CR>
|
|
|
|
|
nnoremap <C-a> :Buffers<CR>
|
|
|
|
|
nnoremap <C-F> :Files<CR>
|
|
|
|
|
nnoremap <C-\> :Rg<CR>
|
|
|
|
|
nnoremap <leader>\ :call Fzf_dev()<CR>
|
2019-05-13 16:04:43 +02:00
|
|
|
|
nnoremap <leader>c :Commits<CR>
|
|
|
|
|
nnoremap <leader>b :Gblame<CR>
|
2019-05-10 17:44:12 +02:00
|
|
|
|
map <leader><Tab> :bnext<CR>
|
|
|
|
|
map <leader><S-Tab> :bprev<CR>
|