Skip to content

iomz/dotfiles

Repository files navigation

Linux macOS Neovim Zsh

dotfiles powered by chezmoi


Synopsis

sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply iomz

Go, Lua, NodeJS, and Python runtimes used by Neovim are managed by asdf (asdf itself is installed at the first time zsh starts), and it is not automated by Zinit.

Other runtime (e.g, Deno and Rust) is taken cared in~/.zshenv.

  1. Installation of the dependencies (automatically done via run_once_install_packages.sh.tmpl

  2. Install Go, Lua (with LuaRocks), NodeJS, and Python via asdf

for i in golang lua nodejs python; do
    IFS=","; set -- $i;
    lang=$1; repo=$2;
    asdf plugin-add $lang $repo && \
        asdf install $lang latest && \
        asdf global $lang latest;
done
  1. Install the neovim modules
pip install --upgrade pip && pip install neovim
npm i -g neovim
  1. (Optional) Install other stuff
for i in pnpm poetry; do
    IFS=","; set -- $i;
    lang=$1; repo=$2;
    asdf plugin-add $lang $repo && \
        asdf install $lang latest && \
        asdf global $lang latest;
done

Font

I am borrowing MesloLGS Nerd Font from romkatv/powerlevel10k to be installed on macOS.

Just enter the following in Zsh (the script is a reduced version of this):

install-meslo-nerd-font

Notes

Neovim: force reinstall the executable linked from $ZPFX ("polaris")

A nightly version of nvim binary is installed by Zinit; however, the nightly tag won't change for new commits in the repository. To update a nightly version of the installed nvim, simply remove the plugin directory and reopen zsh to force install it again.

rm -fr ${XDG_DATA_HOME}/zinit/plugins/neovim---neovim

Zinit: missing completion link

After zinit update, some completions may get broken (check with zinit completions). If any, clean up the broken links by

zinit cclean

Zsh: order of executions

First of all, $HOME/.profile contains the local option like ${TINY_CHEZMOI} while ~/.profile is only loaded when running zsh in sh compatibility mode. If TINY_CHEZMOI=1, then it doesn't load the heavy setup (nvim, cargo, deno (zeno), and so forth).

The setup loads in the order of

$HOME/.zshenv → $HOME/.config/zsh/.zshrc → $ZDOTDIR/rc.d/**

while the default is

.zshenv → .zprofile → .zshrc → .zlogin → .zlogout
  1. .zshenv is always sourced. It often contains exported variables that should be available to other programs. For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv. Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.
  2. .zprofile is for login shells. It is basically the same as .zlogin except that it's sourced before .zshrc whereas .zlogin is sourced after .zshrc. According to the zsh documentation, ".zprofile is meant as an alternative to .zlogin for ksh fans; the two are not intended to be used together, although this could certainly be done if desired."
  3. .zshrc is for interactive shells. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).
  4. .zlogin is for login shells. It is sourced on the start of a login shell but after .zshrc, if the shell is also interactive. This file is often used to start X using startx. Some systems start X on boot, so this file is not always very useful.
  5. .zlogout is sometimes used to clear and reset the terminal. It is called when exiting, not when opening.

It reads .zprofile, as well as .zshrc for interactive and .zlogin for login shells.

cf. What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?

Zsh: diagnosing the slow start

Sometimes there are "bugs" hard to identify during the startup process, and they might cause inconsistent behaviors that are hard to be logged.

In addition to the $ZPROF environmental value set before starting zsh, also make use of ${ENABLE_ZPROFTIME}.

When you start zsh with ${ENABLE_ZPROFTIME}, it writes out a log to /tmp/zproftime.XXXX and can be examined with the autoloaded function (for example):

zproftime-sort /tmp/zproftime.* | head

cf. How to profile your zsh startup time by Benjamin Esham

Zsh: manage binaries with zinit and z-a-linkbin

Zinit automatically downloads some binaries and creates links in $ZPFX/bin (i.e., ~/.local/share/zinit/polaris/bin) with the zinit-annex-binary-symlink.

See the config file at https://github.com/iomz/dotfiles/blob/main/dot_config/zsh/rc.d/03-polaris.zsh