This is a chezmoi source repository for personal dotfiles.
At the moment it manages:
dot_config/nvim/init.lua->~/.config/nvim/init.luadot_config/nvim/lua/plugins.lua->~/.config/nvim/lua/plugins.luadot_config/nvim/lua/lsp.lua->~/.config/nvim/lua/lsp.luadot_config/nvim/lua/cpp.lua->~/.config/nvim/lua/cpp.luadot_config/nvim/lua/terraform.lua->~/.config/nvim/lua/terraform.luadot_config/nvim/lua/local.lua.tmpl->~/.config/nvim/lua/local.luadot_config/nvim/nvim-pack-lock.json->~/.config/nvim/nvim-pack-lock.jsondot_tmux.conf->~/.tmux.conf
The local.lua.tmpl file is rendered by chezmoi and sets a platform-specific
C++ compiler value. It is also the place for host-local database connection
settings through vim.g.dbs.
Install the core tools before applying the dotfiles:
brew install chezmoi neovim tmux gitFor the C++ Neovim setup, install clangd and clang-format so LSP and formatting work:
brew install llvm clang-formatFor Telescope search performance, install ripgrep. It is used for live grep and fast file discovery:
brew install ripgrepFor Terraform and HCL LSP support, install terraform-ls:
brew install terraform-lsJSON formatting uses jq, and XML formatting uses xmllint:
brew install jq libxml2Install and select a Nerd Font in your terminal if you want file icons in nvim-tree and the statusline:
brew install --cask font-meslo-lg-nerd-fontThe native Telescope sorter also needs make and a C compiler. On macOS, install the Xcode Command Line Tools if those are missing:
xcode-select --installnvim-treesitter uses the tree-sitter CLI to build language parsers:
brew install tree-sitter-cliblink.cmp can build its native fuzzy matcher when cargo and rustup are
available. Without Rust it falls back to the Lua matcher and warns once:
brew install rustup
rustup-initOn non-macOS systems, use the equivalent package manager packages for
chezmoi, neovim, tmux, git, clangd, clang-format, terraform-ls,
tree-sitter-cli, ripgrep, jq, xmllint, make, and a C compiler.
Initialize chezmoi from this repository:
chezmoi init git@github.com:sushengloong/dotfiles.gitReview the changes before writing anything into $HOME:
chezmoi diffApply the dotfiles:
chezmoi applyOr initialize and apply in one command:
chezmoi init --apply git@github.com:sushengloong/dotfiles.gitCheck what chezmoi would change:
chezmoi status
chezmoi diffApply pending changes:
chezmoi applyEdit a managed file through chezmoi:
chezmoi edit ~/.config/nvim/init.lua
chezmoi diff
chezmoi applyAdd or refresh a file from $HOME into the source repository:
chezmoi add ~/.config/nvim/init.lua
chezmoi add ~/.config/nvim/lua/cpp.luaUpdate from the remote repository and apply changes:
chezmoi updateOpen the chezmoi source repository:
cd "$(chezmoi source-path)"
git statusThis configuration uses Neovim's native Lua config and avoids plugin manager frameworks such as lazy.nvim or Mason.
Optional plugins are installed with vim.pack when that API is available:
nvim-treesitter/nvim-treesitterstevearc/conform.nvimsaghen/blink.libsaghen/blink.cmpnvim-lua/plenary.nvimnvim-telescope/telescope.nvimnvim-telescope/telescope-fzf-native.nvimfolke/tokyonight.nvimnvim-tree/nvim-web-deviconsnvim-tree/nvim-tree.luatpope/vim-fugitivetpope/vim-dadbodkristijanhusak/vim-dadbod-uikristijanhusak/vim-dadbod-completionlewis6991/gitsigns.nvimnvim-lualine/lualine.nvim
Telescope uses telescope-fzf-native.nvim as its sorter because it is implemented in C and is materially faster than the default Lua sorter on larger lists. The config builds it with make after install or update when the compiled library is missing.
Telescope file search and live grep include hidden files while excluding
.git/ and build/.
blink.cmp provides completion with Super-Tab navigation, a rounded menu, automatically displayed documentation, LSP signatures, and LSP, path, snippet, and buffer sources. SQL-family buffers also receive vim-dadbod completion. Its optional Rust fuzzy matcher is built after plugin installation or update.
The active colorscheme is tokyonight-night. It was chosen for C++ because it has mature Tree-sitter, LSP, diagnostics, Telescope, and terminal color support. The config increases foreground, diagnostic, and line-number contrast, and disables italics for steadier terminal rendering inside tmux.
Editor defaults include soft wrapping at word boundaries, persistent undo
history, split live-substitute previews, visible-line movement with j/k,
search-highlight clearing with <Esc>, and brief highlighting after a yank.
JSON, XML, YAML, Python, C#, and SQL-family buffers use Tree-sitter expression
folding and open fully expanded. Use za to toggle the fold under the cursor,
zc/zo to close/open it, and zM/zR to close/open all folds.
The C++ configuration starts clangd for C, C++, Objective-C, Objective-C++, and CUDA buffers. Project roots are detected from:
compile_commands.json.clangd.gitCMakeLists.txt
The Terraform configuration starts terraform-ls serve for Terraform,
Terraform variables, and HCL buffers when the executable is installed.
Project roots are detected from .terraform, .terraform.lock.hcl, or .git.
Useful Neovim commands and keymaps:
:LspStatus Show attached LSP clients for the current buffer
<Esc> Clear search highlighting
j / k Move by visible line, or real line when given a count
gd Go to definition
gD Go to declaration
gr List references
gi Go to implementation
K Show hover documentation
<leader>rn Rename symbol
<leader>ca Code action
<leader>e Show diagnostics
[d / ]d Previous / next diagnostic
<leader>cf Format buffer with conform or LSP fallback
<leader>ff Find files
<leader>fg Live grep
<leader>fw Live grep for word under cursor or visual selection
<leader>fb Find buffers
<leader>fh Find help
<leader>fr Find recent files
<leader>fd Find diagnostics
<leader>fk Find keymaps
<leader>n Toggle nvim-tree
<leader>fn Reveal current file in nvim-tree
]c / [c Next / previous git hunk
<leader>gb Git blame current file
<leader>go Open current line or visual selection on the git remote
<leader>yp Copy the current file's absolute path
<leader>yr Copy the current file's cwd-relative path
<leader>yn Copy the current filename
<leader>db Toggle the database UI
<leader>df Find the current database buffer in the database UI
<leader>cr Build and run the current C/C++ file in a tmux pane
:CppRun Build and run the current C/C++ file in a tmux pane
:CppIncludePath Show compiler include directories used for gf
<leader>cr and :CppRun create or reuse a tmux pane below Neovim, compile the current file, and run the binary without moving focus out of Neovim. By default, the binary is written under build/nvim-run/ in the detected project root.
For C/C++ buffers, gf uses include directories discovered from the active compiler, so standard headers like vector and iostream can be opened without hardcoded system paths.
The default C++ build command is equivalent to:
clang++ -std=c++20 -Wall -Wextra -g current_file.cpp -o build/nvim-run/current_fileOverride the command in dot_config/nvim/lua/local.lua.tmpl if a project should use CMake or a custom binary name:
vim.g.cpp_run_command = "cmake --build build && ./build/my_program"The database UI is installed without repository credentials. Define named
connections in the rendered local.lua through vim.g.dbs, for example:
vim.g.dbs = {
local_postgres = os.getenv("DATABASE_URL"),
}<leader>db toggles the database UI and <leader>df reveals the database
buffer associated with the current query.
The tmux config is tuned for Neovim sessions:
- prefix remapped from
Ctrl-btoCtrl-a tmux-256colorwith true color enabled for common terminal types- extended key handling for terminal Neovim
- focus events for Neovim autocmds
- low escape timeout for modal editing
- mouse support and vi copy mode
- large scrollback for build and test output
- new panes and windows inherit the current project directory
- automatic window names show the foreground command or current directory
- pane movement with
Ctrl-a h,Ctrl-a j,Ctrl-a k, andCtrl-a l - optional prefix-free pane movement with
Alt-h,Alt-j,Alt-k, andAlt-l - repeatable
Ctrl-a </Ctrl-a >bindings move the current window in the window list - repeatable
Ctrl-a H/J/K/Lbindings resize panes in five-cell steps
Start a C++ project session:
tmux new-session -s cpp -c ~/src/projectInside the session, open Neovim in one pane:
nvim .Create a build pane in the same project directory:
tmux split-window -h -c "#{pane_current_path}"
cmake --build buildDetach and reattach:
tmux detach-client
tmux attach-session -t cppMove between panes:
Ctrl-a j Move to pane below
Ctrl-a k Move to pane above
Ctrl-a h Move to pane on the left
Ctrl-a l Move to pane on the right
Ctrl-a ↓ Move to pane below
Ctrl-a ↑ Move to pane above
Ctrl-a o Cycle panes
Ctrl-a H Resize pane left by 5 cells
Ctrl-a J Resize pane down by 5 cells
Ctrl-a K Resize pane up by 5 cells
Ctrl-a L Resize pane right by 5 cells
Reload tmux config after changes:
tmux source-file ~/.tmux.confRender the platform-specific local Neovim template without applying it:
chezmoi execute-template < dot_config/nvim/lua/local.lua.tmplOn macOS, this should render:
vim.g.cpp_compiler = "clang++"On Linux, this should render:
vim.g.cpp_compiler = "g++"List managed files:
chezmoi managedShow the target path for a source file:
chezmoi target-path dot_config/nvim/init.luaRe-apply only the Neovim config:
chezmoi apply ~/.config/nvimRe-apply only the tmux config:
chezmoi apply ~/.tmux.confIf Neovim opens but C++ LSP does not attach, confirm clangd is available:
which clangd
clangd --versionInside tmux, confirm the terminal type is the tmux terminfo entry:
echo "$TERM"It should print:
tmux-256color