mirror of
https://github.com/amix/vimrc
synced 2025-07-07 00:15:00 +08:00
Add support with Go language.
This commit is contained in:
37
sources_non_forked/vim-go/ftplugin/asm.vim
Normal file
37
sources_non_forked/vim-go/ftplugin/asm.vim
Normal file
@ -0,0 +1,37 @@
|
||||
" asm.vim: Vim filetype plugin for Go assembler.
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let b:undo_ftplugin = "setl fo< com< cms<
|
||||
\ | exe 'au! vim-go-asm-buffer * <buffer>'"
|
||||
|
||||
setlocal formatoptions-=t
|
||||
|
||||
setlocal comments=s1:/*,mb:*,ex:*/,://
|
||||
setlocal commentstring=//\ %s
|
||||
|
||||
setlocal noexpandtab
|
||||
|
||||
command! -nargs=0 AsmFmt call go#asmfmt#Format()
|
||||
|
||||
" Autocommands
|
||||
" ============================================================================
|
||||
|
||||
augroup vim-go-asm-buffer
|
||||
autocmd! * <buffer>
|
||||
|
||||
autocmd BufWritePre <buffer> call go#auto#asmfmt_autosave()
|
||||
augroup end
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: sw=2 ts=2 et
|
135
sources_non_forked/vim-go/ftplugin/go.vim
Normal file
135
sources_non_forked/vim-go/ftplugin/go.vim
Normal file
@ -0,0 +1,135 @@
|
||||
" Copyright 2013 The Go Authors. All rights reserved.
|
||||
" Use of this source code is governed by a BSD-style
|
||||
" license that can be found in the LICENSE file.
|
||||
"
|
||||
" go.vim: Vim filetype plugin for Go.
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let b:undo_ftplugin = "setl fo< com< cms<"
|
||||
\ . "| exe 'au! vim-go-buffer * <buffer>'"
|
||||
|
||||
setlocal formatoptions-=t
|
||||
|
||||
setlocal comments=s1:/*,mb:*,ex:*/,://
|
||||
setlocal commentstring=//\ %s
|
||||
|
||||
setlocal noexpandtab
|
||||
|
||||
compiler go
|
||||
|
||||
if go#config#CodeCompletionEnabled()
|
||||
" Set autocompletion
|
||||
setlocal omnifunc=go#complete#Complete
|
||||
endif
|
||||
|
||||
if get(g:, "go_doc_keywordprg_enabled", 1)
|
||||
" keywordprg doesn't allow to use vim commands, override it
|
||||
nnoremap <buffer> <silent> K :GoDoc<cr>
|
||||
endif
|
||||
|
||||
if get(g:, "go_def_mapping_enabled", 1)
|
||||
" these are default Vim mappings, we're overriding them to make them
|
||||
" useful again for Go source code
|
||||
nnoremap <buffer> <silent> gd :GoDef<cr>
|
||||
nnoremap <buffer> <silent> <C-]> :GoDef<cr>
|
||||
nnoremap <buffer> <silent> <C-LeftMouse> <LeftMouse>:GoDef<cr>
|
||||
nnoremap <buffer> <silent> g<LeftMouse> <LeftMouse>:GoDef<cr>
|
||||
nnoremap <buffer> <silent> <C-w><C-]> :<C-u>call go#def#Jump("split", 0)<CR>
|
||||
nnoremap <buffer> <silent> <C-w>] :<C-u>call go#def#Jump("split", 0)<CR>
|
||||
nnoremap <buffer> <silent> <C-t> :<C-U>call go#def#StackPop(v:count1)<cr>
|
||||
endif
|
||||
|
||||
if get(g:, "go_textobj_enabled", 1)
|
||||
onoremap <buffer> <silent> af :<c-u>call go#textobj#Function('a')<cr>
|
||||
xnoremap <buffer> <silent> af :<c-u>call go#textobj#Function('a')<cr>
|
||||
|
||||
onoremap <buffer> <silent> if :<c-u>call go#textobj#Function('i')<cr>
|
||||
xnoremap <buffer> <silent> if :<c-u>call go#textobj#Function('i')<cr>
|
||||
|
||||
onoremap <buffer> <silent> ac :<c-u>call go#textobj#Comment('a')<cr>
|
||||
xnoremap <buffer> <silent> ac :<c-u>call go#textobj#Comment('a')<cr>
|
||||
|
||||
onoremap <buffer> <silent> ic :<c-u>call go#textobj#Comment('i')<cr>
|
||||
xnoremap <buffer> <silent> ic :<c-u>call go#textobj#Comment('i')<cr>
|
||||
|
||||
" Remap ]] and [[ to jump betweeen functions as they are useless in Go
|
||||
nnoremap <buffer> <silent> ]] :<c-u>call go#textobj#FunctionJump('n', 'next')<cr>
|
||||
nnoremap <buffer> <silent> [[ :<c-u>call go#textobj#FunctionJump('n', 'prev')<cr>
|
||||
|
||||
onoremap <buffer> <silent> ]] :<c-u>call go#textobj#FunctionJump('o', 'next')<cr>
|
||||
onoremap <buffer> <silent> [[ :<c-u>call go#textobj#FunctionJump('o', 'prev')<cr>
|
||||
|
||||
xnoremap <buffer> <silent> ]] :<c-u>call go#textobj#FunctionJump('v', 'next')<cr>
|
||||
xnoremap <buffer> <silent> [[ :<c-u>call go#textobj#FunctionJump('v', 'prev')<cr>
|
||||
endif
|
||||
|
||||
" Autocommands
|
||||
" ============================================================================
|
||||
"
|
||||
augroup vim-go-buffer
|
||||
autocmd! * <buffer>
|
||||
|
||||
" The file is registered (textDocument/DidOpen) with gopls in plugin/go.vim
|
||||
" on the FileType event.
|
||||
|
||||
if go#util#has_job()
|
||||
autocmd BufWritePost,FileChangedShellPost <buffer> call go#lsp#DidChange(resolve(expand('<afile>:p')))
|
||||
autocmd BufDelete <buffer> call go#lsp#DidClose(resolve(expand('<afile>:p')))
|
||||
endif
|
||||
|
||||
" send the textDocument/didChange notification when idle. go#lsp#DidChange
|
||||
" will not send an event if the buffer hasn't changed since the last
|
||||
" notification.
|
||||
autocmd CursorHold,CursorHoldI <buffer> call go#lsp#DidChange(resolve(expand('<afile>:p')))
|
||||
|
||||
autocmd BufEnter,CursorHold <buffer> call go#auto#update_autocmd()
|
||||
|
||||
" Echo the identifier information when completion is done. Useful to see
|
||||
" the signature of a function, etc...
|
||||
if exists('##CompleteDone')
|
||||
autocmd CompleteDone <buffer> call go#auto#complete_done()
|
||||
endif
|
||||
|
||||
autocmd BufWritePre <buffer> call go#auto#fmt_autosave()
|
||||
autocmd BufWritePost <buffer> call go#auto#metalinter_autosave()
|
||||
|
||||
" TODO(bc): autocmd BufWinLeave call go#lsp#DidChange(expand('<afile>:p'))
|
||||
|
||||
if !has('textprop')
|
||||
"TODO(bc): how to clear sameids and diagnostics when a non-go buffer is
|
||||
" loaded into a window and the previously loaded buffer is still loaded in
|
||||
" another window?
|
||||
|
||||
" TODO(bc): only clear when the new buffer isn't the old buffer
|
||||
|
||||
" clear SameIds when the buffer is unloaded from its last window so that
|
||||
" loading another buffer (especially of a different filetype) in the same
|
||||
" window doesn't highlight the most recently matched identifier's positions.
|
||||
autocmd BufWinLeave <buffer> call go#guru#ClearSameIds()
|
||||
" clear SameIds when a new buffer is loaded in the window so that the
|
||||
" previous buffer's highlighting isn't used.
|
||||
autocmd BufWinEnter <buffer> call go#guru#ClearSameIds()
|
||||
|
||||
" clear diagnostics when the buffer is unloaded from its last window so that
|
||||
" loading another buffer (especially of a different filetype) in the same
|
||||
" window doesn't highlight the previously loaded buffer's diagnostics.
|
||||
autocmd BufWinLeave <buffer> call go#lsp#ClearDiagnosticHighlights()
|
||||
" clear diagnostics when a new buffer is loaded in the window so that the
|
||||
" previous buffer's diagnostics aren't used.
|
||||
"autocmd BufWinEnter <buffer> call go#lsp#ClearDiagnosticHighlights()
|
||||
endif
|
||||
augroup end
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: sw=2 ts=2 et
|
138
sources_non_forked/vim-go/ftplugin/go/commands.vim
Normal file
138
sources_non_forked/vim-go/ftplugin/go/commands.vim
Normal file
@ -0,0 +1,138 @@
|
||||
" -- gorename
|
||||
command! -nargs=? -complete=customlist,go#rename#Complete GoRename call go#rename#Rename(<bang>0, <f-args>)
|
||||
|
||||
" -- guru
|
||||
" do not configure commands that _require_ guru when not in GOPATH mode.
|
||||
"if go#package#InGOPATH()
|
||||
command! -nargs=* -complete=customlist,go#package#Complete GoGuruScope call go#guru#Scope(<f-args>)
|
||||
command! -range=% GoPointsTo call go#guru#PointsTo(<count>)
|
||||
command! -range=% GoWhicherrs call go#guru#Whicherrs(<count>)
|
||||
command! -range=% GoCallees call go#guru#Callees(<count>)
|
||||
command! -range=% GoDescribe call go#guru#Describe(<count>)
|
||||
command! -range=% GoCallstack call go#guru#Callstack(<count>)
|
||||
command! -range=% GoFreevars call go#guru#Freevars(<count>)
|
||||
command! -range=% GoChannelPeers call go#guru#ChannelPeers(<count>)
|
||||
"endif
|
||||
|
||||
command! -range=% GoImplements call go#implements#Implements(<count>)
|
||||
command! -range=% GoReferrers call go#referrers#Referrers(<count>)
|
||||
command! -range=0 GoSameIds call go#guru#SameIds(1)
|
||||
command! -range=0 GoSameIdsClear call go#guru#ClearSameIds()
|
||||
command! -range=0 GoSameIdsToggle call go#guru#ToggleSameIds()
|
||||
command! -range=0 GoSameIdsAutoToggle call go#guru#AutoToggleSameIds()
|
||||
|
||||
" -- calls
|
||||
command! -nargs=0 GoCallers call go#calls#Callers()
|
||||
|
||||
" -- tags
|
||||
command! -nargs=* -range GoAddTags call go#tags#Add(<line1>, <line2>, <count>, <f-args>)
|
||||
command! -nargs=* -range GoRemoveTags call go#tags#Remove(<line1>, <line2>, <count>, <f-args>)
|
||||
|
||||
" -- mod
|
||||
command! -nargs=0 -range GoModFmt call go#mod#Format()
|
||||
|
||||
" -- tool
|
||||
command! -nargs=* -complete=customlist,go#tool#ValidFiles GoFiles echo go#tool#Files(<f-args>)
|
||||
command! -nargs=0 GoDeps echo go#tool#Deps()
|
||||
command! -nargs=0 GoInfo call go#tool#Info(1)
|
||||
command! -nargs=0 GoAutoTypeInfoToggle call go#complete#ToggleAutoTypeInfo()
|
||||
|
||||
" -- cmd
|
||||
command! -nargs=* -bang GoBuild call go#cmd#Build(<bang>0,<f-args>)
|
||||
command! -nargs=? -bang GoBuildTags call go#cmd#BuildTags(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang GoGenerate call go#cmd#Generate(<bang>0,<f-args>)
|
||||
command! -nargs=* -bang -complete=file GoRun call go#cmd#Run(<bang>0,<f-args>)
|
||||
command! -nargs=* -bang GoInstall call go#cmd#Install(<bang>0, <f-args>)
|
||||
|
||||
" -- test
|
||||
command! -nargs=* -bang GoTest call go#test#Test(<bang>0, 0, <f-args>)
|
||||
command! -nargs=* -bang GoTestFunc call go#test#Func(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang GoTestCompile call go#test#Test(<bang>0, 1, <f-args>)
|
||||
|
||||
" -- cover
|
||||
command! -nargs=* -bang GoCoverage call go#coverage#Buffer(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang GoCoverageClear call go#coverage#Clear()
|
||||
command! -nargs=* -bang GoCoverageToggle call go#coverage#BufferToggle(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang GoCoverageBrowser call go#coverage#Browser(<bang>0, <f-args>)
|
||||
|
||||
" -- play
|
||||
command! -nargs=0 -range=% GoPlay call go#play#Share(<count>, <line1>, <line2>)
|
||||
|
||||
" -- def
|
||||
command! -nargs=* -range GoDef :call go#def#Jump('', 0)
|
||||
command! -nargs=* -range GoDefType :call go#def#Jump('', 1)
|
||||
command! -nargs=? GoDefPop :call go#def#StackPop(<f-args>)
|
||||
command! -nargs=? GoDefStack :call go#def#Stack(<f-args>)
|
||||
command! -nargs=? GoDefStackClear :call go#def#StackClear(<f-args>)
|
||||
|
||||
" -- doc
|
||||
command! -nargs=* -range -complete=customlist,go#package#Complete GoDoc call go#doc#Open('new', 'split', <f-args>)
|
||||
command! -nargs=* -range -complete=customlist,go#package#Complete GoDocBrowser call go#doc#OpenBrowser(<f-args>)
|
||||
|
||||
" -- fmt
|
||||
command! -nargs=0 GoFmt call go#fmt#Format(0)
|
||||
command! -nargs=0 GoFmtAutoSaveToggle call go#fmt#ToggleFmtAutoSave()
|
||||
command! -nargs=0 GoImports call go#fmt#Format(1)
|
||||
|
||||
" -- asmfmt
|
||||
command! -nargs=0 GoAsmFmtAutoSaveToggle call go#asmfmt#ToggleAsmFmtAutoSave()
|
||||
|
||||
" -- import
|
||||
command! -nargs=? -complete=customlist,go#package#Complete GoDrop call go#import#SwitchImport(0, '', <f-args>, '')
|
||||
command! -nargs=1 -bang -complete=customlist,go#package#Complete GoImport call go#import#SwitchImport(1, '', <f-args>, '<bang>')
|
||||
command! -nargs=* -bang -complete=customlist,go#package#Complete GoImportAs call go#import#SwitchImport(1, <f-args>, '<bang>')
|
||||
|
||||
" -- linters
|
||||
command! -nargs=* -bang GoMetaLinter call go#lint#Gometa(<bang>0, 0, <f-args>)
|
||||
command! -nargs=0 GoMetaLinterAutoSaveToggle call go#lint#ToggleMetaLinterAutoSave()
|
||||
command! -nargs=* -bang GoLint call go#lint#Golint(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang GoVet call go#lint#Vet(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang -complete=customlist,go#package#Complete GoErrCheck call go#lint#Errcheck(<bang>0, <f-args>)
|
||||
|
||||
" -- alternate
|
||||
command! -bang GoAlternate call go#alternate#Switch(<bang>0, '')
|
||||
|
||||
" -- decls
|
||||
command! -nargs=? -complete=file GoDecls call go#decls#Decls(0, <q-args>)
|
||||
command! -nargs=? -complete=dir GoDeclsDir call go#decls#Decls(1, <q-args>)
|
||||
|
||||
" -- impl
|
||||
command! -nargs=* -complete=customlist,go#impl#Complete GoImpl call go#impl#Impl(<f-args>)
|
||||
|
||||
" -- template
|
||||
command! -nargs=0 GoTemplateAutoCreateToggle call go#template#ToggleAutoCreate()
|
||||
|
||||
" -- keyify
|
||||
if go#package#InGOPATH()
|
||||
command! -nargs=0 GoKeyify call go#keyify#Keyify()
|
||||
endif
|
||||
|
||||
" -- fillstruct
|
||||
command! -nargs=0 GoFillStruct call go#fillstruct#FillStruct()
|
||||
|
||||
" -- debug
|
||||
if !exists(':GoDebugStart')
|
||||
command! -nargs=* -complete=customlist,go#package#Complete GoDebugStart call go#debug#Start('debug', <f-args>)
|
||||
command! -nargs=* -complete=customlist,go#package#Complete GoDebugTest call go#debug#Start('test', <f-args>)
|
||||
command! -nargs=* GoDebugTestFunc call go#debug#TestFunc(<f-args>)
|
||||
command! -nargs=1 GoDebugAttach call go#debug#Start('attach', <f-args>)
|
||||
command! -nargs=? GoDebugConnect call go#debug#Start('connect', <f-args>)
|
||||
command! -nargs=? GoDebugBreakpoint call go#debug#Breakpoint(<f-args>)
|
||||
endif
|
||||
|
||||
" -- issue
|
||||
command! -nargs=0 GoReportGitHubIssue call go#issue#New()
|
||||
|
||||
" -- iferr
|
||||
command! -nargs=0 GoIfErr call go#iferr#Generate()
|
||||
|
||||
" -- lsp
|
||||
command! -nargs=+ -complete=dir GoAddWorkspace call go#lsp#AddWorkspaceDirectory(<f-args>)
|
||||
command! -nargs=0 GoLSPDebugBrowser call go#lsp#DebugBrowser()
|
||||
command! -nargs=* -bang GoDiagnostics call go#lint#Diagnostics(<bang>0, <f-args>)
|
||||
command! -nargs=? GoModReload call go#lsp#ModReload()
|
||||
|
||||
" -- term
|
||||
command! GoToggleTermCloseOnExit call go#term#ToggleCloseOnExit()
|
||||
|
||||
" vim: sw=2 ts=2 et
|
89
sources_non_forked/vim-go/ftplugin/go/mappings.vim
Normal file
89
sources_non_forked/vim-go/ftplugin/go/mappings.vim
Normal file
@ -0,0 +1,89 @@
|
||||
" go_jump_to_error defines whether we should pass the bang attribute to the
|
||||
" command or not. This is only used for mappings, because the user can't pass
|
||||
" the bang attribute to the plug mappings below. So instead of hardcoding it
|
||||
" as 0 (no '!' attribute) or 1 (with '!' attribute) we pass the user setting,
|
||||
" which by default is enabled. For commands the user has the ability to pass
|
||||
" the '!', such as :GoBuild or :GoBuild!
|
||||
if !exists("g:go_jump_to_error")
|
||||
let g:go_jump_to_error = 1
|
||||
endif
|
||||
|
||||
" Some handy plug mappings
|
||||
nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(!g:go_jump_to_error)<CR>
|
||||
|
||||
if has("nvim") || has("terminal")
|
||||
nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit', [])<CR>
|
||||
nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split', [])<CR>
|
||||
nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe', [])<CR>
|
||||
endif
|
||||
|
||||
nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-generate) :<C-u>call go#cmd#Generate(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-install) :<C-u>call go#cmd#Install(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-test) :<C-u>call go#test#Test(!g:go_jump_to_error, 0)<CR>
|
||||
nnoremap <silent> <Plug>(go-test-func) :<C-u>call go#test#Func(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-test-compile) :<C-u>call go#test#Test(!g:go_jump_to_error, 1)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-coverage) :<C-u>call go#coverage#Buffer(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-coverage-clear) :<C-u>call go#coverage#Clear()<CR>
|
||||
nnoremap <silent> <Plug>(go-coverage-toggle) :<C-u>call go#coverage#BufferToggle(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-coverage-browser) :<C-u>call go#coverage#Browser(!g:go_jump_to_error)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-files) :<C-u>call go#tool#Files()<CR>
|
||||
nnoremap <silent> <Plug>(go-deps) :<C-u>call go#tool#Deps()<CR>
|
||||
nnoremap <silent> <Plug>(go-info) :<C-u>call go#tool#Info(1)<CR>
|
||||
nnoremap <silent> <Plug>(go-import) :<C-u>call go#import#SwitchImport(1, '', expand('<cword>'), '')<CR>
|
||||
nnoremap <silent> <Plug>(go-imports) :<C-u>call go#fmt#Format(1)<CR>
|
||||
nnoremap <silent> <Plug>(go-fmt) :<C-u>call go#fmt#Format(0)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-implements) :<C-u>call go#implements#Implements(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-callees) :<C-u>call go#guru#Callees(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-callers) :<C-u>call go#calls#Callers()<CR>
|
||||
nnoremap <silent> <Plug>(go-describe) :<C-u>call go#guru#Describe(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-callstack) :<C-u>call go#guru#Callstack(-1)<CR>
|
||||
xnoremap <silent> <Plug>(go-freevars) :<C-u>call go#guru#Freevars(0)<CR>
|
||||
nnoremap <silent> <Plug>(go-channelpeers) :<C-u>call go#guru#ChannelPeers(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-referrers) :<C-u>call go#referrers#Referrers(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-sameids) :<C-u>call go#guru#SameIds(1)<CR>
|
||||
nnoremap <silent> <Plug>(go-pointsto) :<C-u>call go#guru#PointsTo(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-whicherrs) :<C-u>call go#guru#Whicherrs(-1)<CR>
|
||||
nnoremap <silent> <Plug>(go-sameids-toggle) :<C-u>call go#guru#ToggleSameIds()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-rename) :<C-u>call go#rename#Rename(!g:go_jump_to_error)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-decls) :<C-u>call go#decls#Decls(0, '')<CR>
|
||||
nnoremap <silent> <Plug>(go-decls-dir) :<C-u>call go#decls#Decls(1, '')<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-def) :<C-u>call go#def#Jump('', 0)<CR>
|
||||
nnoremap <silent> <Plug>(go-def-vertical) :<C-u>call go#def#Jump("vsplit", 0)<CR>
|
||||
nnoremap <silent> <Plug>(go-def-split) :<C-u>call go#def#Jump("split", 0)<CR>
|
||||
nnoremap <silent> <Plug>(go-def-tab) :<C-u>call go#def#Jump("tab", 0)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-def-type) :<C-u>call go#def#Jump('', 1)<CR>
|
||||
nnoremap <silent> <Plug>(go-def-type-vertical) :<C-u>call go#def#Jump("vsplit", 1)<CR>
|
||||
nnoremap <silent> <Plug>(go-def-type-split) :<C-u>call go#def#Jump("split", 1)<CR>
|
||||
nnoremap <silent> <Plug>(go-def-type-tab) :<C-u>call go#def#Jump("tab", 1)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-def-pop) :<C-u>call go#def#StackPop()<CR>
|
||||
nnoremap <silent> <Plug>(go-def-stack) :<C-u>call go#def#Stack()<CR>
|
||||
nnoremap <silent> <Plug>(go-def-stack-clear) :<C-u>call go#def#StackClear()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-doc) :<C-u>call go#doc#Open("new", "split")<CR>
|
||||
nnoremap <silent> <Plug>(go-doc-tab) :<C-u>call go#doc#Open("tabnew", "tabe")<CR>
|
||||
nnoremap <silent> <Plug>(go-doc-vertical) :<C-u>call go#doc#Open("vnew", "vsplit")<CR>
|
||||
nnoremap <silent> <Plug>(go-doc-split) :<C-u>call go#doc#Open("new", "split")<CR>
|
||||
nnoremap <silent> <Plug>(go-doc-browser) :<C-u>call go#doc#OpenBrowser()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-metalinter) :<C-u>call go#lint#Gometa(!g:go_jump_to_error, 0)<CR>
|
||||
nnoremap <silent> <Plug>(go-lint) :<C-u>call go#lint#Golint(!g:go_jump_to_error)<CR>
|
||||
nnoremap <silent> <Plug>(go-vet) :<C-u>call go#lint#Vet(!g:go_jump_to_error)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-alternate-edit) :<C-u>call go#alternate#Switch(0, "edit")<CR>
|
||||
nnoremap <silent> <Plug>(go-alternate-vertical) :<C-u>call go#alternate#Switch(0, "vsplit")<CR>
|
||||
nnoremap <silent> <Plug>(go-alternate-split) :<C-u>call go#alternate#Switch(0, "split")<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-iferr) :<C-u>call go#iferr#Generate()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-diagnostics) :<C-u>call go#lint#Diagnostics(!g:go_jump_to_error)<CR>
|
||||
|
||||
" vim: sw=2 ts=2 et
|
67
sources_non_forked/vim-go/ftplugin/go/snippets.vim
Normal file
67
sources_non_forked/vim-go/ftplugin/go/snippets.vim
Normal file
@ -0,0 +1,67 @@
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if exists("g:go_loaded_gosnippets")
|
||||
finish
|
||||
endif
|
||||
let g:go_loaded_gosnippets = 1
|
||||
|
||||
function! s:GoUltiSnips() abort
|
||||
if get(g:, 'did_plugin_ultisnips') isnot 1
|
||||
return
|
||||
endif
|
||||
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = ["gosnippets/UltiSnips"]
|
||||
else
|
||||
let g:UltiSnipsSnippetDirectories += ["gosnippets/UltiSnips"]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GoNeosnippet() abort
|
||||
if get(g:, 'loaded_neosnippet') isnot 1
|
||||
return
|
||||
endif
|
||||
|
||||
let g:neosnippet#enable_snipmate_compatibility = 1
|
||||
|
||||
let l:gosnippets_dir = globpath(&rtp, 'gosnippets/snippets')
|
||||
if type(g:neosnippet#snippets_directory) == type([])
|
||||
let g:neosnippet#snippets_directory += [l:gosnippets_dir]
|
||||
elseif type(g:neosnippet#snippets_directory) == type("")
|
||||
if strlen(g:neosnippet#snippets_directory) > 0
|
||||
let g:neosnippet#snippets_directory = g:neosnippet#snippets_directory . "," . l:gosnippets_dir
|
||||
else
|
||||
let g:neosnippet#snippets_directory = l:gosnippets_dir
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GoMinisnip() abort
|
||||
if get(g:, 'loaded_minisnip') isnot 1
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('g:minisnip_dir')
|
||||
let g:minisnip_dir .= go#util#PathListSep() . globpath(&rtp, 'gosnippets/minisnip')
|
||||
else
|
||||
let g:minisnip_dir = globpath(&rtp, 'gosnippets/minisnip')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
let s:engine = go#config#SnippetEngine()
|
||||
if s:engine is? 'ultisnips'
|
||||
call s:GoUltiSnips()
|
||||
elseif s:engine is? 'neosnippet'
|
||||
call s:GoNeosnippet()
|
||||
elseif s:engine is? 'minisnip'
|
||||
call s:GoMinisnip()
|
||||
endif
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: sw=2 ts=2 et
|
65
sources_non_forked/vim-go/ftplugin/go/tagbar.vim
Normal file
65
sources_non_forked/vim-go/ftplugin/go/tagbar.vim
Normal file
@ -0,0 +1,65 @@
|
||||
" Check if tagbar is installed under plugins or is directly under rtp
|
||||
" this covers pathogen + Vundle/Bundle
|
||||
"
|
||||
" Also make sure the ctags command exists
|
||||
"
|
||||
if !executable('ctags')
|
||||
finish
|
||||
elseif globpath(&rtp, 'plugin/tagbar.vim') == ""
|
||||
finish
|
||||
endif
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists("g:go_gotags_bin")
|
||||
let g:go_gotags_bin = "gotags"
|
||||
endif
|
||||
|
||||
|
||||
function! s:SetTagbar()
|
||||
let bin_path = go#path#CheckBinPath(g:go_gotags_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
if !exists("g:tagbar_type_go")
|
||||
let g:tagbar_type_go = {
|
||||
\ 'ctagstype' : 'go',
|
||||
\ 'kinds' : [
|
||||
\ 'p:package',
|
||||
\ 'i:imports',
|
||||
\ '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' : bin_path,
|
||||
\ 'ctagsargs' : '-sort -silent'
|
||||
\ }
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
call s:SetTagbar()
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: sw=2 ts=2 et
|
7
sources_non_forked/vim-go/ftplugin/gohtmltmpl.vim
Normal file
7
sources_non_forked/vim-go/ftplugin/gohtmltmpl.vim
Normal file
@ -0,0 +1,7 @@
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime! ftplugin/html.vim
|
||||
|
||||
" vim: sw=2 ts=2 et
|
36
sources_non_forked/vim-go/ftplugin/gomod.vim
Normal file
36
sources_non_forked/vim-go/ftplugin/gomod.vim
Normal file
@ -0,0 +1,36 @@
|
||||
" gomod.vim: Vim filetype plugin for Go assembler.
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" don't spam the user when Vim is started in Vi compatibility mode
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let b:undo_ftplugin = "setl fo< com< cms<
|
||||
\ | exe 'au! vim-go-gomod-buffer * <buffer>'"
|
||||
|
||||
setlocal formatoptions-=t
|
||||
|
||||
setlocal comments=s1:/*,mb:*,ex:*/,://
|
||||
setlocal commentstring=//\ %s
|
||||
|
||||
" Autocommands
|
||||
" ============================================================================
|
||||
|
||||
augroup vim-go-gomod-buffer
|
||||
autocmd! * <buffer>
|
||||
|
||||
autocmd BufWritePre <buffer> call go#auto#modfmt_autosave()
|
||||
if go#util#has_job()
|
||||
autocmd BufWritePost,FileChangedShellPost <buffer> call go#lsp#ModReload(resolve(expand('<afile>:p')))
|
||||
endif
|
||||
augroup end
|
||||
|
||||
" restore Vi compatibility settings
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: sw=2 ts=2 et
|
3
sources_non_forked/vim-go/ftplugin/gomod/commands.vim
Normal file
3
sources_non_forked/vim-go/ftplugin/gomod/commands.vim
Normal file
@ -0,0 +1,3 @@
|
||||
command! -nargs=0 -range GoModFmt call go#mod#Format()
|
||||
|
||||
command! -nargs=0 GoModFmtAutoSaveToggle call go#mod#ToggleModFmtAutoSave()
|
1
sources_non_forked/vim-go/ftplugin/gomod/mappings.vim
Normal file
1
sources_non_forked/vim-go/ftplugin/gomod/mappings.vim
Normal file
@ -0,0 +1 @@
|
||||
nnoremap <silent> <Plug>(go-mod-fmt) :<C-u>call go#mod#Format()<CR>
|
Reference in New Issue
Block a user