From working the usual 9 to 5 job on top of studying data engineering (Python, SQL, DE concepts), I’ve been feeling a little burnt out with everything. I decided to take a break and revisit my development environment to see what I could add, remove or even change.
It’s been a while. According to my dotfiles repository, it’s been about 6 years since I last updated it. This makes sense since in my aliases
file, the most used aliases I’ve used over the years are:
alias ..='cd ..'
alias gs='git status'
alias ga='git add .'
alias gd='git ls-files --deleted | xargs git rm'
alias gc='git commit'
alias gl='git log --pretty="%H %s"'
alias gp='git push'
alias gf='git difftool'
alias bell="tput bel"
That’s it. I mean, there are other aliases and exports in my dotfiles but I rarely use them daily.
The ulterior motives
Faster. That’s at least one of the goals when customizing a development environment. This was my motive.
VSCode has served me well over the years. It prevented me from getting the Sublime Text pop-up that “suggests” for you to buy it. In a previous post, I explained the magic of vim motions within VSCode. But honestly, there were times when I turned the vim plugin off. Going back and forth between the two, eventually, I never bothered and/or forgot to turn it back on.
After a while, I noticed that VSCode got slower. Depending on the project I was on, it would go from a speedy turtle pace to a snail’s pace. Yes, both are slow but you get the gist. It came to a point where I was uninstalling VSCode extensions to try to improve the speed. I also kept the file explorer closed due to VSCode taking forever to load huge directories.
So there I was with a single VSCode window with nothing else open and barely any extensions installed. Its fuzzy finder (cmd/ctrl + P
) left much to be desired. In huge directories, adding a file that was created by an external script would take ~10 seconds for the newly created file to show up in VSCode’s fuzzy finder. I found myself audibly grunting at the delay.
Preventing repetitive stress injury. I’ve been having trouble with my shoulder lately and mouse work has gotten a bit painful if I keep reaching for it. I needed a way to prevent this as much as possible.
Hi, Neovim
Much of my free time is spent consuming content from the gaming community. Recently, I shifted to consuming content from the developer community. I stumbled upon The Primeagen’s vim series and got very excited. It’s hard not to get excited when watching his videos. He always sounds so passionate. I viewed his vim setup video in its entirety and was fascinated.
I spent a couple of days learning and setting everything up. Doing so lit a fire inside me that I haven’t felt in a while. I was programming to make my programming faster. Well, technically I’d call it “configuring”.
Day 1
Much of Day 1 was spent re-learning vim motions and getting the lay of the land as far as the Neovim ecosystem. I wanted to know how it was possible to configure Neovim like I’ve seen others do without Vimscript.
I discovered that Neovim uses the Lua programming language to extend functionality! The only reason I got excited about Lua is because I had some experience with it in my World of Warcraft days. Not an expert, but it was cool to see Lua being used for something in a completely different context. Before Neovim, I thought Lua was just used for WoW extensions.
I wanted to understand how developers extend Neovim so I decided to follow this video in setting up everything from scratch. Everything worked flawlessly. I installed plugins for syntax highlighting, fuzzy finding, colored everything so it looks sexy, status bar customizations, and a file explorer.
But am I the one to maintain all of this a year down the road? How about 3 years down the road? I wasn’t going to remember most of the things I did to install and configure Neovim.
Day 2
Now that I knew how to install a plugin, configure it and use it inside of Neovim, I wanted to see what kind of “bundles” were out there as far as Neovim setups. Why should I maintain my setup when someone else can do it for me, right? :)
I found a couple of notable ones:
I started with kickstart.vim
bundle (pun intended), and everything looked and worked perfectly. But where was I to put all of my customizations? I saw the examples and while it looked like a good solution I wanted to try something else.
I ended up going with NvChad. My reasons are probably going to be hilarious and/or stupid to some, but I liked the theme switcher and cheat sheet features already bundled in NvChad. Could install these features with kickstart.vim
? Sure, but no thanks.
I spent a longer time choosing a font and a theme compared to the amount of time it took to install Neovim, NvChad, and tmux combined.
Oh, tmux. Yes, I installed it without really knowing what it was used for. I saw everyone using it so it must be good, right? Well, after diving into what it actually does, I found a use for it. I probably won’t be using all of its features, but they’re there for when I do I guess.
After everything was configured, now what? I knew I was going to be updating this config as I work in it so I wanted a way to save changes in case I needed them later. That’s what I’ll tackle on Day 3.
Day 3
There were two things I wanted to do. I wanted a way to install all of my customizations in Neovim/NvChad, tmux, and general dotfiles. I also wanted a way to pull any changes I’ve made to either Neovim/NvChad and/or tmux. The latter is the more important one since I’ll rarely be installing dotfiles.
Also, I guess I should say I’m adding things to my dotfiles repository that aren’t necessarily “dotfiles”. I know, I know. I usually like to separate this but all of these things in my dotfile repository are for my development environment. So the purpose fits.
The bash scripts I’ve made for both the install and the update are pretty simple and probably need refactoring. But it works.
#!/bin/bash
# install script for dotfiles, neovim, nvchad, tmux
echo "==============================================="
echo "-- Running install..."
zshrc_path="$HOME/.zshrc"
zshrc_add='source $HOME/src/dotfiles/zshrc'
if ! grep -qF "$zshrc_add" $zshrc_path; then
# Append the code if the search line is not found
echo "# dotfiles" >> "$zshrc_path"
echo "$zshrc_add" >> "$zshrc_path"
echo "-- Dotfiles have been installed."
else
echo "-- Dotfiles have already been installed. No changes made."
fi
echo "-- Installing nvim configuration..."
cp -R "$HOME/src/dotfiles/nvchad/" "$HOME/.config/nvim/lua/custom/"
echo "-- Configuration for nvim has been installed."
echo "-- Attempting to install tmux..."
brew update
brew install tmux
echo "-- Installing tmux configuration..."
old_tmux_config="$HOME/.tmux.conf"
new_tmux_config="$HOME/src/dotfiles/tmux/tmux.conf"
if [ -f "$old_tmux_config" ]; then
echo "-- Found an old tmux configuration. Backing up..."
timestamp=$(date +"%Y%m%dH%M%S")
backup_file="$HOME/.tmux.conf.backup.${timestamp}"
# Create backup
cp "$old_tmux_config" "$backup_file"
# Install new tmux configuration
cp "$new_tmux_config" "$HOME/.tmux.conf"
else
cp "$new_tmux_config" "$HOME/.tmux.conf"
fi
echo "-- Installing tmux package manager..."
if [ -d "$HOME/.tmux/plugins/tpm" ]; then
echo "-- The tmux package manager is already installed. Skipping..."
else
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
echo "-- tmux package manager has been installed."
fi
echo "-- Configuration for tmux has been installed."
cp "$HOME/src/dotfiles/tmux/tmux.conf" "$HOME/.tmux.conf"
echo "==============================================="
The echo
statements describe what this script is doing. I’m torn though. I think I’ll be taking the lines of code that install tmux. I think I want this script to only install configurations. We’ll see.
The “update” script I’ve created is the more important one. Over time, I’ll be modifying my configurations in Neovim/NvChad, tmux or dotfiles.
#!/bin/bash
# update script for neovim, nvChad, tmux
echo "========================================="
timestamp=$(date "+%Y%m%d%H%M%S")
nvm_custom="$HOME/.config/nvim/lua/custom"
nvm_dest="$HOME/src/dotfiles/nvchad/"
cp -rf "$nvm_custom"/* "$nvm_dest"
echo "-- Pulled your custom updates from ~/.config/nvim..."
cp "$HOME/.tmux.conf" "$HOME/src/dotfiles/tmux/tmux.conf"
echo "-- Pulled your tmux configuration..."
echo "-- Checking for changes..."
cd "$HOME/src/dotfiles"
git_status=$(git status)
if [[ "$git_status" == *"nothing to commit, working tree clean"* ]]; then
echo "-- No changes found in the repository. Exiting..."
else
git add .
git commit -m "dotfiles update ${timestamp}"
git push origin master
echo "-- Update complete."
fi
echo "========================================="
This script is pretty simple. I’m copying and pasting the config files to my dotfiles repository and pushing it to Github with a timestamped commit message.
To infinity and beyond…
I deem this setup as “good enough”. I don’t want to spend too much time on this configuration. I could easily go on an infinite loop working on this stuff. It’s very addicting. If I get stuck configuring, I’ll never have time to build anything!
I will be updating my configuration as I work with it or find settings that another developer uses that will better my setup.
There’s one issue I’d like to solve next though. I’m having an issue changing the color of my cursor depending on which mode vim is in. It’s not straightforward to me how to do that. I’ll figure it out in time.
My dotfiles repository can be found on Github.
Be sure to follow me @chrisparaiso.