Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gofmt integration is not working #25

Closed
oblitum opened this issue Mar 30, 2014 · 8 comments
Closed

gofmt integration is not working #25

oblitum opened this issue Mar 30, 2014 · 8 comments

Comments

@oblitum
Copy link

oblitum commented Mar 30, 2014

I was using :Fmt without problems before trying to adopt vim-go, I have then removed all previous integration and switched to vim-go but now, when I try to save a go source file, I get a screen with all the buffer contents non-highlighted, I must scroll down to the bottom of this message (yes, the buffer contents is being output as an output message), at the bottom it says I must press any key to have the file saved. Also, in the end, no formatting is being applyed, both with the command, nor when it's being saved. I'm on Ubuntu 13.10 with a quite recent Vim build, 7.4.211.

@oblitum
Copy link
Author

oblitum commented Mar 30, 2014

Just to add, I'm debugging a bit now and the strange buffer output seems to come from this part of fmt.vim:

    if empty(errors)
        % | " Couldn't detect gofmt error format, output errors
    endif

@oblitum
Copy link
Author

oblitum commented Mar 30, 2014

Ok the issue is being caused because the fmt.vim script is using "goimports" instead of g:go_goimports_bin to build the command for execution. This is an issue since ~/.vim-go is not in my $PATH.

@oblitum
Copy link
Author

oblitum commented Mar 30, 2014

Replacing the instances of that string in the file with the bin variable solved the issue for me.

@fatih
Copy link
Owner

fatih commented Mar 30, 2014

You are right, it uses g:go_fmt_command instead of g:go_goimports_bin (which is actually being setted). Thanks for reporting, I'll push a fix asap.

@fatih
Copy link
Owner

fatih commented Mar 30, 2014

Can you revert your changes and just replace this on line 37-39:

if !exists("g:go_fmt_command")
    let g:go_fmt_command = g:go_goimports_bin
endif

@oblitum
Copy link
Author

oblitum commented Mar 30, 2014

@fatih my previous change was just that, and the same for line 60.

@fatih
Copy link
Owner

fatih commented Mar 30, 2014

ok thanks @oblitum, pushing the fix now. Awesome catch 👍

@oblitum
Copy link
Author

oblitum commented Mar 30, 2014

glad to help

@fatih fatih closed this as completed in 89e9bdd Mar 30, 2014
mingtaoy added a commit to mingtaoy/vim-go that referenced this issue Dec 26, 2018
vim's rename() function will output messages for non-fatal conditions,
such as setting SELinux context. This will cause vim-go to annoyingly
display a "Press ENTER to continue" message in conjunction with
go_fmt_autosave = 1.

For example, if the original Go source file is located on a FUSE
filesystem that does not support `setxattr()`, and vim is compiled with
SELINUX_ENABLED, `rename()` will attempt to call `setfilecon()`, which
will fail and output an annoying error message.

Call stack:

```
 #0  mch_copy_sec (from_file=0xc2e3d0 "/tmp/vRUr7yU/7.go", to_file=0xc59910 "/fuse/test.go") at os_unix.c:2866
 fatih#1  0x00000000004e7dcf in vim_rename (from=0xc2e3d0 "/tmp/vRUr7yU/7.go", to=0xc59910 "/fuse/test.go") at fileio.c:6731
 fatih#2  0x0000000000480ab7 in f_rename (argvars=0x7ffec6fddac0, rettv=0x7ffec6fddd08) at evalfunc.c:9646
 fatih#3  0x0000000000474011 in call_internal_func (name=0xc51b00 "rename", argcount=2, argvars=0x7ffec6fddac0, rettv=0x7ffec6fddd08) at evalfunc.c:1110
 fatih#4  0x0000000000660d8e in call_func (funcname=0xc62d20 "rename", len=6, rettv=0x7ffec6fddd08, argcount_in=2, argvars_in=0x7ffec6fddac0, argv_func=0x0, firstline=12, lastline=12, doesrange=0x7ffec6fddcfc,
     evaluate=1, partial=0x0, selfdict_in=0x0) at userfunc.c:1507
 fatih#5  0x0000000000660690 in get_func_tv (name=0xc62d20 "rename", len=6, rettv=0x7ffec6fddd08, arg=0x7ffec6fddd38, firstline=12, lastline=12, doesrange=0x7ffec6fddcfc, evaluate=1, partial=0x0, selfdict=0x0)
     at userfunc.c:455
 fatih#6  0x0000000000666961 in ex_call (eap=0x7ffec6fddf38) at userfunc.c:3171
 fatih#7  0x00000000004af3c2 in do_one_cmd (cmdlinep=0x7ffec6fde6c8, sourcing=1, cstack=0x7ffec6fde210, fgetline=0x666be0 <get_func_line>, cookie=0xc48fd0) at ex_docmd.c:2537
 fatih#8  0x00000000004ac3d8 in do_cmdline (cmdline=0x0, fgetline=0x666be0 <get_func_line>, cookie=0xc48fd0, flags=7) at ex_docmd.c:1038
 fatih#9  0x0000000000662123 in call_user_func (fp=0xbfe220, argcount=2, argvars=0x7ffec6fdf0e0, rettv=0x7ffec6fdf328, firstline=12, lastline=12, selfdict=0x0) at userfunc.c:954
 fatih#10 0x0000000000660d01 in call_func (funcname=0xc59fb0 "go#fmt#update_file", len=18, rettv=0x7ffec6fdf328, argcount_in=2, argvars_in=0x7ffec6fdf0e0, argv_func=0x0, firstline=12, lastline=12,
     doesrange=0x7ffec6fdf31c, evaluate=1, partial=0x0, selfdict_in=0x0) at userfunc.c:1488
 fatih#11 0x0000000000660690 in get_func_tv (name=0xc59fb0 "go#fmt#update_file", len=18, rettv=0x7ffec6fdf328, arg=0x7ffec6fdf358, firstline=12, lastline=12, doesrange=0x7ffec6fdf31c, evaluate=1, partial=0x0,
     selfdict=0x0) at userfunc.c:455
 fatih#12 0x0000000000666961 in ex_call (eap=0x7ffec6fdf558) at userfunc.c:3171
 fatih#13 0x00000000004af3c2 in do_one_cmd (cmdlinep=0x7ffec6fdfce8, sourcing=1, cstack=0x7ffec6fdf830, fgetline=0x666be0 <get_func_line>, cookie=0xc61900) at ex_docmd.c:2537
 fatih#14 0x00000000004ac3d8 in do_cmdline (cmdline=0x0, fgetline=0x666be0 <get_func_line>, cookie=0xc61900, flags=7) at ex_docmd.c:1038
 fatih#15 0x0000000000662123 in call_user_func (fp=0xc59340, argcount=1, argvars=0x7ffec6fe0700, rettv=0x7ffec6fe0948, firstline=12, lastline=12, selfdict=0x0) at userfunc.c:954
 fatih#16 0x0000000000660d01 in call_func (funcname=0xc64a40 "go#fmt#Format", len=13, rettv=0x7ffec6fe0948, argcount_in=1, argvars_in=0x7ffec6fe0700, argv_func=0x0, firstline=12, lastline=12, doesrange=0x7ffec6fe093c,
     evaluate=1, partial=0x0, selfdict_in=0x0) at userfunc.c:1488
 fatih#17 0x0000000000660690 in get_func_tv (name=0xc64a40 "go#fmt#Format", len=13, rettv=0x7ffec6fe0948, arg=0x7ffec6fe0978, firstline=12, lastline=12, doesrange=0x7ffec6fe093c, evaluate=1, partial=0x0, selfdict=0x0)
     at userfunc.c:455
 fatih#18 0x0000000000666961 in ex_call (eap=0x7ffec6fe0b78) at userfunc.c:3171
 fatih#19 0x00000000004af3c2 in do_one_cmd (cmdlinep=0x7ffec6fe1308, sourcing=1, cstack=0x7ffec6fe0e50, fgetline=0x4cc2a0 <getexline>, cookie=0x0) at ex_docmd.c:2537
 fatih#20 0x00000000004ac3d8 in do_cmdline (cmdline=0xc65380 "call go#fmt#Format(-1)", fgetline=0x4cc2a0 <getexline>, cookie=0x0, flags=11) at ex_docmd.c:1038
 fatih#21 0x00000000004ba24b in do_ucmd (eap=0x7ffec6fe15d8) at ex_docmd.c:7018
 fatih#22 0x00000000004af390 in do_one_cmd (cmdlinep=0x7ffec6fe1d68, sourcing=0, cstack=0x7ffec6fe18b0, fgetline=0x4cc2a0 <getexline>, cookie=0x0) at ex_docmd.c:2528
 fatih#23 0x00000000004ac3d8 in do_cmdline (cmdline=0x0, fgetline=0x4cc2a0 <getexline>, cookie=0x0, flags=0) at ex_docmd.c:1038
 fatih#24 0x0000000000558c59 in nv_colon (cap=0x7ffec6fe1eb8) at normal.c:5388
 fatih#25 0x000000000054ec81 in normal_cmd (oap=0x7ffec6fe1f58, toplevel=1) at normal.c:1121
 fatih#26 0x00000000006bf4b9 in main_loop (cmdwin=0, noexmode=0) at main.c:1374
 fatih#27 0x00000000006bdf2b in vim_main2 () at main.c:920
 fatih#28 0x00000000006bb637 in main (argc=2, argv=0x7ffec6fe2168) at main.c:444
```

Fixes fatih#1081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants