-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Auto go fmt on save #5
Comments
Hi, It is possible to pass options to the formatter like so: Via the go-vim setting: However now I'm wondering how would it be possible to pass these settings when using I'm trying to get my code formatted with spaces instead of tabs, 4 spaces in width. |
Well just pass it to goimports binary path!
can you try it? |
I have 2 issues with that approach.
|
My suggestion was based on that you had a goimports installed somewhere else. We need to seperate binary path and the options. I've opened a new issue where we are gonna introduce a new parameter. Let us talk from there now. Thanks for reporting. |
I see the commit 13a71b0 adds new option, but I'm wondering how can that option be used to achieve go-vim usage of goimports combined with custom formatting settings ( |
That's up to the go fmt command, if you use let g:go_fmt_options = "-tabs=false -tabwidth=4" |
@fatih Well, naturally that's the first thing I tried before posting here, and it didn't work for me. I went ahead, and deleted every occurrence of goimports from my system, and had the go-vim plugin re-install it. The behavior is pretty much the same as with the one described 9 days ago. When I hit Here is my current vimrc |
|
Well than, that means if I want to do goimports there is no way for me to format my code with proper spacing (other than running :%retab on BufWritePost)? |
Yes, unfortunately this is a limitation of |
I was aware of this limitation, I thought that you would do some magic with new update (eg. run goimports first, and than gofmt over it). The goimports tool is really stupid in this sense, they should merge it with gofmt and provide it as a flag. |
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
# This is the 1st commit message: Add in functionality to test single case in table # This is the commit message fatih#2: internm commit for implementing name discovery # This is the commit message fatih#3: Add ability to run single test case # This is the commit message fatih#4: move subtest name detection to a helper function # This is the commit message fatih#5: use line instead of detecting case
No description provided.
The text was updated successfully, but these errors were encountered: