forked from farazdagi/vim-go-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request farazdagi#8 from marinbek/master
vim-go update
- Loading branch information
Showing
31 changed files
with
1,888 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
" By default use edit (current buffer view) to switch | ||
if !exists("g:go_alternate_mode") | ||
let g:go_alternate_mode = "edit" | ||
endif | ||
|
||
" Test alternates between the implementation of code and the test code. | ||
function! go#alternate#Switch(bang, cmd) | ||
let l:file = go#alternate#Filename(fnameescape(expand("%"))) | ||
if !filereadable(l:file) && !bufexists(l:file) && !a:bang | ||
redraws! | echon "vim-go: " | echohl ErrorMsg | echon "couldn't find ".file | echohl None | ||
return | ||
elseif empty(a:cmd) | ||
execute ":" . g:go_alternate_mode . " " . file | ||
else | ||
execute ":" . a:cmd . " " . file | ||
endif | ||
endfunction | ||
|
||
" Filename returns the name of the test file or implementation file | ||
" depending on the arguments | ||
function! go#alternate#Filename(path) | ||
if empty(matchstr(a:path, "_test")) | ||
let l:root = split(a:path, ".go$")[0] | ||
let l:file = l:root . "_test.go" | ||
else | ||
let l:root = split(a:path, "_test.go$")[0] | ||
let l:file = l:root . ".go" | ||
endif | ||
return l:file | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
" asmfmt.vim: Vim command to format Go asm files with asmfmt | ||
" (github.com/klauspost/asmfmt). | ||
" | ||
" This filetype plugin adds new commands for asm buffers: | ||
" | ||
" :Fmt | ||
" | ||
" Filter the current asm buffer through asmfmt. | ||
" It tries to preserve cursor position and avoids | ||
" replacing the buffer with stderr output. | ||
" | ||
" Options: | ||
" | ||
" g:go_asmfmt_autosave [default=1] | ||
" | ||
" Flag to automatically call :Fmt when file is saved. | ||
|
||
let s:got_fmt_error = 0 | ||
|
||
" This is a trimmed-down version of the logic in fmt.vim. | ||
|
||
function! go#asmfmt#Format() | ||
" Save state. | ||
let l:curw = winsaveview() | ||
|
||
" Write the current buffer to a tempfile. | ||
let l:tmpname = tempname() | ||
call writefile(getline(1, '$'), l:tmpname) | ||
|
||
" Run asmfmt. | ||
let path = go#path#CheckBinPath("asmfmt") | ||
if empty(path) | ||
return | ||
endif | ||
let out = system(path . ' -w ' . l:tmpname) | ||
|
||
" If there's no error, replace the current file with the output. | ||
if v:shell_error == 0 | ||
" Remove undo point caused by BufWritePre. | ||
try | silent undojoin | catch | endtry | ||
|
||
" Replace the current file with the temp file; then reload the buffer. | ||
let old_fileformat = &fileformat | ||
call rename(l:tmpname, expand('%')) | ||
silent edit! | ||
let &fileformat = old_fileformat | ||
let &syntax = &syntax | ||
endif | ||
|
||
" Restore the cursor/window positions. | ||
call winrestview(l:curw) | ||
endfunction |
Oops, something went wrong.