mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 06:33:35 +08:00 
			
		
		
		
	Added not added new plugin files
This commit is contained in:
		
							
								
								
									
										21
									
								
								sources_non_forked/vim-go/autoload/go/decls.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								sources_non_forked/vim-go/autoload/go/decls.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| if !exists('g:go_decls_mode') | ||||
|   let g:go_decls_mode = '' | ||||
| endif | ||||
|  | ||||
| function! go#decls#Decls(mode, ...) abort | ||||
|   if g:go_decls_mode == 'ctrlp' | ||||
|     call ctrlp#init(call("ctrlp#decls#cmd", [a:mode] + a:000)) | ||||
|   elseif g:go_decls_mode == 'fzf' | ||||
|     call call("fzf#decls#cmd", [a:mode] + a:000) | ||||
|   else | ||||
|     if globpath(&rtp, 'plugin/ctrlp.vim') != "" | ||||
|       call ctrlp#init(call("ctrlp#decls#cmd", [a:mode] + a:000)) | ||||
|     elseif globpath(&rtp, 'plugin/fzf.vim') != "" | ||||
|       call call("fzf#decls#cmd", [a:mode] + a:000) | ||||
|     else | ||||
|       call go#util#EchoError("neither ctrlp.vim nor fzf.vim are installed. Please install either one") | ||||
|     end | ||||
|   end | ||||
| endfunction | ||||
|  | ||||
| " vim: sw=2 ts=2 et | ||||
							
								
								
									
										52
									
								
								sources_non_forked/vim-go/autoload/go/fillstruct.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								sources_non_forked/vim-go/autoload/go/fillstruct.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,52 @@ | ||||
| function! go#fillstruct#FillStruct() abort | ||||
|   let l:cmd = ['fillstruct', | ||||
|       \ '-file', bufname(''), | ||||
|       \ '-offset', go#util#OffsetCursor()] | ||||
|  | ||||
|   " Read from stdin if modified. | ||||
|   if &modified | ||||
|     call add(l:cmd, '-modified') | ||||
|     let [l:out, l:err] = go#util#Exec(l:cmd, go#util#archive()) | ||||
|   else | ||||
|     let [l:out, l:err] = go#util#Exec(l:cmd) | ||||
|   endif | ||||
|  | ||||
|   if l:err | ||||
|     call go#util#EchoError(l:out) | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   try | ||||
|     let l:json = json_decode(l:out) | ||||
|   catch | ||||
|     call go#util#EchoError(l:out) | ||||
|     return | ||||
|   endtry | ||||
|  | ||||
|   let l:code = split(l:json['code'], "\n") | ||||
|   let l:pos = getpos('.') | ||||
|  | ||||
|   try | ||||
|     " Add any code before/after the struct. | ||||
|     exe l:json['start'] . 'go' | ||||
|     let l:code[0] = getline('.')[:col('.')-1] . l:code[0] | ||||
|     exe l:json['end'] . 'go' | ||||
|     let l:code[len(l:code)-1] .= getline('.')[col('.'):] | ||||
|  | ||||
|     " Indent every line except the first one; makes it look nice. | ||||
|     let l:indent = repeat("\t", indent('.') / &ts) | ||||
|     for i in range(1, len(l:code)-1) | ||||
|       let l:code[l:i] = l:indent . l:code[i] | ||||
|     endfor | ||||
|  | ||||
|     " Out with the old ... | ||||
|     exe 'normal! ' . l:json['start'] . 'gov' . l:json['end'] . 'gox' | ||||
|     " ... in with the new. | ||||
|     call setline('.', l:code[0]) | ||||
|     call append('.', l:code[1:]) | ||||
|   finally | ||||
|     call setpos('.', l:pos) | ||||
|   endtry | ||||
| endfunction | ||||
|  | ||||
| " vim: sw=2 ts=2 et | ||||
							
								
								
									
										19
									
								
								sources_non_forked/vim-go/autoload/go/fillstruct_test.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								sources_non_forked/vim-go/autoload/go/fillstruct_test.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| func! Test_fillstruct() abort | ||||
|   try | ||||
|     let l:tmp = gotest#write_file('a/a.go', [ | ||||
|           \ 'package a', | ||||
|           \ 'import "net/mail"', | ||||
|           \ 'var addr = mail.Address{}']) | ||||
|  | ||||
|     call go#fillstruct#FillStruct() | ||||
|     call gotest#assert_buffer(1, [ | ||||
|           \ 'var addr = mail.Address{', | ||||
|           \ '\tName:    "",', | ||||
|           \ '\tAddress: "",', | ||||
|           \ '}']) | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
| endfunc | ||||
|  | ||||
| " vim: sw=2 ts=2 et | ||||
							
								
								
									
										23
									
								
								sources_non_forked/vim-go/autoload/go/tool_test.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								sources_non_forked/vim-go/autoload/go/tool_test.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| func! Test_ExecuteInDir() abort | ||||
|   let l:tmp = gotest#write_file('a/a.go', ['package a']) | ||||
|   try | ||||
|     let l:out = go#tool#ExecuteInDir("pwd") | ||||
|     call assert_equal(l:tmp . "/src/a\n", l:out) | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
| endfunc | ||||
|  | ||||
| func! Test_ExecuteInDir_nodir() abort | ||||
|   let l:tmp = go#util#tempdir("executeindir") | ||||
|   exe ':e ' . l:tmp . '/new-dir/a' | ||||
|  | ||||
|   try | ||||
|     let l:out = go#tool#ExecuteInDir("pwd") | ||||
|     call assert_equal('', l:out) | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
| endfunc | ||||
|  | ||||
| " vim: sw=2 ts=2 et | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix