-
-
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
Template creation and BufNewFile rules do not contemplate non-modifiable buffers #2096
Comments
I've create a non-modifiable Go file whose fileformat is dos and have no problems opening it. Can you construct a basic test case to demonstrate that this is a problem with vim-go and not a problem with something that vim-gina is doing?
vim-go doesn't read in the Go template unless the file is a new buffer. Even so, it doesn't attempt to write the buffer afterward; what problem did you actually experience? |
@bhcleek Pretty much as described in the "Configuration" section of the OP. Some more context: The errors in particular that occur when I say it "fails" is vim telling me that it can't set fileencoding (as vim-go attempts to do) because the buffer is not modifiable:
And when I patch that behavior to only do so when the buffer is modifiable (as seen in the gofiletype.vim change from the PR), it gives me the following:
Which gets solved with the other check added in the PR. From what I've been able to tell vim-gina seems to create a new "file" which is set to non-modifiable on creation, and vim-go assumes (in both the fileencoding set that is changed in the PR and the call to template_autocreate which is in Line 301 in 2e1eb6f
I'm sorry I couldn't provide a simpler test case that doesn't involve gina nor mentioned the specific errors, I was a bit hurried so I thought the patch and issue description would suffice. Truth be told, I'm not sure how I could create a simpler test case. I tried to look at gina's codebase to see where the blame command creates the buffer but couldn't make much sense of it since I'm only vaguely familiar with Vimscript. Please let me know if I could be of further assistance. |
This fact points to something odd in gina.vim. Ultimately, I see this as being a problem with the way gina.vim is functioning; it's using This PR has prompted me to take a closer look at Thanks for all the feedback. For now, I think we can leave this issue open; I'll likely refactor the files I mentioned in the near future. |
What did you do? (required. The issue will be closed when not provided.)
Tried to open a .go file in a non-modifiable buffer, specifically, vim-gina's Blame's.
What did you expect to happen?
vim-go not to interfere.
What happened instead?
vim-go attempted to set fileencoding, and when patching that out, attempts to instantiate the go template.
Configuration (MUST fill this out):
vim-go version: 1896764
vimrc
you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):Assuming vim-plugged installed:
Open a .go file, run
:Gina blame
, first time works, try again, next time fails.:version
):go version
):go version go1.11.3 linux/amd64
go env
):The text was updated successfully, but these errors were encountered: