Skip to content

Instantly share code, notes, and snippets.

@alexniver
Last active April 29, 2018 17:33
Show Gist options
  • Save alexniver/b818c6283149c8b02c7b5a4c7d1663d6 to your computer and use it in GitHub Desktop.
Save alexniver/b818c6283149c8b02c7b5a4c7d1663d6 to your computer and use it in GitHub Desktop.
my neovim config
let mapleader = ","
set nocompatible " Disable compatibility to old-time vi
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set mouse=v " middle-click paste with mouse
set hlsearch " highlight search results
set tabstop=4 " number of columns occupied by a tab character
set softtabstop=4 " see multiple spaces as tabstops so <BS> does the right thing
set expandtab " converts tabs to white space
set shiftwidth=4 " width for autoindents
set autoindent " indent a new line the same amount as the line just typed
set number " add line numbers
set wildmode=longest,list " get bash-like tab completions
set cc=80 " set an 80 column border for good coding style
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')
" Make sure you use single quotes
Plug 'drewtempelmeyer/palenight.vim'
Plug 'tpope/vim-fugitive'
Plug 'kien/ctrlp.vim'
Plug 'andrewradev/splitjoin.vim'
Plug 'sirver/ultisnips'
Plug 'fatih/molokai'
Plug 'rstacruz/sparkup'
Plug 'wincent/command-t'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" deoplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'zchee/deoplete-go', {'build': {'unix': 'make'}}
Plug 'jodosha/vim-godebug' " Debugger integration via delve
call plug#end()
" deoplete
let g:deoplete#enable_at_startup = 1
" golang
let g:go_fmt_command = "goimports"
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)
"this make a quick quit window for go run
set splitright
autocmd FileType go nmap <leader>r :w<CR>:vsplit <bar> terminal go run %<CR>
autocmd FileType go nmap <leader>t <Plug>(go-test)
autocmd FileType go nmap <leader>d <Plug>(go-doc)
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)
" beauty go
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
let g:rehash256 = 1
let g:molokai_original = 1
colorscheme molokai
let g:go_metalinter_autosave = 1
let g:go_metalinter_deadline = "5s"
let g:go_auto_sameids = 1
let g:go_test_timeout = '60s'
let g:go_term_enabled=1
let g:go_term_mode = "new"
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')
autocmd FileType go nmap <Leader>i <Plug>(go-info)
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
hi comment ctermfg=6
" set tab, default 4 space
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
" html/js/coffe/jade, use 2 space
autocmd Filetype html setlocal ts=2 sw=2 expandtab
autocmd Filetype javascript setlocal ts=2 sw=2 expandtab
autocmd Filetype coffeescript setlocal ts=2 sw=2 expandtab
autocmd Filetype jade setlocal ts=2 sw=2 expandtab
" autocomplete
let g:deoplete#enable_at_startup = 1
let g:deoplete#sources#go#gocode_binary = $GOPATH.'/bin/gocode'
let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
" nerdtree
map <F2> :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1
" auto locate to last edit pos
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment