Development Configuration

After upgrading my machine at work, I had to migrate my configuration, and even remember some forgotten details about it. This is an attempt to document them for future reference:

Git config:

Prerequisite: delta.

[user]
    email = work.email@here
    name = Cristian A. Ontivero
[diff]
    algorithm = histogram
[merge]
    conflictstyle = zdiff3
[pack]
    useSparse = true
[pull]
    rebase = true
[pager]
    diff = delta
    log = delta
    reflog = delta
    show = delta
[interactive]
    diffFilter = delta --color-only
[delta]
    features = line-numbers decorations
    whitespace-error-style = 22 reverse
[delta "decorations"]
    commit-decoration-style = bold yellow box ul
    file-style = bold yellow ul
    file-decoration-style = none
[core]
    bare = false
    compression = 9
    editor = vim -c 'startinsert!'
    filemode = false
    ignorecase = true
    logallrefupdates = true
    repositoryformatversion = 0
    symlinks = false
    pager = less -x1,5
    hooksPath = githooks

Some explanations:

  1. According to a 2019 paper, the histogram diff algorithm tends to create better patches, leading to less merge conflicts. Of course, it’s not the best algorithm for every case, but it is a sensible default.
  2. Zealous diff3 (zdiff3) as conflictstyle for merges is quite useful, since it provides more context, and even attempts to solve in part the conflict by extracting out shared snippets of code when it’s safe to do so.
  3. useSparse = true under pack enables an algorithm developed by Microsoft to improve the performance when pushing large repos. Though having this enabled now is the default.

Shell

I’ve gotten used to zsh. For the prompt, I’ve been using zsh-git-prompt for a couple of years already without complaints. It hasn’t been maintained for around a decade, but it does it job and does it well.

I have a couple of aliases to ease frequent git uses in my .zshrc. The first two make use of git-fuzzy:

alias gfs="git fuzzy status"
alias gfb="git fuzzy branch"
alias go="git checkout"
alias gca="git commit --amend --date=now"
alias gri="git rebase -i"
alias gd="git diff"
alias gdc="git diff --cached"

alias gom="git checkout master"
alias gor="git checkout release"
alias gorc="git checkout release-candidate"

The last ones of course depend on which branches you deal with frequently in your day-to-day project.

Eclipse (Java development):

  • Full name in javadocs @author tag: add -Duser.name=DESIRED NAME in eclipse.ini
  • One can tell Eclipse from where to suggest imports by adding them in Java > Editor > Content Assistant > Favorites. Some useful ones are:
    • java.util.Arrays.* (asList())
    • java.util.Collections.*(emptyList(), emptyMap(), singletonList(), etc.)
    • java.util.stream.Collectors.* (toSet(), toList(), etc.)
  • Java > Editor > Templates:
    • To add a Log4J logger:
${:import(org.apache.logging.log4j.Logger,org.apache.logging.log4j.LogManager)}
private static final Logger logger = LogManager.getLogger();

Vim

There is a sea of configurations and plugins available for vim. The bare basics I like having pertain git commit messages. In .vimrc, enable the filetype plugin:

filetype plugin on
au FileType gitcommit setlocal tw=72

Then, inside ~/.vim/ftplugin/gitcommit.vim:

" Enable spell checking to avoid spelling mistakes in commit messages
set spell spelllang=en_us

set smartindent

" Show line at limit of commit message length
set ruler
set colorcolumn=+1
highlight ColorColumn ctermbg=lightgrey guibg=lightgrey