diff options
25 files changed, 614 insertions, 271 deletions
@@ -1,14 +1,28 @@ # Dotfiles -Personal dotfiles. +These are my personal dotfiles for macOS systems. + +All configuration files are managed using [GNU Stow](https://www.gnu.org/software/stow/), which automatically creates symlinks from this repository to the appropriate locations in your `$HOME` directory. The repository also includes scripts for managing and syncing your Homebrew packages via a Brewfile. ## Installation -To get the repo and install the dotfiles, you'll want to do a git clone and run the included shell script. +Clone the repository (recommended: `~/.dotfiles`) and run the installation script: -``` -git clone git@github.com:eugenetriguba/dotfiles.git -cd dotfiles +```sh +git clone git@github.com:eugenetriguba/dotfiles.git ~/.dotfiles +cd ~/.dotfiles chmod u+x install.sh ./install.sh ``` + +## Homebrew Packages + +To update your `homebrew/Brewfile` with your currently installed Homebrew formulae and casks, run: + +```sh +chmod u+x homebrew/sync-brewfile.sh +./homebrew/sync-brewfile.sh +``` + +This script only updates the `homebrew/Brewfile` with your current manually installed Homebrew packages; it does not install or remove any packages. You can then use `git diff` to review the changes. + diff --git a/executables/bin/gh-clone-all b/executables/bin/gh-clone-all index 742189b..77de93a 100755 --- a/executables/bin/gh-clone-all +++ b/executables/bin/gh-clone-all @@ -1,11 +1,102 @@ -#!/bin/sh +#!/usr/bin/env bash +# Clone all repositories from a GitHub user or organization using the gh CLI. # -# Clone down all repositories from a GitHub entity. +# Usage: +# gh-clone-all [--exclude-archived] [--exclude-forks] [--pull] <github-entity> [target-directory] # # Args: -# $1: The entity name to clone. i.e. github.com/eugenetriguba => eugenetriguba +# --exclude-archived: If set, skip archived repos (default: include all) +# --exclude-forks: If set, skip forked repos +# --pull: If set, pull latest changes in existing repos +# --limit: The maximum number of repos to clone (default: 10000) +# <github-entity>: The GitHub username or org (e.g. eugenetriguba) +# [target-directory]: Optional directory to clone repos into +set -euo pipefail -gh repo list "$1" --limit 10000 | while read -r repo _; do - gh repo clone "$repo" "$repo" -done +EXCLUDE_ARCHIVED=0 +EXCLUDE_FORKS=0 +PULL_EXISTING=0 +ENTITY="" +TARGET_DIR="." +LIMIT=10000 +main() { + parse_args "$@" + clone_all_repos +} + +parse_args() { + while [[ $# -gt 0 ]]; do + case "$1" in + --exclude-archived) + EXCLUDE_ARCHIVED=1 + shift + ;; + --exclude-forks) + EXCLUDE_FORKS=1 + shift + ;; + --pull) + PULL_EXISTING=1 + shift + ;; + --limit) + LIMIT="$2" + shift 2 + ;; + -*) + usage + ;; + *) + if [[ -z "$ENTITY" ]]; then + ENTITY="$1" + elif [[ "$TARGET_DIR" == "." ]]; then + TARGET_DIR="$1" + else + usage + fi + shift + ;; + esac + done + if [[ -z "$ENTITY" ]]; then + usage + fi + mkdir -p "$TARGET_DIR" +} + +usage() { + echo "Usage: $0 [--exclude-archived] [--exclude-forks] [--pull] [--limit] <github-entity> [target-directory]" + exit 1 +} + +clone_all_repos() { + gh repo list "$ENTITY" --limit "$LIMIT" --json name,sshUrl,archivedAt,isFork | + jq -c '.[]' | while read -r repo; do + NAME=$(echo "$repo" | jq -r '.name') + CLONE_URL=$(echo "$repo" | jq -r '.sshUrl') + ARCHIVED_AT=$(echo "$repo" | jq -r '.archivedAt') + IS_FORK=$(echo "$repo" | jq -r '.isFork') + DEST="$TARGET_DIR/$NAME" + if [[ "$EXCLUDE_ARCHIVED" -eq 1 && "$ARCHIVED_AT" != "null" ]]; then + continue + fi + if [[ "$EXCLUDE_FORKS" -eq 1 && "$IS_FORK" == "true" ]]; then + continue + fi + if [[ -d "$DEST" ]]; then + echo "Repo $NAME already exists." + if [[ "$PULL_EXISTING" -eq 1 ]]; then + echo "Pulling latest changes in $DEST" + git -C "$DEST" pull --ff-only || echo "Warning: git pull failed in $DEST, continuing..." + else + echo "Skipping $NAME (already exists)" + fi + continue + fi + echo "Cloning $CLONE_URL into $DEST" + git clone "$CLONE_URL" "$DEST" + done +} + +main "$@" diff --git a/gdb/.gdbinit b/gdb/.gdbinit deleted file mode 100644 index 21a3384..0000000 --- a/gdb/.gdbinit +++ /dev/null @@ -1,2 +0,0 @@ -set disassembly-flavor intel - diff --git a/homebrew/Brewfile b/homebrew/Brewfile index d7b1824..e956ef5 100644 --- a/homebrew/Brewfile +++ b/homebrew/Brewfile @@ -1,16 +1,22 @@ tap "neovim/neovim" tap "eugenetriguba/bolt" +brew "act" brew "ansible" +brew "bandit" brew "bat" brew "bats-core" -brew "bolt" brew "ca-certificates" brew "clang-format" brew "cmake" brew "cmocka" brew "colima" brew "coreutils" +brew "cppcheck" +brew "ctags" brew "curl" +brew "doxygen" +brew "duckdb" +brew "eugenetriguba/bolt/bolt" brew "fd" brew "ffmpeg" brew "fzf" @@ -20,17 +26,25 @@ brew "git" brew "gnupg" brew "go" brew "gradle" +brew "hadolint" brew "htop" +brew "icu4c@76" brew "jc" brew "jq" +brew "jsonlint" +brew "julia" brew "libffi" -brew "libpq" brew "lima" brew "llvm" +brew "llvm@14" +brew "luajit" +brew "luarocks" brew "make" brew "mas" +brew "meson" brew "mvt" brew "nasm" +brew "ncdu" brew "neovim" brew "nmap" brew "node" @@ -41,32 +55,37 @@ brew "openjdk" brew "openssl@3" brew "pinentry-mac" brew "pipx" -brew "poetry" -brew "postgresql" +brew "pkgconf" +brew "postgresql@14" brew "pre-commit" -brew "pyenv" brew "pyenv-virtualenv" +brew "pyenv" brew "python@3.11" brew "python@3.12" +brew "python@3.13" brew "qemu" brew "readline" brew "ripgrep" brew "rsync" -brew "ruby" +brew "ruff" brew "rustup" brew "speedtest-cli" brew "splint" brew "stow" brew "stylua" brew "telnet" -brew "tmux" brew "terraform" +brew "tflint" brew "tldr" +brew "tmux" brew "tree" brew "vim" brew "wget" brew "xz" +brew "yt-dlp" +brew "zig" brew "zlib" +cask "1password-cli" cask "1password" cask "docker" cask "elgato-control-center" @@ -74,10 +93,11 @@ cask "font-hack-nerd-font" cask "font-inter" cask "font-menlo-for-powerline" cask "ghostty" -cask "iterm2" +cask "hashicorp-vagrant" cask "obsidian" cask "omnifocus" +cask "neovide" cask "raycast" cask "rectangle" cask "spotify" -cask "vivaldi" +cask "vagrant" diff --git a/homebrew/install.sh b/homebrew/install.sh index baa051a..a211828 100755 --- a/homebrew/install.sh +++ b/homebrew/install.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash +set -euo pipefail +echo "Installing Brewfile.." brew bundle install --file=./Brewfile - +echo "Brewfile successfully installed." diff --git a/homebrew/sync-brewfile.sh b/homebrew/sync-brewfile.sh index 3768d7b..bf36e10 100755 --- a/homebrew/sync-brewfile.sh +++ b/homebrew/sync-brewfile.sh @@ -1,11 +1,15 @@ #!/bin/bash # Create a new Brewfile with only manually installed formulae and casks -(echo 'tap "homebrew/cask-fonts"'; \ - echo 'tap "neovim/neovim"'; \ - echo 'tap "eugenetriguba/bolt"'; \ - brew bundle dump --file=- --force | \ - (grep -E "^brew" | grep -f <(brew leaves) ; brew list --cask | sed 's/^/cask "/;s/$/"/') | \ - sort) > Brewfile +( + echo 'tap "neovim/neovim"' + echo 'tap "eugenetriguba/bolt"' + brew bundle dump --file=- --force | + ( + grep -E "^brew" | grep -f <(brew leaves) + brew list --cask | sed 's/^/cask "/;s/$/"/' + ) | + sort +) >Brewfile echo "Brewfile has been updated with only manually installed packages." @@ -1,22 +1,31 @@ -#!/bin/sh +#!/usr/bin/env bash # # Install the Homebrew Brewfile and setup symbolic links to the # dotfiles. -# - -# Installs homebrew and verifies the installation. -# If the install was not successful, exits with a -# 1 status code. -install_homebrew() { - /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>"$HOME/.zprofile" - eval "$(/opt/homebrew/bin/brew shellenv)" +set -eou pipefail - homebrew_exists=$(command -v brew) - if test -z "$homebrew_exists"; then - echo "Failed to install homebrew" - exit 1 +main() { + if ! command -v brew >/dev/null 2>&1; then + if prompt_for_confirmation "Homebrew not found. Would you like to install Homebrew?"; then + install_homebrew + else + echo "Exiting, can't continue without Homebrew installed." + exit 0 + fi fi + + echo "Found homebrew installation. Installing Brewfile.." + (cd homebrew && brew bundle) + echo "Brewfile successfully installed. Moving to linking dotfiles.." + + stow executables + stow nvim + stow zsh + stow git + stow gpg + stow tmux + stow ghostty + echo "Successfully linked all dotfiles." } # Prompt the user for confirmation on an action. @@ -30,76 +39,28 @@ install_homebrew() { prompt_for_confirmation() { printf "%s [y/n]: " "$1" read -r answer - if [ "$answer" != "${answer#[Yy]}" ]; then + if [[ "$answer" != "${answer#[Yy]}" ]]; then return 0 else return 1 fi } -ensure_symlink_exists() { - source_path="$1" - link_path="$2" +# Installs homebrew and verifies the installation. +# +# If the install was not successful, exits with a +# 1 status code. +install_homebrew() { + /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - echo "Checking link to '$link_path'.." - if [ -L "$link_path" ]; then - if [ -e "$link_path" ]; then - echo "Valid '$link_path' link exists." - else - echo "'$link_path' link exists, but it is a broken link." - prompt_for_confirmation "Delete and relink?" - answer=$? - if [ $answer -eq 0 ]; then - rm -r "$link_path" || exit 1 - ln -s "$source_path" "$link_path" || exit 1 - echo "Successfully created link to '$link_path'" - else - echo "Leaving file alone, moving on.." - fi - fi - elif [ -e "$link_path" ]; then - echo "'$link_path' exists, but it isn't a symbolic link file." - prompt_for_confirmation "Delete and relink?" - answer=$? - if [ $answer -eq 0 ]; then - rm -r "$link_path" || exit 1 - ln -s "$source_path" "$link_path" || exit 1 - echo "Successfully created link to '$link_path'" - else - echo "Leaving file alone, moving on.." - fi - else - echo "Link to '$link_path' does not exist. Creating.." - ln -s "$source_path" "$link_path" || exit 1 - fi -} + # shellcheck disable=SC2016 + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>"$HOME/.zprofile" + eval "$(/opt/homebrew/bin/brew shellenv)" -main() { - has_homebrew=$(command -v brew) - if test -z "$has_homebrew"; then - prompt_for_confirmation "I couldn't find a homebrew installation. Would you like to install homebrew?" - answer=$? - if [ $answer -eq 0 ]; then - install_homebrew - else - echo "Exiting, can't continue without homebrew installed." - exit 0 - fi + if ! command -v brew >/dev/null 2>&1; then + echo "Failed to install homebrew" + exit 1 fi - - echo "Found homebrew installation. Installing Brewfile.." - (cd homebrew && brew bundle || exit 1) - echo "Brewfile successfully installed. Moving to linking dotfiles.." - - stow executables - stow nvim - stow zsh - stow git - stow gdb - stow gpg - stow tmux - stow ghostty - echo "Successfully linked all dotfiles." } main diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 3fdaa00..652413b 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,32 +1,32 @@ { + "CopilotChat.nvim": { "branch": "main", "commit": "55f2162c36901224e22ff8424fd60ecef670b8fc" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, + "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, - "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "copilot.lua": { "branch": "master", "commit": "46f4b7d026cba9497159dcd3e6aa61a185cb1c48" }, "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "mini.nvim": { "branch": "main", "commit": "1b32a3f61f1f649cadc748bd4b7a32b4b4785d29" }, + "mini.nvim": { "branch": "main", "commit": "8ca3965e68edfee5f438d4063f5adf5afa255884" }, "neo-tree.nvim": { "branch": "main", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" }, + "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-python": { "branch": "master", "commit": "261ce649d05bc455a29f9636dc03f8cdaa7e0e2c" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "5e0e9c00d51fcb7efef0d4c49023f9593b38661e" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, + "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, @@ -35,5 +35,6 @@ "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-tmux-navigator": { "branch": "master", "commit": "412c474e97468e7934b9c217064025ea7a69e05e" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/nvim/.config/nvim/lua/config/filetypes.lua b/nvim/.config/nvim/lua/config/filetypes.lua index 38ae06f..139bfb7 100644 --- a/nvim/.config/nvim/lua/config/filetypes.lua +++ b/nvim/.config/nvim/lua/config/filetypes.lua @@ -31,3 +31,11 @@ vim.api.nvim_create_autocmd('FileType', { vim.opt_local.shiftwidth = 2 end, }) + +vim.api.nvim_create_autocmd('FileType', { + pattern = 'go', + callback = function() + vim.opt_local.tabstop = 4 + vim.opt_local.shiftwidth = 4 + end, +}) diff --git a/nvim/.config/nvim/lua/config/global.lua b/nvim/.config/nvim/lua/config/global.lua index 8769e85..8581ae9 100644 --- a/nvim/.config/nvim/lua/config/global.lua +++ b/nvim/.config/nvim/lua/config/global.lua @@ -9,3 +9,8 @@ vim.g.have_nerd_font = true -- Disable netrw vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 + +-- Set Python 3 to a virtual environment with `pynvim` installed +-- to support python plugins. +vim.g.python3_host_prog = vim.fn.expand '~/.config/nvim/venv/bin/python' + diff --git a/nvim/.config/nvim/lua/plugins/blink.lua b/nvim/.config/nvim/lua/plugins/blink.lua index d83ee7f..e035292 100644 --- a/nvim/.config/nvim/lua/plugins/blink.lua +++ b/nvim/.config/nvim/lua/plugins/blink.lua @@ -1,8 +1,9 @@ return { { -- Autocompletion 'saghen/blink.cmp', + build = 'cargo +nightly build --release', event = 'VimEnter', - version = '1.*', + version = '*', dependencies = { -- Snippet Engine { @@ -31,6 +32,7 @@ return { opts = {}, }, 'folke/lazydev.nvim', + 'giuxtaposition/blink-cmp-copilot', }, --- @module 'blink.cmp' --- @type blink.cmp.Config @@ -76,9 +78,15 @@ return { }, sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, + default = { 'lsp', 'path', 'snippets', 'lazydev', 'copilot' }, providers = { lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + copilot = { + name = 'copilot', + module = 'blink-cmp-copilot', + score_offset = 100, + async = true, + }, }, }, diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index 54d14d2..627607f 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -1,3 +1,5 @@ +-- Conform adds code autoformatting funcionality. + return { { 'stevearc/conform.nvim', @@ -94,6 +96,8 @@ return { javascriptreact = { 'prettierd', 'prettier', stop_after_first = true }, typescriptreact = { 'prettierd', 'prettier', stop_after_first = true }, css = { 'prettierd', 'prettier', stop_after_first = true }, + htmldjango = { 'prettierd', 'prettier', stop_after_first = true }, + html = { 'prettierd', 'prettier', stop_after_first = true }, }, formatters = { isort = { @@ -104,5 +108,28 @@ return { }, }, }, + config = function(_, opts) + require('conform').setup(opts) + + vim.api.nvim_create_user_command('FormatDisable', function(args) + if args.bang then + -- :FormatDisable! disables autoformat for this buffer only + vim.b.disable_autoformat = true + else + -- :FormatDisable disables autoformat globally + vim.g.disable_autoformat = true + end + end, { + desc = 'Disable autoformat-on-save', + bang = true, -- allows the ! variant + }) + + vim.api.nvim_create_user_command('FormatEnable', function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false + end, { + desc = 'Re-enable autoformat-on-save', + }) + end, }, } diff --git a/nvim/.config/nvim/lua/plugins/copilot.lua b/nvim/.config/nvim/lua/plugins/copilot.lua new file mode 100644 index 0000000..4d16709 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/copilot.lua @@ -0,0 +1,27 @@ +return { + { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + event = 'InsertEnter', + config = function() + require('copilot').setup { + suggestion = { enabled = false }, + panel = { enabled = false }, + } + end, + }, + { + 'CopilotC-Nvim/CopilotChat.nvim', + dependencies = { + { 'zbirenbaum/copilot.lua' }, + { 'nvim-lua/plenary.nvim', branch = 'master' }, -- for curl, log and async functions + }, + build = 'make tiktoken', -- Only on MacOS or Linux + config = function() + require('CopilotChat').setup {} + vim.keymap.set('n', '<leader>cc', function() + vim.cmd 'CopilotChatToggle' + end, { desc = '[Copilot] Toggle Copilot Chat' }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/debug.lua b/nvim/.config/nvim/lua/plugins/debug.lua index fb59be1..668323e 100644 --- a/nvim/.config/nvim/lua/plugins/debug.lua +++ b/nvim/.config/nvim/lua/plugins/debug.lua @@ -1,139 +1,239 @@ -- debug.lua -- --- Shows how to use the DAP plugin to debug your code. +-- Configures the DAP plugin to debug code. -return { - 'mfussenegger/nvim-dap', - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', +---@class DapConfig +---@field name string Configuration name +---@field type string Debug adapter type +---@field request string Launch type ('launch' or 'attach') +---@field program function|string Path to executable or function returning path +---@field cwd string Working directory +---@field stopOnEntry boolean Whether to stop at entry point +---@field args table Command line arguments +---@field runInTerminal boolean Whether to run in terminal - -- Required dependency for nvim-dap-ui - 'nvim-neotest/nvim-nio', +---@class DapAdapter +---@field type string Adapter type ('server', 'executable', etc.) +---@field port string Port configuration +---@field executable table Executable configuration with command and args - -- Installs the debug adapters - 'williamboman/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', - - -- Debugger adapters - 'leoluz/nvim-dap-go', - 'mfussenegger/nvim-dap-python', - }, - keys = { - { - '<F5>', - function() - require('dap').continue() - end, - desc = 'Debug: Start/Continue', +-- Go debugging adapter setup +-- Configures delve debugger for Go with platform-specific settings +---@return nil +local function setup_go_adapter() + require('dap-go').setup { + delve = { + -- On Windows delve must be run attached or it crashes + detached = vim.fn.has 'win32' == 0, }, - { - '<F1>', - function() - require('dap').step_into() - end, - desc = 'Debug: Step Into', + } +end + +-- Python debugging adapter setup +-- Configures Python debugger using python3 interpreter +---@return nil +local function setup_python_adapter() + require('dap-python').setup 'python3' +end + +-- CodeLLDB adapter setup +-- Configures LLDB-based debugger for native languages (C, C++, Rust, Zig) +---@param dap table # DAP module instance +---@return nil +local function setup_codelldb_adapter(dap) + ---@type DapAdapter + dap.adapters.codelldb = { + type = 'server', + port = '${port}', + executable = { + command = vim.fn.exepath 'codelldb', + args = { '--port', '${port}' }, }, + } +end + +-- Build and find the newly-built Zig executable by running +-- 'zig build' and attempting to locate the resulting executable. +-- If the executable is unable to be automatically found, the user +-- will be prompted to give the path to the executable. +-- +---@return string|nil # Path to executable or nil if build the failed +local function build_and_find_zig_executable() + local build_result = vim.fn.system 'zig build' + if vim.v.shell_error ~= 0 then + vim.notify('Build failed: ' .. build_result, vim.log.levels.ERROR) + return nil + end + + local exe_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':t') + local possible_paths = { 'zig-out/bin/' .. exe_name } + + for _, path in ipairs(possible_paths) do + local full_path = vim.fn.getcwd() .. '/' .. path + if vim.fn.executable(full_path) == 1 then + return full_path + end + end + + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/zig-out/bin/', 'file') +end + +-- Build and find the Zig test executable by running +-- 'zig build test' and prompting the user for the test +-- executable location. +-- +---@return string # Path to test executable +local function build_and_find_zig_test() + vim.fn.system 'zig build test' + return vim.fn.input('Path to test executable: ', vim.fn.getcwd() .. '/zig-cache/o/', 'file') +end + +-- Zig debugging configuration +-- Sets up debugging configurations for Zig programs and tests +---@param dap table # DAP module instance +---@return nil +local function setup_zig_configuration(dap) + ---@type DapConfig[] + dap.configurations.zig = { { - '<F2>', - function() - require('dap').step_over() - end, - desc = 'Debug: Step Over', + name = 'Build and Launch Zig Program', + type = 'codelldb', + request = 'launch', + program = build_and_find_zig_executable, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + runInTerminal = false, }, { - '<F3>', - function() - require('dap').step_out() - end, - desc = 'Debug: Step Out', + name = 'Launch Zig Test', + type = 'codelldb', + request = 'launch', + program = build_and_find_zig_test, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + runInTerminal = false, }, - { - '<leader>b', + } +end + +-- Language adapters and configurations +-- Sets up debugging support for all supported languages +---@param dap table # DAP module instance +---@return nil +local function setup_language_adapters(dap) + setup_go_adapter() + setup_python_adapter() + setup_codelldb_adapter(dap) + setup_zig_configuration(dap) +end + +-- Key mappings setup +-- Configures function keys and leader key combinations for debugging actions +---@param dap table # DAP module instance +---@param dapui table # DAP UI module instance +---@return nil +local function setup_keymaps(dap, dapui) + ---@type table<string, {[1]: function, [2]: string}> + local keymaps = { + ['<F5>'] = { dap.continue, 'Debug: Start/Continue' }, + ['<F1>'] = { dap.step_into, 'Debug: Step Into' }, + ['<F2>'] = { dap.step_over, 'Debug: Step Over' }, + ['<F3>'] = { dap.step_out, 'Debug: Step Out' }, + ['<F7>'] = { dapui.toggle, 'Debug: See last session result' }, + ['<leader>tb'] = { dap.toggle_breakpoint, 'Debug: Toggle Breakpoint' }, + ['<leader>B'] = { function() - require('dap').toggle_breakpoint() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, - desc = 'Debug: Toggle Breakpoint', + 'Debug: Set Breakpoint', }, - { - '<leader>B', - function() - require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, - desc = 'Debug: Set Breakpoint', + } + + for key, config in pairs(keymaps) do + vim.keymap.set('n', key, config[1], { desc = config[2] }) + end +end + +-- Event listeners setup +-- Configures automatic UI opening/closing based on debug session events +---@param dap table # DAP module instance +---@param dapui table # DAP UI module instance +---@return nil +local function setup_dap_listeners(dap, dapui) + local dapui_config = 'dapui_config' + dap.listeners.after.event_initialized[dapui_config] = dapui.open + dap.listeners.before.event_terminated[dapui_config] = dapui.close + dap.listeners.before.event_exited[dapui_config] = dapui.close +end + +-- DAP UI configuration +-- Sets up the debugging user interface with custom icons and controls +---@param dapui table # DAP UI module instance +---@return nil +local function setup_dapui_config(dapui) + dapui.setup { + icons = { + expanded = '▾', + collapsed = '▸', + current_frame = '*', }, - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - { - '<F7>', - function() - require('dapui').toggle() - end, - desc = 'Debug: See last session result.', + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, }, - }, - config = function() - local dap = require 'dap' - local dapui = require 'dapui' + } +end - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_installation = true, +-- Mason DAP configuration +-- Automatically installs and configures debug adapters through Mason +---@return nil +local function setup_mason_dap() + require('mason-nvim-dap').setup { + automatic_installation = true, + handlers = {}, + ensure_installed = { 'delve', 'python', 'codelldb' }, + } +end - -- see mason-nvim-dap README for more information - handlers = {}, +-- Main configuration orchestrator +-- Sets up all debugging components in the correct order +---@return nil +local function setup_dap() + local dap = require 'dap' + local dapui = require 'dapui' - ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', - 'python', - }, - } - - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| - dapui.setup { - icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, - controls = { - icons = { - pause = '⏸', - play = '▶', - step_into = '⏎', - step_over = '⏭', - step_out = '⏮', - step_back = 'b', - run_last = '▶▶', - terminate = '⏹', - disconnect = '⏏', - }, - }, - } - - -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } - -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) - -- end - - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, - }, - } + setup_mason_dap() + setup_dapui_config(dapui) + setup_dap_listeners(dap, dapui) + setup_language_adapters(dap) + setup_keymaps(dap, dapui) +end - require('dap-python').setup 'python3' +-- Plugin specification +-- Configures nvim-dap with all necessary dependencies for debugging +---@return table # Plugin specification for lazy.nvim +return { + 'mfussenegger/nvim-dap', + dependencies = { + 'rcarriga/nvim-dap-ui', -- Beautiful debugger UI + 'nvim-neotest/nvim-nio', -- Required dependency for nvim-dap-ui + 'williamboman/mason.nvim', -- Package manager for debug adapters + 'jay-babu/mason-nvim-dap.nvim', -- Mason integration for DAP + 'leoluz/nvim-dap-go', -- Go debugging support + 'mfussenegger/nvim-dap-python', -- Python debugging support + }, + config = function() + setup_dap() end, } diff --git a/nvim/.config/nvim/lua/plugins/lint.lua b/nvim/.config/nvim/lua/plugins/lint.lua index 1361816..66923a7 100644 --- a/nvim/.config/nvim/lua/plugins/lint.lua +++ b/nvim/.config/nvim/lua/plugins/lint.lua @@ -11,6 +11,7 @@ return { lint.linters_by_ft['terraform'] = { 'tflint' } lint.linters_by_ft['python'] = { 'ruff', 'bandit' } lint.linters_by_ft['markdown'] = nil + lint.linters_by_ft['text'] = nil lint.linters_by_ft['sh'] = { 'shellcheck' } -- Default linters, which will cause errors unless these tools are available: diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua index ced27a2..c184284 100644 --- a/nvim/.config/nvim/lua/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -37,8 +37,8 @@ return { vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), callback = function(event) - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. + -- Utility to more easily define mappings specific for LSP related items. + -- It sets the mode, buffer and description for us each time. local map = function(keys, func, desc, mode) mode = mode or 'n' vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) @@ -87,10 +87,7 @@ return { -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) - if - client - and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) - then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, @@ -196,6 +193,8 @@ return { }, }, stylua = {} + tailwindcss = {}, + mesonlsp = {}, } -- Ensure the servers and tools above are installed diff --git a/nvim/.config/nvim/lua/plugins/neo-tree.lua b/nvim/.config/nvim/lua/plugins/neo-tree.lua index 556111b..fa2b5db 100644 --- a/nvim/.config/nvim/lua/plugins/neo-tree.lua +++ b/nvim/.config/nvim/lua/plugins/neo-tree.lua @@ -22,5 +22,19 @@ return { }, }, }, + filtered_items = { + visible = true, + hide_dotfiles = false, + hide_gitignored = true, + hide_by_name = { + '.DS_Store', + 'thumbs.db', + '.git', + }, + always_show_by_pattern = { + '.env*', + '.gitignore', + }, + }, }, } diff --git a/nvim/.config/nvim/lua/plugins/obsidian.lua b/nvim/.config/nvim/lua/plugins/obsidian.lua new file mode 100644 index 0000000..a29e9f8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/obsidian.lua @@ -0,0 +1,20 @@ +return { + 'epwalsh/obsidian.nvim', + version = '*', + lazy = true, + event = { + 'BufReadPre ' .. vim.fn.expand '~' .. '/Documents/Notes/*.md', + 'BufNewFile ' .. vim.fn.expand '~' .. '/Documents/Notes/*.md', + }, + dependencies = { + 'nvim-lua/plenary.nvim', + }, + opts = { + workspaces = { + { + name = 'personal', + path = '~/Documents/Notes', + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua index 5157aea..9e3c703 100644 --- a/nvim/.config/nvim/lua/plugins/telescope.lua +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -39,15 +39,25 @@ return { -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { ['<c-enter>'] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} + defaults = { + vimgrep_arguments = { + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--hidden', + '--glob', + '!.git/*', + }, + }, + pickers = { + find_files = { + find_command = { 'fd', '--type', 'f', '--hidden', '--strip-cwd-prefix', '--exclude', '.git' }, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), diff --git a/nvim/.config/nvim/lua/plugins/tmux-navigator.lua b/nvim/.config/nvim/lua/plugins/tmux-navigator.lua new file mode 100644 index 0000000..a161285 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/tmux-navigator.lua @@ -0,0 +1,20 @@ +--- Vim Tmux Navigator is a plugin that allows you to navigate between Vim and Tmux panes seamlessly. + +return { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + 'TmuxNavigatorProcessList', + }, + keys = { + { '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' }, + { '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' }, + { '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' }, + { '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' }, + { '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/vim-sleuth.lua b/nvim/.config/nvim/lua/plugins/vim-sleuth.lua index 93904da..d9a0887 100644 --- a/nvim/.config/nvim/lua/plugins/vim-sleuth.lua +++ b/nvim/.config/nvim/lua/plugins/vim-sleuth.lua @@ -1,5 +1,4 @@ -- Detect tabstop and shiftwidth automatically - return { 'tpope/vim-sleuth', } diff --git a/tmux/.config/tmux/options.conf b/tmux/.config/tmux/options.conf index a06803b..ac1cb84 100644 --- a/tmux/.config/tmux/options.conf +++ b/tmux/.config/tmux/options.conf @@ -9,7 +9,7 @@ set-option -g allow-rename off set-option -g mouse on # Set terminal colors -# set-option -g default-terminal "screen-256color" +set-option -g default-terminal "screen-256color" # Start windows and panes at 1, not 0 set-option -g base-index 1 @@ -24,3 +24,5 @@ set-option -g visual-silence off set-window-option -g monitor-activity off set-option -g bell-action none +# Enable hyperlinks +set-option -as terminal-features ",*:hyperlinks" diff --git a/tmux/.config/tmux/plugins.conf b/tmux/.config/tmux/plugins.conf index ee2de5e..58ca774 100644 --- a/tmux/.config/tmux/plugins.conf +++ b/tmux/.config/tmux/plugins.conf @@ -4,22 +4,24 @@ set-option -g @plugin 'tmux-plugins/tpm' # 'Sensible' set of defaults set-option -g @plugin 'tmux-plugins/tmux-sensible' +# Tmux FZF is a plugin that integrates FZF with tmux TMUX_FZF_ORDER="session|window|pane|command|keybinding" TMUX_FZF_OPTIONS="-p -w 90% -h 70% -m" set-option -g @plugin 'sainnhe/tmux-fzf' -# Persist tmux sessions across system restarts +# Resurrect is a plugin that saves and restores tmux sessions set-option -g @plugin 'tmux-plugins/tmux-resurrect' -set-option -g @plugin 'tmux-plugins/tmux-continuum' -set -g @resurrect-strategy-nvim 'session' - -# set -g @plugin 'christoomey/vim-tmux-navigator' +set-option -g @resurrect-save 'S' +set-option -g @resurrect-restore 'R' -# Save and restore session -# set -g @resurrect-save 'S' -# set -g @resurrect-restore 'R' +# Continuum is a plugin that automatically saves tmux sessions +# at regular intervals +set-option -g @plugin 'tmux-plugins/tmux-continuum' +set-option -g @continuum-restore 'on' +set-option -g @continuum-save-interval '15' +set-option -g @resurrect-strategy-nvim 'session' -# # more options here: https://github.com/sainnhe/tmux-fzf/issues/6#issuecomment-578750879 -# bind w run-shell -b "~/.config/tmux/plugins/tmux-fzf/scripts/window.sh switch" +# Vim Tmux Navigator allows you to navigate between Vim and tmux panes +set-option -g @plugin 'christoomey/vim-tmux-navigator' run '~/.tmux/plugins/tpm/tpm' diff --git a/zsh/.zsh/prompt.sh b/zsh/.zsh/prompt.sh new file mode 100644 index 0000000..ef015fd --- /dev/null +++ b/zsh/.zsh/prompt.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +autoload -Uz vcs_info +zstyle ":vcs_info:*" enable git svn +zstyle ':vcs_info:git:*' formats '%F{green}(%b)%f ' +precmd() { + vcs_info +} +setopt prompt_subst +NEWLINE=$'\n' +PROMPT=' %2~ ${vcs_info_msg_0_}%# ' @@ -1,19 +1,18 @@ -autoload -Uz vcs_info -zstyle ":vcs_info:*" enable git svn -zstyle ':vcs_info:git:*' formats '%F{green}(%b)%f ' -precmd() { - vcs_info -} -setopt prompt_subst -NEWLINE=$'\n' -PROMPT=' %2~ ${vcs_info_msg_0_}%# ' +#!/usr/bin/env zsh + +source ~/.zsh/prompt.sh + +autoload -Uz compinit +compinit export HISTFILE=~/.zhistory export HISTSIZE=100000 export SAVEHIST=100000 export EDITOR="nvim" -export BROWSER= +export BROWSER="vivaldi" +export BAT_THEME="tokyonight_night" +export MANPAGER="less" export PAGER="less" export TERM="xterm-256color" @@ -32,6 +31,8 @@ export GOPATH="$SRC_DIR/go" export GOBIN="$SRC_DIR/go/bin" export PATH="$GOBIN:$PATH" +source "$HOME/.cargo/env" + export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" @@ -43,8 +44,8 @@ export NVM_DIR="$HOME/.nvm" export PNPM_HOME="/Users/eugene/Library/pnpm" case ":$PATH:" in - *":$PNPM_HOME:"*) ;; - *) export PATH="$PNPM_HOME:$PATH" ;; +*":$PNPM_HOME:"*) ;; +*) export PATH="$PNPM_HOME:$PATH" ;; esac eval "$(brew shellenv)" @@ -72,7 +73,5 @@ alias j="jobs -l" alias l="ls -alG" alias tf="terraform" -alias lg="lazygit" alias vi="nvim" alias vim="nvim" - |