Month: September 2018
Highlights from Git 2.19 and PHP syntax
GitHub blog covers the highlights from Git 2.19, which was recently released.
One particular change that I want to highlight (which GitHub skipped in their highlights, but which exists in the Git release notes for this version) is the syntax pattern update for the PHP files.
Let’s have a look at the full diff of this release. The particular change I am referring to is in the userdiff.c file. Git now understands final, abstract, interface, and trait keywords.
If you are not sure where and how it is used, here are a couple of useful links for you:
- .gitattributes documentation section on settings the syntax of the file for diffs. Basically, you just need to add “*.php diff=php” to the .gitattributes file. Unfortunately, this is done on a per-project level, rather than globally on a user level. (See this blog post for more details).
- More info on the same subject: How Does Git Know What Functions Look Like?
Now that you have it all configured, there are a couple of ways to benefit from this functionality. First, you’ll see a more useful context comment in the diffs. Here’s the screenshot (using an older git version still). On the left, the diff without the PHP syntax configured, and on the right is the diff with the PHP syntax configured:
As you can see, on the left, the context shows that the change was done somewhere in the ChangeLogTrait trait. On the right, the context is much more specific – it shows that the change was done in the public function changelog.
This makes reviewing code changes a lot easier. But there is also one other place where this is useful – in reviewing the history of a particular function. For example, running “git log -L :changelog:ChangelogTrait.php” will produce the git log output containing only the commits and diffs on the function changelog in the file ChangelogTrait.php. Very handy!
After years and years of waiting for the templates to make it to Evernote, the feature is finally here! There are about 30 templates to choose from, and, of course, you can create your own.
Well done, Evernote!
Vim tweaks and updates
Over the last few weeks, I have significantly changed and updated my Vim configuration. I’ve been using the editor for decades, and yet I every time I revisit my setup, I am amazed at how far the editor progressed and how wisdom the Vim community shares via themes, plugins, configuration tweaks, etc.
Here are some of the highlights this time around:
- Switched from Pathogen plugin manager (and Ansible bits) to Vundle.
- Added vim-devicons plugin and a patched font that supports them.
- Switched from Syntastic to ALE for faster and better syntax checks.
- Improved the code completion configuration, tags, and such.
- Added a whole bunch of plugins for developers.
I am still getting used to some new shortcuts, catching up on the documentation, and trying things out. But if it’s been a while since you’ve looked at your own Vim configuration, I suggest you do so. Things are moving and evolving faster than you might think.