Skip to content

Instantly share code, notes, and snippets.

@antonstakhouski
Last active March 15, 2020 21:04
Show Gist options
  • Save antonstakhouski/a2b04b8ac82d3cfb3c33bb4f864d6aeb to your computer and use it in GitHub Desktop.
Save antonstakhouski/a2b04b8ac82d3cfb3c33bb4f864d6aeb to your computer and use it in GitHub Desktop.
if &compatible
set nocompatible
endif
filetype off
" append to runtime path
set rtp+=/usr/share/vim/vimfiles
" initialize dein, plugins are installed to this directory
call dein#begin(expand('~/.cache/dein'))
" add packages here, e.g:
call dein#add('arakashic/chromatica.nvim')
call dein#add('mhinz/vim-janah')
call dein#add('mhinz/vim-startify')
call dein#add('mhinz/vim-signify')
call dein#add('tpope/vim-dispatch')
call dein#add('radenling/vim-dispatch-neovim')
call dein#add('critiqjo/lldb.nvim')
call dein#add('ncm2/ncm2')
call dein#add('roxma/nvim-yarp')
call dein#add('ncm2/ncm2-vim')
call dein#add('Shougo/neco-vim')
call dein#add('ncm2/ncm2-bufword')
call dein#add('ncm2/ncm2-path')
call dein#add('ncm2/ncm2-go')
call dein#add('ncm2/ncm2-ultisnips')
call dein#add('SirVer/ultisnips')
call dein#add('ncm2/ncm2-pyclang')
call dein#add('ncm2/ncm2-jedi')
call dein#add('fatih/vim-go')
call dein#add('AndrewRadev/splitjoin.vim')
call dein#add('ctrlpvim/ctrlp.vim')
call dein#add('jiangmiao/auto-pairs')
call dein#add('tpope/vim-fugitive')
call dein#add('nvie/vim-flake8')
call dein#add('ludovicchabant/vim-gutentags')
call dein#add('sbdchd/neoformat')
call dein#add('ncm2/ncm2-tmux')
call dein#add('Shougo/neco-syntax')
call dein#add('ncm2/ncm2-syntax')
call dein#add('ncm2/ncm2-neoinclude')
call dein#add('Shougo/neoinclude.vim')
call dein#add('lervag/vimtex')
" mat be not working at all
call dein#add('ncm2/ncm2-github')
call dein#add('ncm2/ncm2-tagprefix')
call dein#add('filipekiss/ncm2-look.vim')
call dein#add('yuki-ycino/ncm2-dictionary')
call dein#add('wellle/tmux-complete.vim')
"call dein#add('python-rope/ropevim.git')
" exit dein
call dein#end()
" auto-install missing packages on startup
if dein#check_install()
call dein#install()
endif
filetype plugin on
filetype plugin indent on
set shell=/bin/bash
set number
set visualbell
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
"colorscheme falcon
autocmd ColorScheme janah highlight Normal ctermbg=235
colorscheme janah
" vim-go
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_generate_tags = 1
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
set autowrite
map <C-n> :cnext<CR>
map <C-m> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
autocmd FileType go nmap <leader>r <Plug>(go-run)
let g:go_fmt_command = "goimports"
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
let g:go_metalinter_autosave = 1
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
let g:go_metalinter_deadline = "5s"
let g:go_addtags_transform = "camelcase"
autocmd FileType go nmap <leader>t <Plug>(go-test)
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
let g:go_auto_type_info = 1
let g:go_info_mode = "guru"
set updatetime=100
let g:go_auto_sameids = 1
autocmd FileType go nmap <Leader>i <Plug>(go-info)
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" au User Ncm2Plugin call ncm2#register_source({
" \ 'name' : 'vimtex',
" \ 'priority': 1,
" \ 'subscope_enable': 1,
" \ 'complete_length': 1,
" \ 'scope': ['tex'],
" \ 'matcher': {'name': 'combine',
" \ 'matchers': [
" \ {'name': 'abbrfuzzy', 'key': 'menu'},
" \ {'name': 'prefix', 'key': 'word'},
" \ ]},
" \ 'mark': 'tex',
" \ 'word_pattern': '\w+',
" \ 'complete_pattern': g:vimtex#re#ncm,
" \ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
" \ })
set completeopt=noinsert,menuone,noselect
" Press enter key to trigger snippet expansion
" The parameters are the same as `:help feedkeys()`
inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n')
" c-j c-k for moving in snippet
let g:UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
let g:UltiSnipsJumpForwardTrigger = "<C-j>"
let g:UltiSnipsJumpBackwardTrigger = "<C-k>"
let g:AutoPairsMapCR = 0
set noshowmode
" NERDcommenter
" Add spaces after comment delimiters by default
" let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
"let g:ycm_server_python_interpreter="/usr/bin/python2"
let g:loaded_youcompleteme = 1
let g:ycm_global_ycm_extra_conf = '/usr/share/vim/vimfiles/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
"au FileType c,cpp nnoremap <buffer> <c-]> :YcmCompleter GoTo<CR>
let g:chromatica#enable_at_startup=1
let g:chromatica#dotclangfile_search_path="../build"
set clipboard+=unnamedplus
set cursorline
set hlsearch
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
set encoding=utf-8
set autoindent
set smartindent
set ignorecase
set smartcase
set nobackup
set nowritebackup
set noswapfile
set history=100
set ruler
set incsearch
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab
" wrap lines at 120 chars. 80 is somewaht antiquated with nowadays displays.
set textwidth=120
set colorcolumn=120
" turn syntax highlighting on
syntax on
set nowrap
" highlight matching braces
set showmatch
"set backspace=indent,eol,start
" switch between header/source with F4
map <F4> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
map <F5> :Dispatch python %<CR>
map <F6> :Dispatch make <CR>
map <F12> :TagbarToggle<CR>
autocmd BufWinEnter * highlight ColorColumn ctermbg=DarkGrey
" Airline (status line)
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" Searching the file system
map <leader>' :NERDTreeToggle<cr>
" jump to last cursor
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
fun! StripTrailingWhitespace()
" don't strip on these filetypes
if &ft =~ 'markdown'
return
endif
%s/\s\+$//e
endfun
autocmd BufWritePre * call StripTrailingWhitespace()
" file formats
autocmd Filetype gitcommit setlocal spell textwidth=72
autocmd Filetype markdown setlocal wrap linebreak nolist textwidth=0 wrapmargin=0 " http://vim.wikia.com/wiki/Word_wrap_without_line_breaks
autocmd FileType sh,cucumber,ruby,yaml,zsh,vim setlocal shiftwidth=2 tabstop=2 expandtab
autocmd FileType c,h setlocal shiftwidth=8 tabstop=8 noexpandtab
autocmd FileType cpp,h setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab wrap textwidth=80 cindent colorcolumn=80
autocmd FileType py setlocal shiftwidth=4 softtabstop=4 tabstop=8 expandtab
" specify syntax highlighting for specific files
autocmd Bufread,BufNewFile *.spv set filetype=php
autocmd Bufread,BufNewFile *.md set filetype=markdown " Vim interprets .md as 'modula2' otherwise, see :set filetype?
" Close all folds when opening a new buffer
autocmd BufRead * setlocal foldmethod=marker
autocmd BufRead * normal zM
" Change colourscheme when diffing
fun! SetDiffColors()
highlight DiffAdd cterm=bold ctermfg=white ctermbg=DarkGreen
highlight DiffDelete cterm=bold ctermfg=white ctermbg=DarkGrey
highlight DiffChange cterm=bold ctermfg=white ctermbg=DarkBlue
highlight DiffText cterm=bold ctermfg=white ctermbg=DarkRed
endfun
autocmd FilterWritePre * call SetDiffColors()
" to use colors defined in the colorscheme
highlight link Flake8_Error Error
highlight link Flake8_Warning WarningMsg
highlight link Flake8_Complexity WarningMsg
highlight link Flake8_Naming WarningMsg
highlight link Flake8_PyFlake WarningMsg
let g:flake8_error_marker='EE' " set error marker to 'EE'
let g:flake8_warning_marker='WW' " set warning marker to 'WW'
let g:flake8_show_in_file=1 " show
let g:flake8_show_in_gutter=1 " show
"autocmd BufWritePost *.py call Flake8()
" a list of relative paths for compile_commands.json
let g:ncm2_pyclang#database_path = [
\ 'compile_commands.json',
\ 'build/compile_commands.json'
\ ]
augroup fmt
autocmd!
autocmd BufWritePre * undojoin | Neoformat
augroup END
au InsertEnter * call ncm2#enable_for_buffer()
au Filetype tex call ncm2#register_source({
\ 'name' : 'vimtex-cmds',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'prefix', 'key': 'word'},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#cmds,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au Filetype tex call ncm2#register_source({
\ 'name' : 'vimtex-labels',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'combine',
\ 'matchers': [
\ {'name': 'substr', 'key': 'word'},
\ {'name': 'substr', 'key': 'menu'},
\ ]},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#labels,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au Filetype tex call ncm2#register_source({
\ 'name' : 'vimtex-files',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'combine',
\ 'matchers': [
\ {'name': 'abbrfuzzy', 'key': 'word'},
\ {'name': 'abbrfuzzy', 'key': 'abbr'},
\ ]},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#files,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au Filetype tex call ncm2#register_source({
\ 'name' : 'bibtex',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'combine',
\ 'matchers': [
\ {'name': 'prefix', 'key': 'word'},
\ {'name': 'abbrfuzzy', 'key': 'abbr'},
\ {'name': 'abbrfuzzy', 'key': 'menu'},
\ ]},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#bibtex,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
let g:vimtex_compiler_progname = 'nvr'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment