tweekmonster / gofmt.vim Goto Github PK
View Code? Open in Web Editor NEWA Vim plugin that runs gofmt when you save
License: MIT License
A Vim plugin that runs gofmt when you save
License: MIT License
Every time gofmt#apply
is invoked, another change is added to the undo tree. This is perfectly fine when gofmt
actually changes the buffer, but it's unnecessary and inconvenient if the buffer doesn't actually change.
The empty change in the undo tree makes it more effort to navigate the undo tree (for example with u
and CTRL-R
) and it marks the buffer as modified. This can force users to save the buffer unnecessarily, if the buffer was previously unmodified. This can happen when the function gets invoked in a way other than with the autocmd
, like with a mapping.
gofmt#apply
could check whether gofmt -l
lists its standard input as differing from its formatting. Based on that gofmt#apply
could terminate without making any changes to the buffer.
from gofmt --help
:
-l list files whose formatting differs from gofmt's
The -l
option is also supported by goimports
.
It might be a good idea to also add an option to enable or disable this behavior, for example if g:gofmt_exe
doesn't support the -l
flag or if it's undesired for some other reason.
My gofmt is under /usr/bin which is in PATH
, yet gofmt.vim is unable to find it.
As a workaround I used:
let g:gofmt_exe = '/usr/bin/gofmt
gofmt
command line will shows error message if the .go file has some syntax errors, and would not format the .go file. So if any improvement in this plugin to show errors as well in Vim window after saving .go file which has syntax error?
I like this little plugin, and it works fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.