Skip to content

Instantly share code, notes, and snippets.

@mishudark
Created February 12, 2020 11:32
Show Gist options
  • Save mishudark/b5b8f13ff39a864bce974321a5b8b25f to your computer and use it in GitHub Desktop.
Save mishudark/b5b8f13ff39a864bce974321a5b8b25f to your computer and use it in GitHub Desktop.
$HOME/.config/nvim/init.vim
" vim:foldmethod=marker:foldlevel=0
" zo + zc to open / close folds in case I forgot :P
if (!isdirectory(expand("$HOME/.config/nvim/repos/github.com/Shougo/dein.vim")))
call system(expand("mkdir -p $HOME/.config/nvim/repos/github.com"))
call system(expand("git clone https://github.com/Shougo/dein.vim $HOME/.config/nvim/repos/github.com/Shougo/dein.vim"))
endif
" DEIN {{{
set runtimepath+=~/.config/nvim/repos/github.com/Shougo/dein.vim/
call dein#begin(expand('~/.config/nvim'))
call dein#add( 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' })
call dein#add('Shougo/neosnippet')
call dein#add('Shougo/neosnippet-snippets') " Default snippets for many languages
call dein#add( 'scrooloose/nerdtree')
call dein#add('easymotion/vim-easymotion')
call dein#add( 'bling/vim-airline')
call dein#add( 'tomtom/tcomment_vim' )
call dein#add('junegunn/vim-easy-align')
call dein#add( 'tpope/vim-surround' )
call dein#add( 'leafgarland/typescript-vim', { 'for': 'typescript' })
"call dein#add( 'w0rp/ale', {'rev': 'v2.3.0' })
call dein#add('dense-analysis/ale')
call dein#add('christoomey/vim-tmux-navigator')
call dein#add('Raimondi/delimitMate')
call dein#add('junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' })
call dein#add('junegunn/fzf.vim')
call dein#add('sotte/presenting.vim')
call dein#add('tybenz/vimdeck')
call dein#add('tpope/vim-markdown')
call dein#add('vim-scripts/SyntaxRange')
call dein#add('dart-lang/dart-vim-plugin')
call dein#add('natebosch/vim-lsc')
call dein#add('natebosch/vim-lsc-dart')
"call dein#add('tbodt/deoplete-tabnine', { 'build': './install.sh' })
call dein#add('MaxMEllon/vim-jsx-pretty')
" Colorschemes
call dein#add('mhartington/oceanic-next')
" Language plugins
" Scala plugins
if executable('scalac')
call dein#add( 'derekwyatt/vim-scala', { 'for': 'scala' })
call dein#add( 'ensime/ensime-vim', {'do': ':UpdateRemotePlugins'})
endif
" Rust
if executable('rustc')
call dein#add( 'rust-lang/rust.vim', { 'for': 'rust' })
call dein#add( 'racer-rust/vim-racer', { 'for': 'rust' })
endif
" Go
if executable('go')
call dein#add('fatih/vim-go')
call dein#add('mdempsky/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' })
call dein#add('zchee/deoplete-go', { 'do': 'make'})
endif
" Haskell
call dein#add('neovimhaskell/haskell-vim')
if dein#check_install()
call dein#install()
let pluginsExist=1
endif
call dein#end()
" }}}
"
" LOOK AND SYNTAX HILIGHTING {{{
syntax on
colorscheme OceanicNext
set termguicolors
" whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd Syntax * syn match ExtraWhitespace /\s\+$/ containedin=ALL
" Undefined Marks
highlight UndefinedMarks ctermfg=yellow
"autocmd Syntax * syn match UndefinedMarks /???/ containedin=ALL
" Automatic syntax highlighting for files
au BufRead,BufNewFile *.sbt set filetype=scala
au BufRead,BufNewFile *.conf set filetype=dosini
au BufRead,BufNewFile *.bash* set filetype=sh
au BufRead,BufNewFile *.jsonnet* set filetype=c
au BufRead,BufNewFile *.libsonnet* set filetype=c
" Better split character
" Override color scheme to make split them black
" set fillchars=vert:\|
"set fillchars=vert:│
set colorcolumn=101
set cursorline
" }}}
" KEYMAPPINGS {{{
" Leader key
let mapleader = ","
" arrow keys disable
nnoremap <right> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <up> <nop>
vnoremap <right> <nop>
vnoremap <down> <nop>
vnoremap <left> <nop>
vnoremap <up> <nop>
" j/k move virtual lines, gj/jk move physical lines
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" Remap increment and decrement numbers to something that works on macs/linux
nnoremap <A-a> <C-a>
nnoremap <A-x> <C-x>
" panes
nnoremap <leader>d :vsp<cr>
set splitright
nnoremap <leader>s :split<cr>
set splitbelow
" map <C-w>w (switch buffer focus) to something nicer
nnoremap <leader>w <C-w>w
" tabs
nnoremap <leader>] :tabn<cr>
nnoremap <leader>[ :tabp<cr>
nnoremap <leader>T :tabe<cr>
" Insert date
nnoremap <leader>fd "=strftime("%m-%d-%y")<CR>p
" Edit vimrc
nnoremap <leader>ev :edit $MYVIMRC<cr>
nnoremap <leader>evs :source $MYVIMRC<cr>
" Toggle paste with F2
set pastetoggle=<F2>
" Terminal Mode
" Use escape to go back to normal mode
tnoremap <Esc> <C-\><C-n>
" }}}
set showmatch
" GENERAL/TOGGLEABLE SETTINGS {{{
" horizontal split splits below
set splitbelow
set clipboard=unnamedplus
" indentation
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
set smartindent
set tabstop=2
"set formatoptions=tcqron
"filetype indent off
" line numbers
set number
" show title
set title
" mouse
set mouse-=a
" utf-8 ftw
" Ignore case unless use a capital in search (smartcase needs ignore set)
set ignorecase
set smartcase
" Textwidth for folding
set textwidth=100
set noswapfile " disable swapfile usage<Paste>
set noerrorbells " No bells!
set novisualbell " I said, no bells!
" Disable cursor styling in new neovim version
set guicursor=
" }}}
" PLUGINS + CUSTOM FUNCTIONS {{{
" Custom
" deoplete
let g:deoplete#enable_at_startup=1
inoremap <silent><expr> <Tab> pumvisible() ? "\<C-n>" : "\<C-i>"
" sarsi
let sarsivim = 'sarsi-nvim'
if (executable(sarsivim))
call rpcstart(sarsivim)
" nnoremap <leader>l :cfirst<cr>
nnoremap <leader>f :cnext<cr>
nnoremap <leader>g :cprevious<cr>
endif
" Ripgrep for search
if executable('rg')
set grepprg=rg\ -i\ --vimgrep
" Ripgrep on /
command! -nargs=+ -complete=file -bar Rg silent! grep! <args>|cwindow|redraw!
nnoremap <leader>/ :Rg<SPACE>
endif
" airline
set laststatus=2
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#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#show_tab_nr = 1
let g:airline#extensions#tabline#tab_nr_type = 1 " show tab number not number of split panes
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#show_buffers = 0
" let g:airline#extensions#hunks#enabled = 0
" let g:airline_section_z = ""
" Enable top tabline.
let g:airline#extensions#tabline#enabled = 1
" Disable showing tabs in the tabline. This will ensure that the buffers are
" what is shown in the tabline at all times.
let g:airline#extensions#tabline#show_tabs = 0
let g:airline#extensions#tabline#buffer_idx_mode = 1
tmap <leader>1 <C-\><C-n><Plug>AirlineSelectTab1
tmap <leader>2 <C-\><C-n><Plug>AirlineSelectTab2
tmap <leader>3 <C-\><C-n><Plug>AirlineSelectTab3
tmap <leader>4 <C-\><C-n><Plug>AirlineSelectTab4
tmap <leader>5 <C-\><C-n><Plug>AirlineSelectTab5
tmap <leader>6 <C-\><C-n><Plug>AirlineSelectTab6
tmap <leader>7 <C-\><C-n><Plug>AirlineSelectTab7
tmap <leader>8 <C-\><C-n><Plug>AirlineSelectTab8
tmap <leader>9 <C-\><C-n><Plug>AirlineSelectTab9
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
" FZF
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --no-messages "" .'
set grepprg=rg\ --vimgrep
endif
let g:fzf_command_prefix = 'Fzf'
if executable('fzf')
nnoremap <leader>v :FzfFiles<cr>
nnoremap <leader>u :FzfTags<cr>
nnoremap <leader>j :call fzf#vim#tags("'".expand('<cword>'))<cr>
if executable('rg')
" :Find <term> runs `rg <term>` and passes it to fzf
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --color "always" '.shellescape(<q-args>), 1, <bang>0)
nnoremap <leader>/ :Find
nnoremap <leader>' :execute "Find " . expand("<cword>")<cr>
endif
else
nnoremap <leader>v :CtrlP<Space><cr>
endif
" Racer
set hidden
let g:racer_cmd = "/home/yc00118/.cargo/bin/racer"
let g:racer_experimental_completer = 1
au FileType rust nmap <leader>rx <call dein#add(>(rust-doc)
au FileType rust nmap <leader>rd <call dein#add(>(rust-def)
au FileType rust nmap <leader>rs <call dein#add(>(rust-def-split)
"----------------------------------------------
" Plugin: w0rp/ale
"----------------------------------------------
let g:ale_linters = {
\ 'dart': ['language_server'],
\ 'go': ['gopls'],
\ 'rust': ['rls', 'rustc'],
\ 'python': ['pylama'],
\}
let g:ale_go_bingo_executable = 'gopls'
" Error and warning signs.
let g:ale_go_gometalinter_options = ' --aggregate --fast --sort=line --vendor --vendored-linters --disable=gas --disable=goconst --disable=gocyclo '
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ 'dart': ['dartfmt'],
\}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
"let g:ale_linters = {'go':['golint', 'govet']}
"let g:ale_linters = {'go':['golint', 'gometalinter', 'go vet', 'staticcheck']}
let g:ale_open_list = 0
let g:ale_set_highlights = 0
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '✖'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '⚠'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 0
" Enable integration with airline.
let g:airline#extensions#ale#enabled = 1
"----------------------------------------------
" Plugin: scrooloose/nerdtree
"----------------------------------------------
nnoremap <leader>d :NERDTreeToggle<cr>
nnoremap <F2> :NERDTreeToggle<cr>
let NERDTreeQuitOnOpen=1
" Files to ignore
let NERDTreeIgnore = [
\ '\~$',
\ '\.pyc$',
\ '^\.DS_Store$',
\ '^node_modules$',
\ '^vendor$',
\ '^.ropeproject$',
\ '^__pycache__$'
\]
"----------------------------------------------
" Plugin: junegunn/vim-easy-align
"----------------------------------------------
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
"----------------------------------------------
" Plugin: Shougo/neosnippet
"----------------------------------------------
" Disable the default snippets (needed since we do not install
" Shougo/neosnippet-snippets).
"
" Below you can disable default snippets for specific languages. If you set the
" language to _ it sets the default for all languages.
" let g:neosnippet#disable_runtime_snippets = {
" \ 'go': 1
" \}
" Keybindings
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
let g:deoplete#ignore_sources = {}
let g:deoplete#ignore_sources._ = ["neosnippet"]
" I want to use my tab more smarter. If we are inside a completion menu jump
" to the next item. Otherwise check if there is any snippet to expand, if yes
" expand it. Also if inside a snippet and we need to jump tab jumps. If none
" of the above matches we just call our usual 'tab'.
function! s:neosnippet_complete()
if neosnippet#expandable_or_jumpable()
return "\<Plug>(neosnippet_expand_or_jump)"
else
if pumvisible()
return "\<c-n>"
endif
return "\<tab>"
endif
endfunction
imap <expr><TAB> <SID>neosnippet_complete()
" For conceal markers.
"if has('conceal')
" set conceallevel=2 concealcursor=niv
"endif
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Set the path to our snippets
let g:neosnippet#snippets_directory='~/.config/nvim/snippets'
"----------------------------------------------
" Plugin: easymotion/vim-easymotion
"----------------------------------------------
" Enable support for bidirectional motions
nmap <space> <Plug>(easymotion-s2)
"----------------------------------------------
" Plugin: christoomey/vim-tmux-navigator
"----------------------------------------------
" tmux will send xterm-style keys when its xterm-keys option is on
if &term =~ '^screen'
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
" Tmux vim integration
let g:tmux_navigator_no_mappings = 1
let g:tmux_navigator_save_on_switch = 1
" Move between splits with ctrl+h,j,k,l
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
nnoremap <silent> <c-\> :TmuxNavigatePrevious<cr>
"----------------------------------------------
" Language: apiblueprint
"----------------------------------------------
au FileType apiblueprint set expandtab
au FileType apiblueprint set shiftwidth=4
au FileType apiblueprint set softtabstop=4
au FileType apiblueprint set tabstop=4
"----------------------------------------------
" Language: Bash
"----------------------------------------------
au FileType sh set noexpandtab
au FileType sh set shiftwidth=2
au FileType sh set softtabstop=2
au FileType sh set tabstop=2
"----------------------------------------------
" Language: CSS
"----------------------------------------------
au FileType css set expandtab
au FileType css set shiftwidth=2
au FileType css set softtabstop=2
au FileType css set tabstop=2
"----------------------------------------------
" Language: gitcommit
"----------------------------------------------
au FileType gitcommit setlocal spell
au FileType gitcommit setlocal textwidth=80
"----------------------------------------------
" Language: fish
"----------------------------------------------
au FileType fish set expandtab
au FileType fish set shiftwidth=2
au FileType fish set softtabstop=2
au FileType fish set tabstop=2
"----------------------------------------------
" Language: HTML
"----------------------------------------------
au FileType html set expandtab
au FileType html set shiftwidth=2
au FileType html set softtabstop=2
au FileType html set tabstop=2
"----------------------------------------------
" Language: JavaScript
"----------------------------------------------
au FileType javascript set expandtab
au FileType javascript set smartindent
au FileType javascript set autoindent
au FileType javascript set shiftwidth=2
au FileType javascript set softtabstop=2
au FileType javascript set tabstop=2
"----------------------------------------------
" Language: JSON
"----------------------------------------------
au FileType json set expandtab
au FileType json set shiftwidth=2
au FileType json set softtabstop=2
au FileType json set tabstop=2
"----------------------------------------------
" Language: LESS
"----------------------------------------------
au FileType less set expandtab
au FileType less set shiftwidth=2
au FileType less set softtabstop=2
au FileType less set tabstop=2
"----------------------------------------------
" Language: Make
"----------------------------------------------
au FileType make set noexpandtab
au FileType make set shiftwidth=2
au FileType make set softtabstop=2
au FileType make set tabstop=2
"----------------------------------------------
" Language: Markdown
"----------------------------------------------
au FileType markdown setlocal spell
au FileType markdown set expandtab
au FileType markdown set shiftwidth=4
au FileType markdown set softtabstop=4
au FileType markdown set tabstop=4
au FileType markdown set syntax=markdown
"----------------------------------------------
" Language: PlantUML
"----------------------------------------------
au FileType plantuml set expandtab
au FileType plantuml set shiftwidth=4
au FileType plantuml set softtabstop=4
au FileType plantuml set tabstop=4
"----------------------------------------------
" Language: Protobuf
"----------------------------------------------
au FileType proto set expandtab
au FileType proto set shiftwidth=2
au FileType proto set softtabstop=2
au FileType proto set tabstop=2
"----------------------------------------------
" Language: Python
"----------------------------------------------
au FileType python set expandtab
au FileType python set shiftwidth=4
au FileType python set softtabstop=4
au FileType python set tabstop=4
"let g:ale_fixers = {'python': ['yapf']}
"----------------------------------------------
" Language: Ruby
"----------------------------------------------
au FileType ruby set expandtab
au FileType ruby set shiftwidth=2
au FileType ruby set softtabstop=2
au FileType ruby set tabstop=2
"----------------------------------------------
" Language: SQL
"----------------------------------------------
au FileType sql set expandtab
au FileType sql set shiftwidth=2
au FileType sql set softtabstop=2
au FileType sql set tabstop=2
"----------------------------------------------
" Language: Thrift
"----------------------------------------------
au FileType thrift set expandtab
au FileType thrift set shiftwidth=2
au FileType thrift set softtabstop=2
au FileType thrift set tabstop=2
"----------------------------------------------
" Language: TOML
"----------------------------------------------
au FileType toml set expandtab
au FileType toml set shiftwidth=2
au FileType toml set softtabstop=2
au FileType toml set tabstop=2
"----------------------------------------------
" Language: Vader
"----------------------------------------------
au FileType vader set expandtab
au FileType vader set shiftwidth=2
au FileType vader set softtabstop=2
au FileType vader set tabstop=2
"----------------------------------------------
" Language: vimscript
"----------------------------------------------
au FileType vim set expandtab
au FileType vim set shiftwidth=4
au FileType vim set softtabstop=4
au FileType vim set tabstop=4
"----------------------------------------------
" Language: YAML
"----------------------------------------------
au FileType yaml set expandtab
au FileType yaml set shiftwidth=2
au FileType yaml set softtabstop=2
au FileType yaml set tabstop=2
"----------------------------------------------
" Language: DART
"----------------------------------------------
au FileType dart set expandtab
au FileType dart set shiftwidth=2
au FileType dart set softtabstop=2
au FileType dart set tabstop=2
let dart_format_on_save = 0
let dart_style_guide = 2
"----------------------------------------------
" Language: LSP
"----------------------------------------------
set shortmess-=F
let g:lsc_server_commands = {'dart': 'dart_language_server'}
"----------------------------------------------
" Language: GO
"----------------------------------------------
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" Set neosnippet as snippet engine
let g:go_snippet_engine = "neosnippet"
"call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' })
"
"----------------------------------------------
" Language: RUST
"----------------------------------------------
let g:ale_fix_on_save=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment