vim-go icon indicating copy to clipboard operation
vim-go copied to clipboard

Question: Weird behavior with newly created go project files

Open stefanos82 opened this issue 7 years ago • 4 comments

I use the latest version of vim-go from github using Vim 8.0 under Debian testing 64-bit.

vim-go gives the user the opportunity to open a new main.go file in the form of a skeleton.

What I usually do when I want to build a new project from scratch is to open a nonexistent folder combined with main.go and inside Vim I run a standard command :!mkdir -p %:h to create my folder and then save my file so I can start working on my project.

Immediately after I press my Enter key to return back to Vim from my terminal output, I press :w to write on the newly created file that is located in the newly created folder.

With vim-go I get the following behavior though:

"foo/main.go" E212: Can't open file for writing

As soon as I close Vim and reopen it from the newly created folder with the main.go and press the :w command, now it writes it to the aforementioned location.

Should this behavior be considered a bug or no?

Please advice, thank you.

stefanos82 avatar Mar 11 '18 16:03 stefanos82

Yes, this should be considered a bug.

bhcleek avatar Mar 11 '18 21:03 bhcleek

This seems to work well for me. I actually fixed this before in #1618.

arp242 avatar Apr 08 '18 00:04 arp242

@Carpetsmoker The issue remains for me even with the latest updates.

stefanos82 avatar Apr 08 '18 18:04 stefanos82

#1618 doesn't solve this problem for me as described by @ stefanos82. All that #1618 does is to make sure the package name is determined correctly.

Calling vim notadir/quux.go and immediately running :w displays the message Can't open file for writing. The same message is shown when the file in a non-existent directory is created by opening it with :e notadir/quux.go from within vim. This is an issue with Vim, though, not with vim-go....

However, calling vim notadir/quux.go and immediately running :!mkdir notadir followed by :w displays the message Autcommands deleted or unloaded buffer to be written.

You can see this result pretty easily with our docker container:

docker run --rm -i -t --entrypoint /tmp/vim-go-test/vim-8.0-install/bin/vim vim-go-test -N +"set packpath=/tmp/vim-go-test/vim-8.0-install/share/vim/vimgo" +"filetype plugin indent on" +'packloadall!' +'e notadir/quux.go' +'!mkdir notadir' +'w'

bhcleek avatar Apr 08 '18 19:04 bhcleek