more settings and natively support go

This commit is contained in:
Jie Feng 2017-08-02 00:15:51 +08:00
parent 6a75a4dae0
commit 0190dad747
6 changed files with 122 additions and 30 deletions

View File

@ -1,3 +1,18 @@
" The tree buffer makes it easy to drill down through the directories of your
" git repository, but its not obvious how you could go up a level to the
" parent directory. Heres a mapping of .. to the above command, but
" only for buffers containing a git blob or tree
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
" Every time you open a git object using fugitive it creates a new buffer.
" This means that your buffer listing can quickly become swamped with
" fugitive buffers. This prevents this from becomming an issue:
autocmd BufReadPost fugitive://* set bufhidden=delete
" fugitive.git " fugitive.git
" ======================================== " ========================================
" For fugitive.git, dp means :diffput. Define dg to mean :diffget " For fugitive.git, dp means :diffput. Define dg to mean :diffget

56
vim/settings/go.vim Normal file
View File

@ -0,0 +1,56 @@
let g:go_fmt_fail_silently = 1
let g:go_fmt_command = "gofmt" "Explicited the formater plugin (gofmt, goimports, goreturn...)
" Show a list of interfaces which is implemented by the type under your cursor
au FileType go nmap <Leader>s <Plug>(go-implements)
" Show type info for the word under your cursor
au FileType go nmap <Leader>i <Plug>(go-info)
" Open the relevant Godoc for the word under the cursor
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
" Open the Godoc in browser
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
" Run/build/test/coverage
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
" By default syntax-highlighting for Functions, Methods and Structs is disabled.
" Let's enable them!
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
nmap <F8> :TagbarToggle<CR>
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }

View File

@ -1,18 +1,20 @@
" Disable AutoComplPop. let g:acp_enableAtStartup = 0 " Disable AutoComplPop.
let g:acp_enableAtStartup = 0 let g:neocomplete#enable_at_startup = 1 " Use neocomplete.
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_camel_case = 1 let g:neocomplete#enable_camel_case = 1
let g:neocomplete#enable_smart_case = 1 let g:neocomplete#enable_smart_case = 1
" Default # of completions is 100, that's crazy. " Default # of completions is 100, that's crazy.
let g:neocomplete#max_list = 5 let g:neocomplete#max_list = 5
" Set minimum syntax keyword length. let g:neocomplete#auto_completion_start_length = 3 " Set minimum syntax keyword length.
let g:neocomplete#auto_completion_start_length = 3 let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
let g:neocomplete#enable_auto_select = 1 " AutoComplPop like behavior.
" Map standard Ctrl-N completion to Ctrl-Space " Map standard Ctrl-N completion to Ctrl-Space
inoremap <C-Space> <C-n> inoremap <C-Space> <C-n>
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
" This makes sure we use neocomplete completefunc instead of " This makes sure we use neocomplete completefunc instead of
" the one in rails.vim, otherwise this plugin will crap out. " the one in rails.vim, otherwise this plugin will crap out.
@ -24,6 +26,20 @@ if !exists('g:neocomplete#keyword_patterns')
endif endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*' let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Enable heavy omni completion.
"if !exists('g:neocomplete#sources#omni#input_patterns')
" let g:neocomplete#sources#omni#input_patterns = {}
"endif
"let g:neocomplete#force_omni_input_patterns.go = '[^.[:digit:] *\t]\.'
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#force_omni_input_patterns.go = '[^.[:digit:] *\t]\.'
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" Enable omni completion. " Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
@ -31,3 +47,20 @@ autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
" Recommended key-mappings.
" <CR>: close popup and save indent.
imap <expr><silent> <CR> <SID>my_cr_function()
function! s:my_cr_function()
return pumvisible() ? neocomplcache#close_popup() . "\<CR>" : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"

View File

@ -1,11 +1,11 @@
"mark syntax errors with :signs let g:syntastic_enable_signs=1 "mark syntax errors with :signs
let g:syntastic_enable_signs=1 let g:syntastic_auto_jump=0 "automatically jump to the error when saving the file
"automatically jump to the error when saving the file let g:syntastic_auto_loc_list=1 "show the error list automatically
let g:syntastic_auto_jump=0 let g:syntastic_always_populate_loc_list = 0
"show the error list automatically let g:syntastic_quiet_messages = {'level': 'warnings'} "don't care about warnings
let g:syntastic_auto_loc_list=1 let g:syntastic_aggregate_errors = 1
"don't care about warnings let g:syntastic_check_on_open = 1
let g:syntastic_quiet_messages = {'level': 'warnings'} let g:syntastic_check_on_wq = 0
" Default to eslint. If you need jshint, you can override this in " Default to eslint. If you need jshint, you can override this in
" ~/.vimrc.after " ~/.vimrc.after
@ -15,6 +15,10 @@ let g:syntastic_python_flake8_args='--ignore=F401,F403,F405,W0401,E501'
let g:syntastic_python_pylint_post_args="--max-line-length=160" let g:syntastic_python_pylint_post_args="--max-line-length=160"
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" I have no idea why this is not working, as it used to " I have no idea why this is not working, as it used to
" be a part of syntastic code but was apparently removed " be a part of syntastic code but was apparently removed
" This will make syntastic find the correct ruby specified by mri " This will make syntastic find the correct ruby specified by mri

View File

@ -1,15 +0,0 @@
" The tree buffer makes it easy to drill down through the directories of your
" git repository, but its not obvious how you could go up a level to the
" parent directory. Heres a mapping of .. to the above command, but
" only for buffers containing a git blob or tree
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
" Every time you open a git object using fugitive it creates a new buffer.
" This means that your buffer listing can quickly become swamped with
" fugitive buffers. This prevents this from becomming an issue:
autocmd BufReadPost fugitive://* set bufhidden=delete

View File

@ -252,6 +252,5 @@ alias top_by_memory="top -o %MEM"
alias gcaa="gia .; gcF" alias gcaa="gia .; gcF"
alias ror_ctags="ctags -R --languages=ruby --exclude=.git --exclude=log . \$(bundle list --paths)" alias ror_ctags="ctags -R --languages=ruby --exclude=.git --exclude=log . \$(bundle list --paths)"
alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)' alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)'
alias vimgo='vim -u ~/.vimrc.go'
alias find_large_files="sudo find / -xdev -type f -size +50M" alias find_large_files="sudo find / -xdev -type f -size +50M"
alias start_polipo='polipo socksParentProxy=localhost:1080' alias start_polipo='polipo socksParentProxy=localhost:1080'