├── .config ├── nvim │ ├── .gitignore │ ├── lsp-settings │ │ ├── jsonls.json │ │ └── bashls.json │ ├── lua │ │ ├── user │ │ │ ├── lsp │ │ │ │ ├── providers │ │ │ │ │ ├── bashls.lua │ │ │ │ │ ├── jsonls.lua │ │ │ │ │ ├── pyright.lua │ │ │ │ │ ├── pylsp.lua │ │ │ │ │ ├── cmake.lua │ │ │ │ │ ├── yamlls.lua │ │ │ │ │ ├── clangd.lua │ │ │ │ │ └── lua_ls.lua │ │ │ │ ├── ws.lua │ │ │ │ ├── utils.lua │ │ │ │ ├── handlers.lua │ │ │ │ ├── manager.lua │ │ │ │ ├── init.lua │ │ │ │ └── null-ls.lua │ │ │ ├── commands.lua │ │ │ ├── settings.lua │ │ │ ├── utils.lua │ │ │ └── autocmds.lua │ │ └── core │ │ │ ├── quickfix.lua │ │ │ ├── project.lua │ │ │ ├── zk.lua │ │ │ ├── indent.lua │ │ │ ├── lightspeed.lua │ │ │ ├── neogen.lua │ │ │ ├── mason.lua │ │ │ ├── sniprun.lua │ │ │ ├── dashboard.lua │ │ │ ├── telescope │ │ │ └── custom-actions.lua │ │ │ ├── comment.lua │ │ │ ├── tmux.lua │ │ │ ├── treesitter.lua │ │ │ ├── terminal.lua │ │ │ ├── sessions.lua │ │ │ ├── telescope.lua │ │ │ ├── statusline.lua │ │ │ ├── bufferline.lua │ │ │ ├── cmp.lua │ │ │ ├── nvimtree.lua │ │ │ └── git.lua │ ├── .stylua.toml │ ├── init.lua │ ├── .luacheckrc │ ├── scripts │ │ └── minimal_init.lua │ └── lazy-lock.json ├── zsh │ ├── .gitignore │ ├── completions.zsh │ ├── modules │ │ └── kp │ ├── .zlogin │ ├── aliases.zsh │ ├── utils │ │ └── ssh-agent.zsh │ ├── keymaps.zsh │ ├── plugins.zsh │ ├── .zshrc │ ├── functions.zsh │ └── .zshenv ├── lazygit │ └── .gitignore ├── ranger │ └── rc.conf ├── fd │ └── ignore ├── hypr │ ├── scripts │ │ ├── clip.sh │ │ ├── autostart.sh │ │ ├── switch-kb.sh │ │ ├── import-gsettings.sh │ │ └── fix-portals.sh │ └── hyprland.conf ├── lf │ ├── batlf.sh │ ├── image │ ├── lf │ ├── draw_img │ ├── lf.zsh │ ├── preview │ └── lfrc ├── readline │ └── inputrc ├── npm │ └── npmrc ├── tmuxp │ ├── default.yaml │ ├── project.yaml │ └── wm.yaml ├── glow │ └── glow.yml ├── bat │ └── config ├── tmux │ ├── scripts │ │ ├── nvrm.tmux │ │ ├── zlf │ │ └── theme.tmux │ └── bin │ │ ├── lnav-tmux │ │ ├── fman-tmux │ │ └── dwm-tmux ├── lazydocker │ └── config.yml ├── vcpkg │ └── hook.sh ├── bash │ ├── aliases.bash │ └── exports.bash ├── ripgrep │ └── ripgreprc ├── luacheck │ └── .luacheckrc ├── gitui │ ├── dracula.ron │ ├── theme.ron │ └── key_bindings.ron ├── alacritty │ ├── colors │ │ ├── pastel.toml │ │ ├── pastel.yaml │ │ └── onedark.yaml │ └── alacritty.toml ├── emacs │ └── init.el ├── gh │ └── config.yml ├── pacman │ └── makepkg.conf ├── git │ ├── hooks │ │ └── dots-pre-push │ └── config ├── zk │ └── config.toml ├── vivid │ └── themes │ │ └── one-dark.yml ├── waybar │ └── style.css └── fzf │ └── helper │ └── previewer.sh ├── .zshenv ├── .pre-commit-config.yaml ├── .bashrc ├── .local └── share │ └── cargo │ └── config.toml ├── docs └── README.md ├── .gitignore ├── bootstrap.sh └── .vimrc /.config/nvim/.gitignore: -------------------------------------------------------------------------------- 1 | plugin/* 2 | -------------------------------------------------------------------------------- /.config/zsh/.gitignore: -------------------------------------------------------------------------------- 1 | *.zwc 2 | *.zcomp 3 | -------------------------------------------------------------------------------- /.config/lazygit/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !/config.yml 3 | -------------------------------------------------------------------------------- /.config/ranger/rc.conf: -------------------------------------------------------------------------------- 1 | map DT shell gio trash %s 2 | -------------------------------------------------------------------------------- /.config/fd/ignore: -------------------------------------------------------------------------------- 1 | .git/* 2 | *.git/* 3 | .node-modules/* 4 | -------------------------------------------------------------------------------- /.config/nvim/lsp-settings/jsonls.json: -------------------------------------------------------------------------------- 1 | { 2 | "json.validate.enable": true 3 | } 4 | -------------------------------------------------------------------------------- /.config/hypr/scripts/clip.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | grim -g "$(slurp)" - | swappy -f - 4 | -------------------------------------------------------------------------------- /.config/lf/batlf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | unset COLORTERM 3 | bat --color=always --style=plain --wrap auto "$1" 4 | -------------------------------------------------------------------------------- /.config/nvim/lsp-settings/bashls.json: -------------------------------------------------------------------------------- 1 | { 2 | "bashIde.shellcheckArguments": "--exclude=SC1091" 3 | } 4 | -------------------------------------------------------------------------------- /.config/readline/inputrc: -------------------------------------------------------------------------------- 1 | ## arrow up 2 | "\e[A":history-search-backward 3 | ## arrow down 4 | "\e[B":history-search-forward 5 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/bashls.lua: -------------------------------------------------------------------------------- 1 | -- npm i -g bash-language-server 2 | 3 | return { 4 | filetypes = { "sh", "bash", "zsh" }, 5 | } 6 | -------------------------------------------------------------------------------- /.zshenv: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | export XDG_CONFIG_HOME="$HOME/.config" 4 | export ZDOTDIR="$HOME/.config/zsh" 5 | 6 | source "$HOME/.config/zsh/.zshenv" 7 | 8 | -------------------------------------------------------------------------------- /.config/hypr/scripts/autostart.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # systemctl --user restart xsettingsd waybar swaybg swayidle 4 | 5 | systemctl --user start autostart.target 6 | -------------------------------------------------------------------------------- /.config/nvim/.stylua.toml: -------------------------------------------------------------------------------- 1 | column_width = 100 2 | line_endings = "Unix" 3 | indent_type = "Spaces" 4 | indent_width = 2 5 | quote_style = "AutoPreferDouble" 6 | call_parentheses = "None" 7 | -------------------------------------------------------------------------------- /.config/npm/npmrc: -------------------------------------------------------------------------------- 1 | prefix=${XDG_DATA_HOME}/npm 2 | cache=${XDG_CACHE_HOME}/npm 3 | init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js 4 | store-sir=${XDG_DATA_HOME}/pnpm-store 5 | tmp=${XDG_RUNTIME_DIR}/npm 6 | -------------------------------------------------------------------------------- /.config/tmuxp/default.yaml: -------------------------------------------------------------------------------- 1 | session_name: default 2 | windows: 3 | - layout: tiled 4 | panes: 5 | - focus: true 6 | - git dots status 7 | - panes: 8 | - nvim +'Telescope zoxide list' 9 | start_directory: ${XDG_DATA_HOME} 10 | -------------------------------------------------------------------------------- /.config/tmuxp/project.yaml: -------------------------------------------------------------------------------- 1 | session_name: project 2 | start_directory: "${XDG_DATA_HOME}" 3 | windows: 4 | - window_name: editor 5 | panes: 6 | - nvim +'Telescope zoxide list' 7 | - window_name: neovim 8 | start_directory: ${XDG_DATA_HOME}/neovim 9 | -------------------------------------------------------------------------------- /.config/nvim/init.lua: -------------------------------------------------------------------------------- 1 | require "user.utils" 2 | require "user.plugins".load() 3 | require "user.settings" 4 | require("user.autocmds").setup() 5 | require("user.commands").setup() 6 | require("user.keymaps").setup() 7 | require "core.treesitter" 8 | 9 | pcall(require, "scratch") 10 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: local 3 | hooks: 4 | - id: stylua 5 | name: StyLua 6 | language: rust 7 | entry: stylua 8 | types: [lua] 9 | files: '\*.lua' 10 | args: ["--config-path", ".config/nvim/.stylua.toml", "-c"] 11 | -------------------------------------------------------------------------------- /.config/glow/glow.yml: -------------------------------------------------------------------------------- 1 | # style name or JSON path (default "auto") 2 | style: "auto" 3 | # show local files only; no network (TUI-mode only) 4 | local: false 5 | # mouse support (TUI-mode only) 6 | mouse: false 7 | # use pager to display markdown 8 | pager: true 9 | # word-wrap at width 10 | width: 100 11 | -------------------------------------------------------------------------------- /.config/hypr/scripts/switch-kb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | layout1="se" 5 | layout2="us" 6 | 7 | if hyprctl getoption input:kb_layout -j | jq -r '.str' | grep "$layout1"; then 8 | hyprctl keyword input:kb_layout "$layout2" 9 | else 10 | hyprctl keyword input:kb_layout "$layout1" 11 | fi 12 | -------------------------------------------------------------------------------- /.config/bat/config: -------------------------------------------------------------------------------- 1 | # Set the theme to "Coldark-Dark" 2 | --theme="Coldark-Dark" 3 | 4 | # Show line numbers, Git modifications and file header (but no grid) 5 | --style="numbers,changes" 6 | 7 | # Use italic text on the terminal (not supported on all terminals) 8 | --italic-text=always 9 | 10 | # Use C++ syntax for .ino files 11 | --map-syntax "*.ino:C++" 12 | -------------------------------------------------------------------------------- /.config/tmux/scripts/nvrm.tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | WINDOW_PANES="$(tmux display -p "#{window_panes}")" 5 | BASE_IDX=${BASE_IDX:-"$(tmux display -p "#{pane-base-index}")"} 6 | IS_VIM="tmux display -p '#{pane_current_command}' | rg 'nvim'" 7 | TARGET_FILE="${DOTBARE_TREE}/$1" 8 | 9 | 10 | function nvrm(){ 11 | nvim-ctrl ":edit $TARGET_FILE" || nvim "$TARGET_FILE" 12 | } 13 | 14 | nvrm "$1" 15 | -------------------------------------------------------------------------------- /.config/lazydocker/config.yml: -------------------------------------------------------------------------------- 1 | gui: 2 | scrollHeight: 2 3 | theme: 4 | activeBorderColor: 5 | - green 6 | - bold 7 | inactiveBorderColor: 8 | - gray 9 | optionsTextColor: 10 | - cyan 11 | returnImmediately: false 12 | wrapMainPanel: false 13 | reporting: "off" 14 | oS: 15 | openCommand: bash -c "nvim {{filename}} >/dev/null" 16 | openLinkCommand: bash -c "nvim {{link}} >/dev/null" 17 | -------------------------------------------------------------------------------- /.config/zsh/completions.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | # https://git-annex.branchable.com/bugs/zsh_completions_installed_to_location_not_in_fpath/ 4 | extra_paths=( 5 | /usr/share/zsh/vendor-completions 6 | /usr/share/zsh/site-functions 7 | /opt/homebrew/share/zsh/site-functions 8 | "$ZDOTDIR/modules" 9 | ) 10 | 11 | for extra in "${extra_paths[@]}"; do 12 | [ -d "$extra" ] && fpath+=($extra) 13 | done 14 | 15 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/quickfix.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | vim.cmd [[ 4 | function! QuickFixToggle() 5 | if empty(filter(getwininfo(), 'v:val.quickfix')) 6 | copen 7 | else 8 | cclose 9 | endif 10 | endfunction 11 | ]] 12 | 13 | function M.setup() 14 | require("bqf").setup { 15 | auto_enable = true, 16 | preview = { 17 | auto_preview = false, 18 | }, 19 | } 20 | end 21 | 22 | return M 23 | -------------------------------------------------------------------------------- /.config/vcpkg/hook.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function __setup_vcpkg() { 4 | while IFS=$'-' read -r arch _ os _; do 5 | arch=${arch//x86_64/x64} 6 | os=${os//darwin*/osx} 7 | export VCPKG_DEFAULT_TRIPLET="${arch}-${os}" 8 | done < <(clang -print-target-triple 2>/dev/null) 9 | export VCPKG_ROOT="$XDG_DATA_HOME/vcpkg" 10 | # shellcheck disable=1091 11 | source "$VCPKG_ROOT/scripts/vcpkg_completion.zsh" 2>/dev/null 12 | } 13 | 14 | __setup_vcpkg 15 | -------------------------------------------------------------------------------- /.config/bash/aliases.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | alias v='nvim' 4 | 5 | alias ls='ls -v --color=auto --group-directories-first' 6 | alias l='ls -ACFN' 7 | alias ll='ls -hlqAFN' 8 | 9 | alias cls='clear' 10 | alias rmd='rm -rd' 11 | alias paux='ps aux | grep' 12 | 13 | # insert relevant xkcd 14 | alias archive='tar --create --gzip --verbose --file' 15 | 16 | alias where='type -a' 17 | 18 | # workaround for interactive 'rm' 19 | alias rm &>/dev/null && unalias rm 20 | -------------------------------------------------------------------------------- /.config/tmuxp/wm.yaml: -------------------------------------------------------------------------------- 1 | session_name: wm 2 | windows: 3 | - window_name: hyprland 4 | start_directory: "${XDG_CONFIG_HOME}" 5 | panes: 6 | - nvim hypr/hyprland.conf waybar/{config,style.css} 7 | - nvim ~/.local/share/hyprland-git/wiki/pages/Home.md 8 | - window_name: rofi 9 | start_directory: "${XDG_CONFIG_HOME}/rofi" 10 | panes: 11 | - nvim config.rasi 12 | - window_name: awesome 13 | start_directory: "${XDG_CONFIG_HOME}/awesome" 14 | panes: 15 | - nvim rc.lua keys.lua apps.lua 16 | -------------------------------------------------------------------------------- /.config/lf/image: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | readonly ID_PREVIEW="preview" 3 | main() { 4 | case "$1" in 5 | "clear") 6 | declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \ 7 | >"$FIFO_UEBERZUG" 8 | ;; 9 | "draw") 10 | declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" 11 | [x]="$3" [y]="$4" [max_width]="$5" [max_height]="$6" 12 | [path]="$2") >"$FIFO_UEBERZUG" 13 | ;; 14 | "*") echo "Unknown command: '$1', '$2'" ;; 15 | esac 16 | } 17 | main "$@" 18 | -------------------------------------------------------------------------------- /.config/lf/lf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # credit: github.com/slavistan/lf-gadgets 3 | 4 | function __lf_cleanup() { 5 | rm -rf "$LF_SCROLLINGPREVIEW_TEMPDIR" 6 | } 7 | 8 | trap __lf_cleanup INT HUP TERM 9 | 10 | # Set up temporary directory. 11 | LF_SCROLLINGPREVIEW_TEMPDIR="$(mktemp -d -t lf-scrollingpreview-XXXXXX)" 12 | export LF_SCROLLINGPREVIEW_TEMPDIR 13 | 14 | # Initialize scrolling offset (page number or line offset) and the file name 15 | echo "1" >"$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 16 | 17 | lf "$@" 18 | 19 | __lf_cleanup 20 | -------------------------------------------------------------------------------- /.config/ripgrep/ripgreprc: -------------------------------------------------------------------------------- 1 | # Don't let ripgrep vomit really long lines to my terminal, and show a preview. 2 | --max-columns=150 3 | --max-columns-preview 4 | 5 | # Always show hidden files 6 | --hidden 7 | 8 | # Add my 'zshrc' type 9 | --type-add=zshrc:*.zsh* 10 | --type-add=bashrc:*.sh* 11 | --type-add=automake:*makefile.in* 12 | 13 | # Using glob patterns to include/exclude files or folders 14 | --glob=!.git/ 15 | 16 | # Set the colors. 17 | # --colors=line:none 18 | # --colors=line:style:bold 19 | 20 | # Because who cares about case!? 21 | --ignore-case 22 | -------------------------------------------------------------------------------- /.config/zsh/modules/kp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | ### PROCESS 4 | # mnemonic: [K]ill [P]rocess 5 | # show output of "ps -ef", use [tab] to select one or multiple entries 6 | # press [enter] to kill selected processes and go back to the process list. 7 | # or press [escape] to go back to the process list. Press [escape] twice to exit completely. 8 | 9 | local pid=$(ps -ef | sed 1d | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[kill:process]'" | awk '{print $2}') 10 | 11 | if [ "x$pid" != "x" ] 12 | then 13 | echo $pid | xargs kill -${1:-9} 14 | kp 15 | fi 16 | 17 | -------------------------------------------------------------------------------- /.bashrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=1090,1091 3 | 4 | export XDG_CONFIG_HOME="$HOME/.config" 5 | 6 | source "$XDG_CONFIG_HOME/bash/exports.bash" 7 | 8 | source "$XDG_CONFIG_HOME/bash/aliases.bash" 9 | 10 | shopt -s histappend 11 | shopt -s checkwinsize 12 | 13 | if shopt -oq posix; then 14 | return 15 | fi 16 | 17 | extras=( 18 | /usr/share/bash-completion/bash_completion 19 | /etc/bash_completion 20 | "$XDG_CONFIG_HOME/fzf/fzf.bash" 21 | ) 22 | 23 | for f in "${extras[@]}"; do 24 | test -f "$f" && source "$f" 25 | done 26 | 27 | eval "$(starship init bash)" 28 | -------------------------------------------------------------------------------- /.local/share/cargo/config.toml: -------------------------------------------------------------------------------- 1 | # generate completion 2 | # rustup completions zsh cargo > ~/.local/share/zsh/site-functions/_cargo 3 | # rustup completions zsh rustup > ~/.local/share/zsh/site-functions/_rustup 4 | 5 | 6 | [alias] # command aliases 7 | ls = "install --list" 8 | i = "install" 9 | ia = "install-update" 10 | 11 | [target.x86_64-unknown-linux-gnu] 12 | rustflags = [ "-C", "linker=clang"] 13 | 14 | [term] 15 | color = 'auto' # whether cargo colorizes output 16 | progress.when = 'auto' # whether cargo shows progress bar 17 | progress.width = 80 # width of progress bar 18 | 19 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/jsonls.lua: -------------------------------------------------------------------------------- 1 | local schemas = require("schemastore").json.schemas() 2 | table.insert(schemas, { 3 | fileMatch = { 4 | "vcpkg.json", 5 | }, 6 | url = "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 7 | }) 8 | local opts = { 9 | settings = { 10 | json = { 11 | schemas = schemas, 12 | }, 13 | }, 14 | setup = { 15 | commands = { 16 | Format = { 17 | function() 18 | vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) 19 | end, 20 | }, 21 | }, 22 | }, 23 | } 24 | 25 | return opts 26 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/pyright.lua: -------------------------------------------------------------------------------- 1 | local before_init = function(_, config) 2 | if vim.env.VIRTUAL_ENV then 3 | local python_bin = require("lspconfig.util").path.join(vim.env.VIRTUAL_ENV, "bin", "python3") 4 | config.settings.python.pythonPath = python_bin 5 | end 6 | end 7 | 8 | local root_files = { 9 | "pyproject.toml", 10 | "pyrightconfig.json", 11 | ".git", 12 | } 13 | 14 | local util = require "lspconfig.util" 15 | return { 16 | -- autostart = false, 17 | root_dir = util.root_pattern(unpack(root_files)), 18 | before_init = before_init, 19 | settings = { 20 | pyright = {}, 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /.config/nvim/.luacheckrc: -------------------------------------------------------------------------------- 1 | ---@diagnostic disable 2 | -- vim: ft=lua tw=80 3 | 4 | stds.nvim = { 5 | globals = { 6 | "vim", 7 | }, 8 | read_globals = { 9 | "jit", 10 | "os", 11 | "join_paths", 12 | "reload", 13 | "log_entry", 14 | "dump", 15 | "P", 16 | }, 17 | } 18 | std = "lua51+nvim" 19 | 20 | files["tests/*_spec.lua"].std = "lua51+nvim+busted" 21 | files["lua/scratch*.lua"].ignore = { "212", "211" } 22 | 23 | -- Don't report unused self arguments of methods. 24 | self = false 25 | 26 | -- Rerun tests only if their modification time changed. 27 | cache = true 28 | 29 | ignore = { 30 | "631", -- max_line_length 31 | "212/_.*", -- unused argument, for vars with "_" prefix 32 | } 33 | -------------------------------------------------------------------------------- /.config/luacheck/.luacheckrc: -------------------------------------------------------------------------------- 1 | ---@diagnostic disable: lowercase-global, undefined-global 2 | 3 | stds.nvim = { 4 | read_globals = { "jit" } 5 | } 6 | 7 | std = "lua51+nvim" 8 | 9 | -- Don't report unused self arguments of methods. 10 | self = false 11 | 12 | -- Rerun tests only if their modification time changed. 13 | cache = true 14 | 15 | ignore = { 16 | "631", -- max_line_length 17 | "212/_.*", -- unused argument, for vars with "_" prefix 18 | } 19 | 20 | -- The unit tests can use busted 21 | files["spec"].std = "+busted" 22 | files["*_spec"].std = "+busted" 23 | 24 | -- Global objects defined by the C code 25 | globals = { 26 | "vim", 27 | } 28 | 29 | -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 30 | -------------------------------------------------------------------------------- /.config/gitui/dracula.ron: -------------------------------------------------------------------------------- 1 | ( 2 | selected_tab: Rgb(255, 255, 0), 3 | command_fg: Rgb(248, 248, 242), 4 | selection_bg: Rgb(98, 114, 164), 5 | cmdbar_extra_lines_bg: Rgb(40, 42, 54), 6 | disabled_fg: Rgb(98, 114, 164), 7 | diff_line_add: Rgb(80, 250, 123), 8 | diff_line_delete: Rgb(255, 85, 85), 9 | diff_file_added: Rgb(105, 255, 148), 10 | diff_file_removed: Rgb(255, 110, 110), 11 | diff_file_moved: Rgb(255, 146, 223), 12 | diff_file_modified: Rgb(241, 250, 140), 13 | commit_hash: Rgb(189, 147, 249), 14 | commit_time: Rgb(164, 255, 255), 15 | commit_author: Rgb(80, 250, 123), 16 | danger_fg: Rgb(255, 85, 85), 17 | push_gauge_bg: Rgb(40, 42, 54), 18 | push_gauge_fg: Rgb(248, 248, 242), 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/project.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | local opts = { 5 | manual_mode = false, 6 | 7 | detection_methods = { "lsp", "pattern" }, 8 | 9 | patterns = { ".git", ".luarc.json" }, 10 | 11 | show_hidden = true, 12 | 13 | silent_chdir = true, 14 | 15 | ignore_lsp = { "null-ls", "lua_ls" }, 16 | 17 | datapath = vim.fn.stdpath "cache", 18 | 19 | -- What scope to change the directory, valid options are 20 | -- * global (default) 21 | -- * tab 22 | -- * win 23 | scope_chdir = "global", 24 | 25 | -- Don't calculate root dir on specific directories 26 | -- Ex: { "~/.cargo/*", ... } 27 | exclude_dirs = {}, 28 | } 29 | 30 | require("project_nvim").setup(opts) 31 | end 32 | 33 | return M 34 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/zk.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.config() 4 | return { 5 | picker = "telescope", 6 | lsp = { 7 | -- `config` is passed to `vim.lsp.start_client(config)` 8 | config = { 9 | cmd = { "zk", "lsp" }, 10 | name = "zk", 11 | on_attach = function() 12 | require("user.lsp").common_on_attach() 13 | vim.cmd [[ setl foldmethod=indent foldlevel=0 ]] 14 | end, 15 | }, 16 | -- automatically attach buffers in a zk notebook that match the given filetypes 17 | auto_attach = { 18 | enabled = true, 19 | filetypes = { "markdown" }, 20 | }, 21 | }, 22 | } 23 | end 24 | 25 | function M.setup() 26 | local opts = M.config() 27 | require("zk").setup(opts) 28 | end 29 | 30 | return M 31 | -------------------------------------------------------------------------------- /.config/hypr/scripts/import-gsettings.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | # usage: import-gsettings 5 | config="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini" 6 | if [ ! -f "$config" ]; then exit 1; fi 7 | 8 | gnome_schema="org.gnome.desktop.interface" 9 | gtk_theme="$(grep 'gtk-theme-name' "$config" | sed 's/.*\s*=\s*//')" 10 | icon_theme="$(grep 'gtk-icon-theme-name' "$config" | sed 's/.*\s*=\s*//')" 11 | cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | sed 's/.*\s*=\s*//')" 12 | font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')" 13 | 14 | gsettings set "$gnome_schema" gtk-theme "$gtk_theme" 15 | gsettings set "$gnome_schema" icon-theme "$icon_theme" 16 | gsettings set "$gnome_schema" cursor-theme "$cursor_theme" 17 | gsettings set "$gnome_schema" font-name "$font_name" 18 | -------------------------------------------------------------------------------- /.config/tmux/bin/lnav-tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function log-view() { 4 | local file="$1" 5 | # local file_basedir=echo "$(dirname "$(readlink -m "$file")")" 6 | tmux split-window -v "lnav -c ':reset-session' $file" 7 | } 8 | 9 | nvim_repo="$XDG_DATA_HOME/neovim" 10 | xtest_cache="$nvim_repo/build/Xtest_xdg/cache" 11 | 12 | declare -A logs=( 13 | [hyprland]="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log" 14 | [nvim]="$XDG_STATE_HOME/nvim/log" 15 | [nvim-lsp]="$XDG_STATE_HOME/nvim/lsp.log" 16 | [nvim-nightly]="$xtest_cache/nvim/*log*" 17 | [lvim]="$XDG_STATE_HOME/lvim/log" 18 | [lvim-lsp]="$XDG_STATE_HOME/lvim/lsp.log" 19 | ) 20 | 21 | SELECTION=$( 22 | printf "%s\n" "${!logs[@]}" | 23 | fzf-tmux --exact --exit-0 --delimiter=' ' --reverse --header="select log file to view " 24 | ) && 25 | log-view "${logs[$SELECTION]}" 26 | -------------------------------------------------------------------------------- /.config/gitui/theme.ron: -------------------------------------------------------------------------------- 1 | 2 | /* dracula */ 3 | 4 | ( 5 | selected_tab: Some(Rgb(255, 255, 0)), 6 | command_fg: Some(Rgb(248, 248, 242)), 7 | selection_bg: Some(Rgb(98, 114, 164)), 8 | cmdbar_extra_lines_bg: Some(Rgb(40, 42, 54)), 9 | disabled_fg: Some(Rgb(98, 114, 164)), 10 | diff_line_add: Some(Rgb(80, 250, 123)), 11 | diff_line_delete: Some(Rgb(255, 85, 85)), 12 | diff_file_added: Some(Rgb(105, 255, 148)), 13 | diff_file_removed: Some(Rgb(255, 110, 110)), 14 | diff_file_moved: Some(Rgb(255, 146, 223)), 15 | diff_file_modified: Some(Rgb(241, 250, 140)), 16 | commit_hash: Some(Rgb(189, 147, 249)), 17 | commit_time: Some(Rgb(164, 255, 255)), 18 | commit_author: Some(Rgb(80, 250, 123)), 19 | danger_fg: Some(Rgb(255, 85, 85)), 20 | push_gauge_bg: Some(Rgb(40, 42, 54)), 21 | push_gauge_fg: Some(Rgb(248, 248, 242)), 22 | ) 23 | 24 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/indent.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | local opts = { 5 | indent = { char = "┊" }, 6 | exclude = { 7 | filetypes = { 8 | "alpha", 9 | "checkhealth", 10 | "dashboard", 11 | "gitcommit", 12 | "help", 13 | "lspinfo", 14 | "lsp-installer", 15 | "man", 16 | "mason", 17 | "packer", 18 | "TelescopePrompt", 19 | "TelescopeResults", 20 | "terminal", 21 | "", 22 | }, 23 | buftypes = { 24 | "terminal", 25 | "nofile", 26 | "quickfix", 27 | "prompt", 28 | }, 29 | }, 30 | scope = { 31 | enabled = true, 32 | char = nil, 33 | show_start = true, 34 | show_end = true, 35 | injected_languages = true, 36 | }, 37 | } 38 | 39 | require("ibl").setup(opts) 40 | end 41 | 42 | return M 43 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/pylsp.lua: -------------------------------------------------------------------------------- 1 | local before_init = function(_, config) 2 | if vim.env.VIRTUAL_ENV then 3 | local python_bin = require("lspconfig.util").path.join(vim.env.VIRTUAL_ENV, "bin", "python3") 4 | config.settings.python.pythonPath = python_bin 5 | end 6 | end 7 | 8 | return { 9 | -- autostart = false, 10 | before_init = before_init, 11 | settings = { 12 | pylsp = { 13 | plugins = { 14 | flake8 = { 15 | enabled = false, 16 | }, 17 | pyflakes = { 18 | enabled = true, 19 | }, 20 | pycodestyle = { 21 | enabled = false, 22 | }, 23 | pylint = { 24 | enabled = true, 25 | }, 26 | isort = { 27 | enabled = true, 28 | }, 29 | black = { 30 | enabled = false, 31 | }, 32 | yapf = { 33 | enabled = true, 34 | }, 35 | }, 36 | }, 37 | }, 38 | } 39 | -------------------------------------------------------------------------------- /.config/alacritty/colors/pastel.toml: -------------------------------------------------------------------------------- 1 | [colors.bright] 2 | black = "#475569" 3 | blue = "#61afef" 4 | cyan = "#56b6c2" 5 | green = "#98c379" 6 | magenta = "#a626a4" 7 | red = "#e86671" 8 | white = "#f8fafc" 9 | yellow = "#e0af68" 10 | 11 | [colors.dim] 12 | black = "#131415" 13 | blue = "#556a7d" 14 | cyan = "#5b7d78" 15 | green = "#777c44" 16 | magenta = "#75617b" 17 | red = "#864343" 18 | white = "#94a3b8" 19 | yellow = "#9e824c" 20 | 21 | [colors.normal] 22 | black = "#0f172a" 23 | blue = "#73D0FF" 24 | cyan = "#95E6CB" 25 | green = "#BAE67E" 26 | magenta = "#C678DD" 27 | red = "#FF3333" 28 | white = "#e2e8f0" 29 | yellow = "#FFA759" 30 | 31 | [colors.primary] 32 | background = "#202734" 33 | foreground = "#CBCCC6" 34 | 35 | [colors.search.focused_match] 36 | background = "#C7C7C7" 37 | foreground = "#191919" 38 | 39 | [colors.search.matches] 40 | background = "#5c5d5c" 41 | foreground = "#191919" 42 | 43 | [colors.vi_mode_cursor] 44 | cursor = "CellForeground" 45 | text = "CellBackground" 46 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Dotfiles 2 | 3 | - [alacritty](https://github.com/alacritty/alacritty) - A cross-platform, OpenGL terminal emulator 4 | - [bash](https://ftpmirror.gnu.org/bash/) - The GNU Bourne Again shell 5 | - [bat](https://github.com/sharkdp/bat) - A cat(1) clone with wings 6 | - [fd](https://github.com/sharkdp/fd) - A simple, fast and user-friendly alternative to 'find 7 | - [fzf](https://github.com/junegunn/fzf) - A command-line fuzzy finder 8 | - [lf](https://github.com/gokcehan/lf) - Terminal file manager 9 | - [neovim](https://github.com/neovim/neovim) - Vim-fork focused on extensibility and usability 10 | - [ripgrep](https://github.com/BurntSushi/ripgrep) - A search tool that combines the usability of ag with the raw speed of grep 11 | - [tmux](https://github.com/tmux/tmux) - A terminal multiplexer 12 | - [vim](https://github.com/vim/vim) - Vi Improved, a highly configurable, improved version of the vi text editor 13 | - [zsh](https://github.com/zsh-users/zsh) - UNIX command interpreter (shell) 14 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/cmake.lua: -------------------------------------------------------------------------------- 1 | local function get_hover_info() 2 | local ts_utils = require "nvim-treesitter.ts_utils" 3 | local n = ts_utils.get_node_at_cursor() 4 | local type = n:type() 5 | if type ~= "identifier" then 6 | n = n:parent() 7 | end 8 | local text = vim.treesitter.query.get_node_text(n, 0) 9 | 10 | local cmd = string.format("cmake --help-command %s | bat --plain -l rst", text) 11 | local Terminal = require("toggleterm.terminal").Terminal 12 | local term_opts = { cmd = cmd, direction = "horizontal" } 13 | local cmake_help = Terminal:new(term_opts) 14 | 15 | cmake_help:toggle() 16 | end 17 | 18 | local custom_on_attach = function(client, bufnr) 19 | require("user.lsp").common_on_attach(client, bufnr) 20 | 21 | local opts = { noremap = true, silent = true, buffer = bufnr, desc = "Hover info" } 22 | vim.keymap.set("n", "lh", get_hover_info, opts) 23 | end 24 | 25 | return { 26 | -- autostart = false, 27 | on_attach = custom_on_attach, 28 | } 29 | -------------------------------------------------------------------------------- /.config/emacs/init.el: -------------------------------------------------------------------------------- 1 | (require 'package) 2 | 3 | (setq package-archives '(("melpa" . "https://melpa.org/packages/") 4 | ("elpa" . "https://elpa.gnu.org/packages/"))) 5 | 6 | (package-initialize) 7 | (unless package-archive-contents 8 | (package-refresh-contents)) 9 | 10 | (setq package-selected-packages '(lsp-mode flycheck which-key)) 11 | 12 | (when (cl-find-if-not #'package-installed-p package-selected-packages) 13 | (package-refresh-contents) 14 | (mapc #'package-install package-selected-packages)) 15 | 16 | (require 'lsp-mode) 17 | 18 | (which-key-mode) 19 | (add-hook 'c-mode-hook 'lsp-deferred) 20 | (add-hook 'c++-mode-hook 'lsp-deferred) 21 | 22 | (with-eval-after-load 'lsp-mode 23 | (add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)) 24 | 25 | (setq lsp-clients-clangd-args '("--all-scopes-completion" 26 | "--background-index" 27 | "--pch-storage=memory" 28 | "--log=info" 29 | "--enable-config" 30 | "--clang-tidy" 31 | "--completion-style=detailed" 32 | "--offset-encoding=utf-16")) 33 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/lightspeed.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | require("lightspeed").setup { 5 | ignore_case = false, 6 | exit_after_idle_msecs = { unlabeled = 1000, labeled = 1500 }, 7 | -- s/x 8 | jump_to_unique_chars = { safety_timeout = 400 }, -- jump right after the first input, if the target character is unique in the search direction 9 | match_only_the_start_of_same_char_seqs = true, -- separator line will not snatch up all the available labels for `==` or `--` 10 | substitute_chars = { ["\r"] = "¬" }, -- highlighted matches by the given characters 11 | special_keys = { -- switch to the next/previous group of matches, when there are more matches than labels available 12 | next_match_group = "", 13 | prev_match_group = "", 14 | }, 15 | 16 | -- f/t 17 | limit_ft_matches = 4, -- For 1-character search, the next 'n' matches will be highlighted after [count] 18 | repeat_ft_with_target_char = false, -- repeat f/t motions by pressing the target character repeatedly 19 | } 20 | end 21 | 22 | return M 23 | -------------------------------------------------------------------------------- /.config/hypr/scripts/fix-portals.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | env_vars=( 5 | DISPLAY DBUS_SESSION_BUS_ADDRESS WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP 6 | ) 7 | 8 | systemctl --user import-environment "${env_vars[@]}" 9 | 10 | hash dbus-update-activation-environment \ 11 | && dbus-update-activation-environment --systemd "${env_vars[@]}" 12 | 13 | # disabled tweaking the portals for now, see https://github.com/flatpak/xdg-desktop-portal/issues/986 14 | 15 | # sleep 1 16 | # 17 | # systemctl --user restart \ 18 | # xdg-desktop-portal-hyprland \ 19 | # xdg-desktop-portal \ 20 | # pipewire \ 21 | # pipewire-pulse \ 22 | # wireplumber 23 | 24 | # sleep 1 25 | # systemctl --user stop xdg-desktop-portal xdg-desktop-portal-hyprland 26 | # 27 | # sleep 1 28 | # systemctl --user start xdg-desktop-portal xdg-desktop-portal-hyprland 29 | 30 | ## original solution from the wiki 31 | 32 | # sleep 4 33 | # killall xdg-desktop-portal-wlr 34 | # killall xdg-desktop-portal 35 | 36 | # /usr/lib/xdg-desktop-portal-wlr & 37 | # sleep 4 38 | # /usr/lib/xdg-desktop-portal & 39 | -------------------------------------------------------------------------------- /.config/gh/config.yml: -------------------------------------------------------------------------------- 1 | # What protocol to use when performing git operations. Supported values: ssh, https 2 | git_protocol: https 3 | # What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment. 4 | editor: nvim 5 | # When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled 6 | prompt: enabled 7 | # A pager program to send command output to, e.g. "less". Set the value to "cat" to disable the pager. 8 | pager: bat --paging=always --color=always --style=plain 9 | # Aliases allow you to create nicknames for gh commands 10 | aliases: 11 | co: '!id=${1:-"$(gh pr list -L50 | fzf | cut -f1)"}; [ -n "$id" ] && gh pr checkout "$id"' 12 | rc: repo clone 13 | repo-delete: api -X DELETE "repos/$1" 14 | fork: repo fork --remote-name=fork --remote=true 15 | mp: pr list --author @me 16 | bugs: issue list --label=bugs 17 | coi: '!id="$(gh pr list -L100 | fzf | cut -f1)"; [ -n "$id" ] && gh pr checkout "$id"' 18 | results: '!gh run list --branch "$(git branch --show-current)"' 19 | version: "1" 20 | -------------------------------------------------------------------------------- /.config/zsh/.zlogin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | # Asynchronously zcompile .zcompdump file. 4 | { 5 | typeset -g zcompdump="$XDG_CACHE_HOME/zsh/compdump" 6 | 7 | if ([[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]) { 8 | zcompile "$zcompdump" 9 | } 10 | } &! 11 | 12 | if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then 13 | export GDK_BACKEND=wayland 14 | export MOZ_ENABLE_WAYLAND=1 15 | # if [[ ! "$XDG_DATA_DIRS" =~ "$XDG_DATA_HOME" ]]; then 16 | # export XDG_DATA_DIRS="$XDG_DATA_HOME:$XDG_DATA_DIRS" 17 | # fi 18 | fi 19 | 20 | # if tmux is executable and not inside a tmux session, then try to attach. 21 | # if attachment fails, start a new session 22 | 23 | # if [ -n "${DISPLAY}" ] && [ -z "${TMUX}" ]; then 24 | # command -v smug >/dev/null && { tmux attach -t default || smug start default -a; } >/dev/null 2>&1 25 | # fi 26 | 27 | # # Use of stty should really only be used with interactive shells. 28 | # if [[ -o interactive ]]; then 29 | # # https://unix.stackexchange.com/questions/72086/ctrl-s-hangs-the-terminal-emulator 30 | # # stty stop '' 31 | # stty -ixon 32 | # fi 33 | -------------------------------------------------------------------------------- /.config/pacman/makepkg.conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=SC2034 3 | 4 | # refs: 5 | # - https://wiki.gentoo.org/wiki/Clang#Link-time_optimizations_with_Clang 6 | # - https://doc.rust-lang.org/rustc/codegen-options/index.html 7 | 8 | np="$(nproc)" 9 | 10 | # NOTE: this might be problematic with hard-coded flags.. 11 | # CC=clang 12 | # CXX=clang++ 13 | # AR=llvm-ar 14 | # NM=llvm-nm 15 | # RANLIB=llvm-ranlib 16 | # 17 | # LDFLAGS="${LDFLAGS} -fuse-ld=lld" 18 | 19 | MAKEFLAGS="${MAKEFLAGS} -j${np}" 20 | 21 | CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" 22 | CMAKE_BUILD_PARALLEL_LEVEL="${np}" 23 | # using ninja causes occasional problems with AUR builds 24 | unset CMAKE_GENERATOR 25 | 26 | RUSTFLAGS="-C target-cpu=native -C linker=clang" 27 | 28 | ######################################################################### 29 | # COMPRESSION DEFAULTS 30 | ######################################################################### 31 | # 32 | COMPRESSZST=(zstd -c -T0 --auto-threads=logical -) 33 | 34 | ######################################################################### 35 | # EXTENSION DEFAULTS 36 | ######################################################################### 37 | # 38 | PKGEXT='.pkg.tar.zst' 39 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/yamlls.lua: -------------------------------------------------------------------------------- 1 | local custom_on_attach = function(client, bufnr) 2 | require("user.lsp").common_on_attach(client, bufnr) 3 | client.server_capabilities.documentFormattingProvider = true 4 | end 5 | 6 | return { 7 | -- filetypes = {"yaml"}, 8 | on_attach = custom_on_attach, 9 | settings = { 10 | yaml = { 11 | format = { 12 | enable = true, 13 | }, 14 | validate = true, 15 | schemas = { 16 | ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.yml", 17 | ["https://json.schemastore.org/pre-commit-config.json"] = ".pre-commit-config.yaml", 18 | kubernetes = "/*.k8s.yaml", 19 | }, 20 | -- scheme = { 21 | -- ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.yml", 22 | -- ["https://json.schemastore.org/pre-commit-config.json"] = ".pre-commit-config.yaml", 23 | -- ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/all.json"] = "frontend-service.yaml" 24 | -- }, 25 | schemaDownload = { enable = true }, 26 | }, 27 | }, 28 | } 29 | -------------------------------------------------------------------------------- /.config/git/hooks/dots-pre-push: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # TODO: consider using python instead 5 | 6 | declare -a TRACKED_DIR 7 | declare -a UNIQUE_DIRS 8 | declare -a MISSED_FILES 9 | UNIQUE_DIRS=(".config/nvim" ".config/zsh") 10 | TRACKED_DIR=($(git -C "$HOME" dots ls-files | xargs -n 1 dirname | rg '^.config/\w*$' | uniq)) 11 | 12 | function find_untracked() { 13 | local -a hits 14 | for dir in "${TRACKED_DIR[@]}"; do 15 | [ -r "$HOME/$dir/.gitignore" ] && local EXCLUDE_FLAG="--exclude-from $HOME/$dir/.gitignore" 16 | hits=($(git dots -C "$HOME/$dir" ls-files \ 17 | --full-name --others $EXCLUDE_FLAG --exclude 'lazygit' --exclude '_*')) 18 | for file in "${hits[@]}"; do 19 | MISSED_FILES+=("$file") 20 | done 21 | done 22 | } 23 | 24 | # function find_unique_untracked() { 25 | # for dir in "${UNIQUE_DIRS[@]}"; do 26 | # local -a hits=("$(git dots -C "$HOME/$dir" ls-files \ 27 | # --full-name --others --exclude-from "$HOME/$dir/.gitignore")") 28 | # echo "${hits[@]}" 29 | # done 30 | # } 31 | 32 | find_untracked 33 | if [ -f "${MISSED_FILES[1]}" ]; then 34 | # echo "warning! did you miss these?" 35 | # echo -e "${MISSED_FILES[@]}" 36 | # # return 1 37 | exit 0 38 | fi 39 | # find_unique_untracked 40 | -------------------------------------------------------------------------------- /.config/tmux/scripts/zlf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | opts=$(printf '%q ' "${args[@]}") 4 | 5 | [[ -z $height ]] && height=${TMUX_POPUP_HEIGHT:-80%} 6 | [[ -z $width ]] && width=${TMUX_POPUP_WIDTH:-80%} 7 | 8 | envs="SHELL=$SHELL" 9 | id=$RANDOM 10 | cmd_file="${TMPDIR:-/tmp}/lf-cmd-file-$id" 11 | clean_cmd="command rm -f $cmd_file $pstdin $pstdout" 12 | 13 | cleanup() { 14 | eval "$clean_cmd" 15 | } 16 | 17 | trap 'cleanup' EXIT 18 | 19 | zlf() { 20 | # set -x 21 | emulate -L zsh 22 | local d=$(mktemp -d) || return 1 23 | { 24 | mkfifo -m 600 $d/fifo || return 1 25 | 26 | # tmux popup -d '#{pane_current_path}' \ 27 | # -xC -yC -w$width -h$height \ 28 | # "echo {ZLE_FIFO}>$d/fifo; export ZLE_FIFO; exec lf" || return 1 29 | # -E "$envs bash $cmd_file" || return 1 30 | 31 | tmux split -bf \ 32 | "echo {ZLE_FIFO}>$d/fifo; export ZLE_FIFO; exec lf" || return 1 33 | 34 | local fd 35 | exec {fd}<$d/fifo 36 | zle -Fw $fd _zlf_handler 37 | } always { 38 | rm -rf $d 39 | } 40 | } 41 | 42 | 43 | zlf_handler() { 44 | emulate -L zsh 45 | local line 46 | if ! read -r line <&$1; then 47 | zle -F $1 48 | exec {1} <&- 49 | return 1 50 | fi 51 | eval $line 52 | zle -R 53 | } 54 | 55 | zle -N zlf 56 | zle -N zlf_handler 57 | 58 | bindkey '^e' zlf 59 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/neogen.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | local i = require("neogen.types.template").item 5 | local custom_template = { 6 | -- { nil, "/// ", { no_results = true, type = { "func", "file", "class" } } }, 7 | { nil, "/// @file", { no_results = true, type = { "file" } } }, 8 | { nil, "/// @brief $1", { no_results = true, type = { "func", "file", "class" } } }, 9 | -- { nil, "/// ", { no_results = true, type = { "func", "file", "class" } } }, 10 | { nil, "", { no_results = true, type = { "file" } } }, 11 | 12 | -- { nil, "/// ", { type = { "func", "class" } } }, 13 | { i.ClassName, "/// @class %s", { type = { "class" } } }, 14 | { nil, "/// @brief $1", { type = { "func", "class" } } }, 15 | -- { nil, "/// ", { type = { "func", "class" } } }, 16 | { i.Tparam, "/// @tparam %s $1" }, 17 | { i.Parameter, "/// @param %s $1" }, 18 | { i.Return, "/// @return $1" }, 19 | -- { nil, "/// ", { type = { "func", "class" } } }, 20 | } 21 | 22 | require("neogen").setup { 23 | enable = true, 24 | input_after_command = true, 25 | languages = { 26 | c = { 27 | template = { 28 | annotation_convention = "my_annotation", 29 | my_annotation = custom_template, 30 | }, 31 | }, 32 | }, 33 | } 34 | end 35 | 36 | return M 37 | -------------------------------------------------------------------------------- /.config/zsh/aliases.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # shellcheck disable 3 | 4 | # TODO: check more examples from 5 | # https://blog.sebastian-daschner.com/entries/zsh-aliases 6 | 7 | alias v='nvim' 8 | 9 | alias dtf='dotbare' 10 | 11 | alias dta='dotbare fadd' 12 | alias dtc='dotbare commit -m ' 13 | alias dtg='dotbare fgrep' 14 | alias dtl='dotbare flog' 15 | alias dtp='dotbare pull' 16 | alias dtP='dotbare push' 17 | alias dtr='dotbare fcheckout' 18 | alias dts='dotbare fstat' 19 | 20 | alias ls='ls -v --color=auto --group-directories-first' 21 | alias l='ls -ACFN' 22 | alias ll='ls -hlqAFN' 23 | alias lt='exa --tree --color=always --icons --all --git --level=2' 24 | 25 | alias dte="GIT_DIR=$HOME/.dtf.git GIT_WORK_TREE=$HOME dotbare fedit" 26 | alias dtm="GIT_DIR=$HOME/.dtf.git GIT_WORK_TREE=$HOME dotbare fedit --modified" 27 | alias pre-dots-commit="GIT_DIR=$HOME/.dtf.git GIT_WORK_TREE=$HOME pre-commit" 28 | 29 | alias lg='lazygit' 30 | alias gu='gitui' 31 | 32 | [ -e /etc/arch-release ] && alias -g paks='sudo pacman -S' 33 | 34 | alias paux='ps aux | rg' 35 | alias tk='tmux kill-server' 36 | 37 | # insert relevant xkcd 38 | alias archive='tar --create --gzip --verbose --file' 39 | 40 | # workaround for interactive 'rm' 41 | alias rm &>/dev/null && unalias rm 42 | 43 | alias grep="grep --color" 44 | 45 | alias -g MN='| bat --language man' 46 | alias -g FZ='| fzf' 47 | 48 | alias -g pipuninstall='pip uninstall -y -r <(pip freeze --user)' 49 | 50 | alias -s {cpp,cxx,cc,c,hh,h,lua,vim,ts,js,yml,json,toml,ini,txt,cmake}="$EDITOR" 51 | alias -s md="glow" 52 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/mason.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | local join_paths = require("user.utils").join_paths 3 | 4 | function M.setup() 5 | local opts = { 6 | PATH = "prepend", 7 | log_level = vim.log.levels.INFO, 8 | max_concurrent_installers = 4, 9 | ui = { 10 | install_root_dir = join_paths(vim.fn.stdpath "data", "mason"), 11 | check_outdated_packages_on_open = false, 12 | border = "rounded", 13 | keymaps = { 14 | toggle_package_expand = "", 15 | install_package = "i", 16 | update_package = "u", 17 | check_package_version = "c", 18 | update_all_packages = "U", 19 | check_outdated_packages = "C", 20 | uninstall_package = "X", 21 | cancel_installation = "", 22 | apply_language_filter = "", 23 | toggle_package_install_log = "", 24 | toggle_help = "g?", 25 | }, 26 | }, 27 | github = { 28 | -- The template URL to use when downloading assets from GitHub. 29 | -- The placeholders are the following (in order): 30 | -- 1. The repository (e.g. "rust-lang/rust-analyzer") 31 | -- 2. The release version (e.g. "v0.3.0") 32 | -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz") 33 | download_url_template = "https://github.com/%s/releases/download/%s/%s", 34 | }, 35 | } 36 | 37 | require("mason").setup(opts) 38 | 39 | local ls_opts = { automatic_installation = { exclude = { "clangd" } } } 40 | 41 | require("user.lsp").setup() 42 | require("mason-lspconfig").setup(ls_opts) 43 | end 44 | 45 | return M 46 | -------------------------------------------------------------------------------- /.config/tmux/bin/fman-tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CMD="zsh" 5 | SESSION="scratch" 6 | 7 | declare -a REST=() 8 | 9 | function usage() { 10 | echo "Usage: fman []" 11 | echo "" 12 | echo "Options:" 13 | echo " -h, --help Print this help message" 14 | echo " -c, --command command to execute" 15 | echo " -s, --session session name" 16 | echo " -- all arguments after this are passed verbatim to the command" 17 | } 18 | 19 | function parse_arguments() { 20 | while [ "$#" -gt 0 ]; do 21 | case "$1" in 22 | -c | --command) 23 | CMD="$2" 24 | ;; 25 | -s | --session) 26 | SESSION="$2" 27 | ;; 28 | --) 29 | REST=("$@") 30 | ;; 31 | -h | --help) 32 | usage 33 | exit 0 34 | esac 35 | shift 36 | done 37 | } 38 | 39 | function main(){ 40 | parse_arguments "$@" 41 | cur_session=$(tmux display -p '#S') 42 | if [ "${cur_session}" == "${SESSION}" ]; then 43 | tmux detach-client 44 | else 45 | # local pane_path="'#{?pane_path,#{pane_path},#{pane_current_path}}'" 46 | # see: https://github.com/neovim/neovim/issues/21771#issuecomment-1615894467 47 | local pane_path="'#{?pane_path,#{s@^file.//@@:pane_path},#{pane_current_path}}'" 48 | # FIXME: we should probably quit the current process if it exists, but this doesn't seem to work even with -X 49 | tmux display-popup -E -yC -xC -w 85% -h 85% \ 50 | "tmux new-session -c ${pane_path} -A -s ${SESSION} ${CMD} ${REST[*]}" 51 | fi 52 | } 53 | 54 | main "$@" 55 | -------------------------------------------------------------------------------- /.config/zsh/utils/ssh-agent.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # https://github.com/romkatv/powerlevel10k/issues/277#issuecomment-545517605 3 | 4 | # Starts ssh-agent if it isn't already running. 5 | () { 6 | emulate -L zsh -o no_unset -o extended_glob 7 | 8 | function _ssh-agent-running() { 9 | [[ -v SSH_AUTH_SOCK && -r $SSH_AUTH_SOCK && -w $SSH_AUTH_SOCK && 10 | -v SSH_AGENT_PID && "$(command ps -p $SSH_AGENT_PID -o comm= 2>/dev/null)" == ssh-agent ]] 11 | } 12 | 13 | { 14 | _ssh-agent-running && return 15 | 16 | local env_file=${XDG_CACHE_HOME:-$HOME/.cache}/ssh-agent-env 17 | if [[ ! -d ${env_file:h} ]]; then 18 | command mkdir -pm 0700 -- ${env_file:h} || return 19 | fi 20 | 21 | if [[ -n $env_file(#qNW) || -n ${env_file:h}/(../)#(#qNW) ]]; then 22 | local f=$env_file 23 | while true; do 24 | if [[ -n $f(#qNW) ]]; then 25 | f=${(q)f//\%/%%} 26 | print -ru2 -- ${(%):-"Not using ssh-agent because %U$f%u is %F{1}world-writable%f."} 27 | print -ru2 -- "" 28 | print -ru2 -- "Run the following command to fix this issue:" 29 | print -ru2 -- "" 30 | print -ru2 -- ${(%):-" %F{2}%Usudo%u chmod%f o-w -- %U$f%u"} 31 | return 1 32 | fi 33 | [[ $f == / ]] && break 34 | f=${f:h} 35 | done 36 | fi 37 | 38 | if [[ -e $env_file ]]; then 39 | builtin source $env_file >/dev/null 40 | _ssh-agent-running && return 41 | fi 42 | 43 | unset SSH_AGENT_PID SSH_AUTH_SOCK 44 | command ssh-agent -st 20h >$env_file || return 45 | builtin source $env_file >/dev/null || return 46 | } always { 47 | unfunction _ssh-agent-running 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /.config/zsh/keymaps.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | bindkey -e 4 | 5 | # Fix backspace not working after returning from cmd mode 6 | bindkey '^?' backward-delete-char 7 | bindkey '^h' backward-delete-char 8 | 9 | # Edit line in vim buffer alt-v 10 | autoload edit-command-line 11 | zle -N edit-command-line 12 | bindkey '^[v' edit-command-line 13 | 14 | # Fix Home/End 15 | # it seems to read differently in tmux for some reason 16 | if [ -z "$TMUX" ]; then 17 | bindkey '^[[H' beginning-of-line 18 | bindkey '^[[F' end-of-line 19 | else 20 | bindkey '^[OH' beginning-of-line 21 | bindkey '^[OF' end-of-line 22 | fi 23 | 24 | # Fix Delete 25 | bindkey '^[[3~' delete-char 26 | 27 | # [muscle-memory] kill line-forward 28 | bindkey '^K' kill-line 29 | bindkey '^X^K' kill-line 30 | 31 | bindkey '^D' kill-word 32 | bindkey '^H' backward-kill-word 33 | 34 | # [muscle-memory] use alt+. to repeat argument 35 | bindkey '^[.' insert-last-word 36 | 37 | # repeat last written word before cursor 38 | bindkey "^[," copy-prev-shell-word 39 | 40 | # partial history search 41 | autoload -U up-line-or-beginning-search 42 | autoload -U down-line-or-beginning-search 43 | zle -N up-line-or-beginning-search 44 | zle -N down-line-or-beginning-search 45 | bindkey '^P' up-line-or-beginning-search 46 | bindkey '^N' down-line-or-beginning-search 47 | 48 | function _expand_alias_wrapper(){ 49 | zle _expand_alias 50 | # fix color as well as allow typing 51 | zle magic-space 52 | } 53 | 54 | zle -N _expand_alias_wrapper 55 | 56 | bindkey '^Xa' _expand_alias_wrapper 57 | 58 | bindkey '^@' vi-forward-word 59 | bindkey '^X^@' vi-add-eol 60 | bindkey '^[[1;5C' vi-forward-word # ctrl+right 61 | bindkey '^[[1;5D' vi-backward-word # ctrl+left 62 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/clangd.lua: -------------------------------------------------------------------------------- 1 | local clangd_flags = { 2 | "--all-scopes-completion", 3 | "--background-index", 4 | "--log=error", 5 | "--pretty", 6 | "--enable-config", 7 | "--clang-tidy", 8 | "--completion-style=detailed", 9 | -- "-j8", 10 | "--offset-encoding=utf-16", --temporary fix for null-ls 11 | "--query-driver=/bin/*-gcc,/bin/*-g++,/bin/clang-*", -- allow cross-compilers 12 | -- "--pch-storage=disk", 13 | -- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", 14 | } 15 | 16 | local provider = "clangd" 17 | 18 | local custom_on_attach = function(client, bufnr) 19 | require("user.lsp").common_on_attach(client, bufnr) 20 | local opts = { noremap = true, silent = true, buffer = bufnr } 21 | vim.keymap.set("n", "lh", "ClangdSwitchSourceHeader", opts) 22 | vim.keymap.set("x", "lA", "ClangdAST", opts) 23 | vim.keymap.set("n", "lH", "ClangdTypeHierarchy", opts) 24 | vim.keymap.set("n", "lt", "ClangdSymbolInfo", opts) 25 | vim.keymap.set("n", "ll", "ClangdToggleInlayHints", opts) 26 | vim.keymap.set("n", "lm", "ClangdMemoryUsage", opts) 27 | end 28 | 29 | local util = require "lspconfig.util" 30 | local root_files = { 31 | -- ".clangd", -- can be included in subdirs 32 | -- ".clang-tidy", 33 | -- ".clang-format", 34 | "compile_commands.json", 35 | "compile_flags.txt", 36 | "configure.ac", -- AutoTools 37 | } 38 | 39 | local server_opts = { 40 | cmd = { provider, unpack(clangd_flags) }, 41 | on_attach = custom_on_attach, 42 | root_dir = function(fname) 43 | return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) 44 | end, 45 | } 46 | 47 | return server_opts 48 | -------------------------------------------------------------------------------- /.config/alacritty/colors/pastel.yaml: -------------------------------------------------------------------------------- 1 | colors: 2 | # Default colors 3 | primary: 4 | background: '#202734' 5 | foreground: '#CBCCC6' 6 | 7 | # Normal colors 8 | normal: 9 | black: '#0f172a' 10 | red: '#FF3333' 11 | green: '#BAE67E' 12 | yellow: '#FFA759' 13 | blue: '#73D0FF' 14 | magenta: '#C678DD' 15 | cyan: '#95E6CB' 16 | white: '#e2e8f0' 17 | 18 | # Bright colors 19 | bright: 20 | black: '#475569' # also serves as "dark gray" 21 | red: '#e86671' 22 | green: '#98c379' 23 | yellow: '#e0af68' 24 | blue: '#61afef' 25 | magenta: '#a626a4' 26 | cyan: '#56b6c2' 27 | white: '#f8fafc' 28 | 29 | # Dim colors 30 | # 31 | # If the dim colors are not set, they will be calculated automatically based 32 | # on the `normal` colors. 33 | dim: 34 | black: '#131415' 35 | red: '#864343' 36 | green: '#777c44' 37 | yellow: '#9e824c' 38 | blue: '#556a7d' 39 | magenta: '#75617b' 40 | cyan: '#5b7d78' 41 | white: '#94a3b8' 42 | 43 | # indexed_colors: 44 | # - { index: 16, color: '#d19a66' } 45 | # - { index: 17, color: '#f65866' } 46 | # Cursor colors 47 | # 48 | # Colors which should be used to draw the terminal cursor. If these are unset, 49 | # the cursor color will be the inverse of the cell color. 50 | # cursor: 51 | # text: '#191919' 52 | # cursor: '#d8dee9' 53 | 54 | vi_mode_cursor: 55 | text: CellBackground 56 | cursor: CellForeground 57 | 58 | search: 59 | # Allowed values are CellForeground/CellBackground, which reference the 60 | # affected cell, or hexadecimal colors like #ff00ff. 61 | matches: 62 | foreground: '#191919' 63 | background: '#5c5d5c' 64 | focused_match: 65 | foreground: '#191919' 66 | background: '#C7C7C7' 67 | -------------------------------------------------------------------------------- /.config/tmux/bin/dwm-tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | BASE_IDX=${BASE_IDX:-"$(tmux display -p "#{pane-base-index}")"} 5 | 6 | function main() { 7 | if [ $# -lt 1 ]; then 8 | echo "dwm.tmux.sh [command]" 9 | exit 10 | fi 11 | 12 | command=$1 13 | shift 14 | 15 | case $command in 16 | newpane) newpane ;; 17 | splitv) splitv "$@";; 18 | splith) splith "$@";; 19 | rotateccw) rotateccw ;; 20 | rotatecw) rotatecw ;; 21 | focus) focus ;; 22 | layouttile) layouttile ;; 23 | zoom) zoom ;; 24 | float) float ;; 25 | togglepane) togglepane ;; 26 | *) 27 | echo "unknown command" 28 | exit 1 29 | ;; 30 | esac 31 | } 32 | 33 | window_panes="$(tmux display -p "#{window_panes}")" 34 | 35 | function newpane() { 36 | tmux new-window -c '#{?pane_path,#{pane_path},#{pane_current_path}}' 37 | } 38 | 39 | function splitv() { 40 | tmux split-window -v -c '#{?pane_path,#{pane_path},#{pane_current_path}}' "$@" 41 | } 42 | 43 | function splith() { 44 | tmux split-window -h -c '#{?pane_path,#{pane_path},#{pane_current_path}}' "$@" 45 | } 46 | 47 | function togglepane() { 48 | if ((window_panes > 1)); then 49 | tmux resize-pane -t "$BASE_IDX" -Z 50 | else 51 | tmux split-window -v -c '#{?pane_path,#{pane_path},#{pane_current_path}}' -l 30% 52 | fi 53 | } 54 | 55 | function rotateccw() { 56 | tmux rotate-window -U\; select-pane -t "$BASE_IDX" 57 | } 58 | 59 | function rotatecw() { 60 | tmux rotate-window -D\; select-pane -t "$BASE_IDX" 61 | } 62 | 63 | function focus() { 64 | tmux swap-pane -s :. -t "$BASE_IDX"\; select-pane -t "$BASE_IDX" 65 | } 66 | 67 | function layouttile() { 68 | tmux select-layout main-horizontal\; resize-pane -t "$BASE_IDX" -y "${FACTOR:-70}"% 69 | } 70 | 71 | function float() { 72 | tmux resize-pane -Z 73 | } 74 | 75 | main "$@" 76 | -------------------------------------------------------------------------------- /.config/lf/draw_img: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | clear_screen() { 4 | printf '\e[%sH\e[9999C\e[1J%b\e[1;%sr' \ 5 | "$((LINES - 2))" "${TMUX:+\e[2J}" "$max_items" 6 | } 7 | 8 | # Get a file's mime_type. 9 | mime_type=$(file -bi "$1") 10 | 11 | # File isn't an image file, give warning. 12 | if [[ $mime_type != image/* ]]; then 13 | lf -remote "send $id echoerr 'Not an image'" 14 | exit 15 | fi 16 | 17 | w3m_paths=(/usr/{local/,}{lib,libexec,lib64,libexec64}/w3m/w3mi*) 18 | read -r w3m _ < <(type -p w3mimgdisplay "${w3m_paths[@]}") 19 | read -r LINES COLUMNS < <(stty size) 20 | 21 | # Get terminal window size in pixels and set it to WIDTH and HEIGHT. 22 | export $(xdotool getactivewindow getwindowgeometry --shell) 23 | 24 | # Get the image size in pixels. 25 | read -r img_width img_height < <("$w3m" <<<"5;${CACHE:-$1}") 26 | 27 | ((img_width > WIDTH)) && { 28 | ((img_height = img_height * WIDTH / img_width)) 29 | ((img_width = WIDTH)) 30 | } 31 | 32 | ((img_height > HEIGHT)) && { 33 | ((img_width = img_width * HEIGHT / img_height)) 34 | ((img_height = HEIGHT)) 35 | } 36 | 37 | # Variable needed for centering image. 38 | HALF_HEIGHT=$(expr $HEIGHT / 2) 39 | HALF_WIDTH=$(expr $WIDTH / 2) 40 | HALF_IMG_HEIGHT=$(expr $img_height / 2) 41 | HALF_IMG_WIDTH=$(expr $img_width / 2) 42 | X_POS=$(expr $HALF_WIDTH - $HALF_IMG_WIDTH) 43 | Y_POS=$(expr $HALF_HEIGHT - $HALF_IMG_HEIGHT) 44 | 45 | clear_screen 46 | # Hide the cursor. 47 | printf '\e[?25l' 48 | 49 | # Display the image. 50 | printf '0;1;%s;%s;%s;%s;;;;;%s\n3;\n4\n' \ 51 | ${X_POS:-0} \ 52 | ${Y_POS:-0} \ 53 | "$img_width" \ 54 | "$img_height" \ 55 | "${CACHE:-$1}" | "$w3m" &>/dev/null 56 | 57 | # Wait for user input. 58 | read -ern 1 59 | 60 | # Clear the image. 61 | printf '6;%s;%s;%s;%s\n3;' \ 62 | "${X_POS:-0}" \ 63 | "${Y_POS:-0}" \ 64 | "$WIDTH" \ 65 | "$HEIGHT" | "$w3m" &>/dev/null 66 | 67 | clear_screen 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### dotfiles 2 | # 3 | # --- Initialization: 4 | # 5 | # git init --bare "$HOME/.dtf.git" 6 | # 7 | # --- Installation: 8 | # 9 | # alias dtf='git --git-dir="$HOME/.dtf.git" --work-tree="$HOME"' 10 | # dtf checkout 11 | # 12 | # We could have just initialized the repository directly in the home 13 | # folder, but the advantage of doing it with a bare repo and a work tree 14 | # is that normal uses of `git` won't try and use the home folder if you 15 | # aren't in a git repository. 16 | # 17 | # --- Usage: 18 | # 19 | # You can use `git add/commit/status/push` as usual, just replace `git` 20 | # with `dtf`. Note that before using `add`, you need to list the file 21 | # below. 22 | # 23 | # --- How it works: 24 | # 25 | # The following line prevents Git from scanning any folders any number of 26 | # levels underneath the repository work tree (home folder). Unlike if we 27 | # used a `*` only, this allows you to scan a folder without also including 28 | # including its contents by listing it with a `!` (see the next section). 29 | # If we used a single `*`, we would have needed to list each folder to scan 30 | # like `!.config` `.config/*` instead of just `!.config`. 31 | # --- From the manual 32 | # 33 | # A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside 34 | # directory "abc", relative to the location of the .gitignore file, with infinite depth. 35 | # 36 | /* 37 | # 38 | # The following line causes Git to track this file. 39 | !/.gitignore 40 | # --- bash 41 | !/.bashrc.user 42 | !/.config 43 | !/.config/bash/** 44 | # --- zsh (still not working as expected) 45 | !/.zshrc.user 46 | !/.config/zsh/ 47 | !/.config/zsh/**/* 48 | # --- nvim (still not working as expected) 49 | !/.config/nvim/ 50 | !/.config/nvim/**/* 51 | # --- tmux 52 | !/.config/tmux/** 53 | # --- misc (either non-static or reproducible) 54 | /.config/gh 55 | /.config/lazygit/state.yml 56 | 57 | 58 | .config/zsh/.zcompdump -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/ws.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local api = vim.api 4 | 5 | function M.add_workspace_folder(path, filter) 6 | for _, client in pairs(vim.lsp.get_active_clients(filter)) do 7 | if 8 | not vim.tbl_get(client.server_capabilities, "workspace", "workspaceFolders", "supported") 9 | then 10 | vim.notify_once( 11 | string.format("[LSP] %s doesn't support workspaces", client.name), 12 | vim.log.levels.WARN 13 | ) 14 | return 15 | end 16 | client.workspace_folders = client.workspace_folders or {} 17 | local prompt_opts = { 18 | prompt = "Workspace Folder: ", 19 | default = vim.fn.expand "%:p:h", 20 | } 21 | if not path then 22 | vim.ui.input(prompt_opts, function(input) 23 | path = input 24 | -- TODO: is there another way to dismiss the prompt? 25 | api.nvim_command "redraw" 26 | end) 27 | end 28 | if vim.fn.isdirectory(path) == 0 then 29 | vim.notify_once( 30 | string.format("[LSP] skipping adding invalid directory %s", path), 31 | vim.log.levels.WARN 32 | ) 33 | return 34 | end 35 | 36 | local new_workspace = { 37 | uri = vim.uri_from_fname(path), 38 | name = path, 39 | } 40 | local params = { event = { added = { new_workspace }, removed = {} } } 41 | for _, folder in pairs(client.workspace_folders) do 42 | if folder.name == path then 43 | vim.notify_once("[LSP] " .. path .. " is already part of this workspace") 44 | return 45 | end 46 | end 47 | client.notify("workspace/didChangeWorkspaceFolders", params) 48 | table.insert(client.workspace_folders, new_workspace) 49 | end 50 | end 51 | 52 | function M.list_workspace_folders(filter) 53 | local workspace_folders = {} 54 | for _, c in pairs(vim.lsp.get_active_clients(filter)) do 55 | for _, folder in pairs(c.workspace_folders or {}) do 56 | table.insert(workspace_folders, folder) 57 | end 58 | end 59 | return workspace_folders 60 | end 61 | 62 | return M 63 | -------------------------------------------------------------------------------- /.config/zk/config.toml: -------------------------------------------------------------------------------- 1 | # NOTE SETTINGS 2 | [note] 3 | 4 | # Language used when writing notes. 5 | # This is used to generate slugs or with date formats. 6 | language = "en" 7 | 8 | # The default title used for new note, if no `--title` flag is provided. 9 | default-title = "untitled" 10 | 11 | # Template used to generate a note's filename, without extension. 12 | filename = "{{id}}-{{slug title}}" 13 | 14 | # The file extension used for the notes. 15 | extension = "md" 16 | 17 | # Template used to generate a note's content. 18 | # If not an absolute path, it is relative to .zk/templates/ 19 | template = "default.md" 20 | 21 | # Configure random ID generation. 22 | 23 | # The charset used for random IDs. 24 | id-charset = "alphanum" 25 | 26 | # Length of the generated IDs. 27 | id-length = 4 28 | 29 | # Letter case for the random IDs. 30 | id-case = "lower" 31 | 32 | 33 | # MARKDOWN SETTINGS 34 | [format.markdown] 35 | # Enable support for #hashtags 36 | hashtags = true 37 | # Enable support for :colon:separated:tags: 38 | colon-tags = true 39 | 40 | 41 | # EXTERNAL TOOLS 42 | [tool] 43 | 44 | # Default editor used to open notes. 45 | editor = "nvim" 46 | 47 | # Pager used to scroll through long output. 48 | pager = "less -FIRX" 49 | 50 | # Command used to preview a note during interactive fzf mode. 51 | fzf-preview = "glow -s dark {-1}" 52 | 53 | # NAMED FILTERS 54 | [filter] 55 | recents = "--sort created- --created-after 'last two weeks'" 56 | 57 | # COMMAND ALIASES 58 | [alias] 59 | 60 | e = "zk edit --interactive" 61 | 62 | # Edit the last modified note. 63 | edlast = "zk edit --limit 1 --sort modified- $@" 64 | 65 | # Edit the notes selected interactively among the notes created the last two weeks. 66 | recent = "zk edit --sort created- --created-after 'last two weeks' --interactive" 67 | 68 | # Show a random note. 69 | lucky = "zk list --quiet --format full --sort random --limit 1" 70 | 71 | # LSP (EDITOR INTEGRATION) 72 | [lsp] 73 | 74 | [lsp.diagnostics] 75 | # Report titles of wiki-links as hints. 76 | wiki-title = "hint" 77 | # Warn for dead links between notes. 78 | dead-link = "warning" 79 | -------------------------------------------------------------------------------- /.config/gitui/key_bindings.ron: -------------------------------------------------------------------------------- 1 | // bit for modifiers 2 | // bits: 0 None 3 | // bits: 1 SHIFT 4 | // bits: 2 CONTROL 5 | // 6 | // Note: 7 | // If the default key layout is lower case, 8 | // and you want to use `Shift + q` to trigger the exit event, 9 | // the setting should like this `exit: Some(( code: Char('Q'), modifiers: ( bits: 1,),)),` 10 | // The Char should be upper case, and the shift modified bit should be set to 1. 11 | // 12 | // Note: 13 | // find `KeysList` type in src/keys/key_list.rs for all possible keys. 14 | // every key not overwritten via the config file will use the default specified there 15 | ( 16 | open_help: Some(( code: F(1), modifiers: ( bits: 0,),)), 17 | 18 | move_left: Some(( code: Char('h'), modifiers: ( bits: 0,),)), 19 | move_right: Some(( code: Char('l'), modifiers: ( bits: 0,),)), 20 | move_up: Some(( code: Char('k'), modifiers: ( bits: 0,),)), 21 | move_down: Some(( code: Char('j'), modifiers: ( bits: 0,),)), 22 | 23 | popup_up: Some(( code: Char('p'), modifiers: ( bits: 2,),)), 24 | popup_down: Some(( code: Char('n'), modifiers: ( bits: 2,),)), 25 | page_up: Some(( code: Char('b'), modifiers: ( bits: 2,),)), 26 | page_down: Some(( code: Char('f'), modifiers: ( bits: 2,),)), 27 | home: Some(( code: Char('g'), modifiers: ( bits: 0,),)), 28 | end: Some(( code: Char('G'), modifiers: ( bits: 1,),)), 29 | shift_up: Some(( code: Char('K'), modifiers: ( bits: 1,),)), 30 | shift_down: Some(( code: Char('J'), modifiers: ( bits: 1,),)), 31 | 32 | edit_file: Some(( code: Char('I'), modifiers: ( bits: 1,),)), 33 | 34 | status_reset_item: Some(( code: Char('U'), modifiers: ( bits: 1,),)), 35 | 36 | diff_reset_lines: Some(( code: Char('u'), modifiers: ( bits: 0,),)), 37 | diff_stage_lines: Some(( code: Char('s'), modifiers: ( bits: 0,),)), 38 | 39 | stashing_save: Some(( code: Char('w'), modifiers: ( bits: 0,),)), 40 | stashing_toggle_index: Some(( code: Char('m'), modifiers: ( bits: 0,),)), 41 | 42 | stash_open: Some(( code: Char('l'), modifiers: ( bits: 0,),)), 43 | 44 | abort_merge: Some(( code: Char('M'), modifiers: ( bits: 1,),)), 45 | ) 46 | -------------------------------------------------------------------------------- /.config/vivid/themes/one-dark.yml: -------------------------------------------------------------------------------- 1 | colors: 2 | background_color: '1e2127' 3 | white: 'abb2bf' 4 | red: 'e06c75' 5 | green: '98c379' 6 | yellow: 'e5c07b' 7 | blue: '61afef' 8 | pink: 'ff6ac1' 9 | cyan: '56b6c2' 10 | 11 | black: '1e2127' 12 | gray: 'abb2bf' 13 | darkgray: '5c6370' 14 | darkergray: '333333' 15 | 16 | core: 17 | normal_text: {} 18 | regular_file: {} 19 | reset_to_normal: {} 20 | 21 | directory: 22 | foreground: blue 23 | 24 | executable_file: 25 | foreground: red 26 | font-style: bold 27 | 28 | symlink: 29 | foreground: pink 30 | 31 | broken_symlink: 32 | foreground: black 33 | background: red 34 | 35 | missing_symlink_target: 36 | foreground: black 37 | background: red 38 | 39 | multi_hard_link: {} 40 | 41 | fifo: 42 | foreground: black 43 | background: blue 44 | 45 | socket: 46 | foreground: black 47 | background: pink 48 | 49 | door: 50 | foreground: black 51 | background: pink 52 | 53 | block_device: 54 | foreground: cyan 55 | background: darkergray 56 | 57 | setuid: {} 58 | 59 | setgid: {} 60 | 61 | character_device: 62 | foreground: pink 63 | background: darkergray 64 | 65 | file_with_capability: {} 66 | 67 | other_writable: {} 68 | 69 | sticky: {} 70 | 71 | sticky_other_writable: {} 72 | 73 | text: 74 | special: 75 | foreground: background_color 76 | background: yellow 77 | 78 | todo: 79 | font-style: bold 80 | 81 | licenses: 82 | foreground: gray 83 | 84 | configuration: 85 | foreground: yellow 86 | 87 | other: 88 | foreground: yellow 89 | 90 | markup: 91 | foreground: yellow 92 | 93 | programming: 94 | source: 95 | foreground: green 96 | 97 | tooling: 98 | foreground: green 99 | 100 | continuous-integration: 101 | foreground: green 102 | 103 | media: 104 | foreground: pink 105 | 106 | office: 107 | foreground: red 108 | 109 | archives: 110 | foreground: cyan 111 | font-style: underline 112 | 113 | executable: 114 | foreground: red 115 | font-style: bold 116 | 117 | unimportant: 118 | foreground: darkgray 119 | -------------------------------------------------------------------------------- /.config/alacritty/alacritty.toml: -------------------------------------------------------------------------------- 1 | import = ["~/.config/alacritty/colors/pastel.toml"] 2 | 3 | [bell] 4 | animation = "EaseOutExpo" 5 | 6 | [cursor.style] 7 | shape = "Beam" 8 | 9 | [env] 10 | TERM = "alacritty" 11 | 12 | [font] 13 | size = 12.0 14 | 15 | [font.normal] 16 | family = "HackNerdFontMono" 17 | 18 | [keyboard] 19 | bindings = [ 20 | { key = "Tab", mods = "Control", command = { program = "tmux", args= ["select-window", "-t", "+"] } }, 21 | { key = "Tab", mods = "Shift|Control", command = { program = "tmux", args= ["select-window", "-t", "-"] } }, 22 | { key = "Return", mods = "Control|Shift", action = "SpawnNewInstance" }, 23 | # QoL 24 | { key = "Space", mods = "Alt" , chars = " " }, 25 | { key = "Back", mods = "Super" , chars = "\u0015" }, # delete word/line 26 | { key = "Left", mods = "Alt" , chars = "\u001Bb" }, # one word left 27 | { key = "Right", mods = "Alt" , chars = "\u001Bf" }, # one word right 28 | # MacOS 29 | { key = "V", mods = "Command", action = "Paste" }, 30 | { key = "C", mods = "Command", action = "Copy" }, 31 | { key = "Q", mods = "Command", action = "Quit" }, 32 | { key = "W", mods = "Command", chars = "\u001Bw" }, # unmap Quit 33 | { key = "Left", mods = "Command", chars = "\u001BOH", mode = "AppCursor" }, # Home 34 | { key = "Right", mods = "Command", chars = "\u001BOF", mode = "AppCursor" }, # End 35 | ] 36 | 37 | [mouse] 38 | hide_when_typing = false 39 | 40 | [[mouse.bindings]] 41 | action = "ExpandSelection" 42 | mouse = "Right" 43 | 44 | [[mouse.bindings]] 45 | action = "ExpandSelection" 46 | mods = "Control" 47 | mouse = "Right" 48 | 49 | [[mouse.bindings]] 50 | action = "PasteSelection" 51 | mode = "~Vi" 52 | mouse = "Middle" 53 | 54 | [scrolling] 55 | history = 10000 56 | 57 | [selection] 58 | save_to_clipboard = true 59 | 60 | [window] 61 | dynamic_title = true 62 | title = "alacritty" 63 | 64 | [window.class] 65 | general = "alacritty" 66 | instance = "alacritty" 67 | 68 | [window.padding] 69 | x = 5 70 | y = 5 71 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/sniprun.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | require("sniprun").setup { 5 | -- selected_interpreters = {}, --# use those instead of the default for the current filetype 6 | repl_enable = {}, --# enable REPL-like behavior for the given interpreters 7 | -- repl_disable = {}, --# disable REPL-like behavior for the given interpreters 8 | 9 | interpreter_options = { --# intepreter-specific options, see docs / :SnipInfo 10 | GFM_original = { 11 | use_on_filetypes = { "markdown.pandoc" }, --# the 'use_on_filetypes' configuration key is 12 | --# available for every interpreter 13 | }, 14 | }, 15 | 16 | --# you can combo different display modes as desired 17 | display = { 18 | -- "Classic", --# display results in the command-line area 19 | -- "VirtualTextOk", --# display ok results as virtual text (multiline is shortened) 20 | 21 | "VirtualTextErr", --# display error results as virtual text 22 | "TempFloatingWindow", --# display results in a floating window 23 | -- "LongTempFloatingWindow", --# same as above, but only long results. To use with VirtualText__ 24 | -- "Terminal", --# display results in a vertical split 25 | -- "TerminalWithCode", --# display results and code history in a vertical split 26 | -- "NvimNotify", --# display with the nvim-notify plugin 27 | -- "Api" --# return output to a programming interface 28 | }, 29 | 30 | --# You can use the same keys to customize whether a sniprun producing 31 | --# no output should display nothing or '(no output)' 32 | show_no_output = { 33 | "Classic", 34 | "TempFloatingWindow", --# implies LongTempFloatingWindow, which has no effect on its own 35 | }, 36 | 37 | --# miscellaneous compatibility/adjustement settings 38 | inline_messages = 0, --# inline_message (0/1) is a one-line way to display messages 39 | --# to workaround sniprun not being able to display anything 40 | 41 | borders = "single", --# display borders around floating windows 42 | --# possible values are 'none', 'single', 'double', or 'shadow' 43 | live_mode_toggle = "off", --# live mode toggle, see Usage - Running for more info 44 | } 45 | end 46 | 47 | return M 48 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/dashboard.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local scratch_file = vim.fn.stdpath "config" .. "/lua/scratch.lua" 4 | 5 | local header = { 6 | type = "text", 7 | val = { 8 | "", 9 | "", 10 | " ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗", 11 | " ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║", 12 | " ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║", 13 | " ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║", 14 | " ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║", 15 | " ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝", 16 | "", 17 | "", 18 | "", 19 | }, 20 | opts = { 21 | position = "center", 22 | hl = "String", 23 | }, 24 | } 25 | 26 | local footer = { 27 | type = "text", 28 | -- val = {}, 29 | opts = { 30 | position = "center", 31 | hl = "Number", 32 | }, 33 | } 34 | 35 | local buttons = { 36 | entries = { 37 | { "SPC f f", "󰈞 Find File", "Telescope find_files" }, 38 | { "SPC f r", " Recently Used Files", "Telescope oldfiles" }, 39 | { "SPC f l", " Find Word", "Telescope live_grep" }, 40 | { "SPC f j", " Recent Places", "Telescope zoxide list" }, 41 | { "SPC P", " Recent Projects", "Telescope projects" }, 42 | { "SPC e", " New File", "ene!" }, 43 | { "SPC R", "󰀘 Load Session", "SessionLoad" }, 44 | { "SPC p", " Plugins ", "edit ~/.config/nvim/lua/user/plugins.lua" }, 45 | { "SPC s", " Scratch", "edit " .. scratch_file .. "" }, 46 | }, 47 | } 48 | 49 | local section = { 50 | header = header, 51 | footer = footer, 52 | buttons = buttons, 53 | } 54 | 55 | function M.setup() 56 | local alpha = require "alpha" 57 | local dashboard = require "alpha.themes.dashboard" 58 | 59 | dashboard.section.buttons.val = {} 60 | 61 | for _, entry in pairs(section.buttons.entries) do 62 | local button = require("alpha.themes.dashboard").button 63 | table.insert(dashboard.section.buttons.val, button(entry[1], entry[2], entry[3])) 64 | end 65 | 66 | dashboard.section.header.val = section.header.val 67 | dashboard.section.header.opts.hl = section.header.opts.hl 68 | -- dashboard.section.footer.val = conf.footer.val 69 | alpha.setup(dashboard.config) 70 | end 71 | 72 | return M 73 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/utils.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.is_client_active(name) 4 | local clients = vim.lsp.get_active_clients() 5 | for _, client in pairs(clients) do 6 | if client.name == name then 7 | return true, client 8 | end 9 | end 10 | return false 11 | end 12 | 13 | function M.get_active_client_by_ft(filetype) 14 | local matches = {} 15 | local clients = vim.lsp.get_active_clients() 16 | for _, client in pairs(clients) do 17 | local supported_filetypes = client.config.filetypes or {} 18 | if client.name ~= "null-ls" and vim.tbl_contains(supported_filetypes, filetype) then 19 | table.insert(matches, client) 20 | end 21 | end 22 | return matches 23 | end 24 | 25 | function M.setup_document_highlight(client, bufnr) 26 | local status_ok, highlight_supported = pcall(function() 27 | return client.supports_method "textDocument/documentHighlight" 28 | end) 29 | if not status_ok or not highlight_supported then 30 | return 31 | end 32 | local group = "lsp_document_highlight" 33 | local hl_events = { "CursorHold", "CursorHoldI" } 34 | 35 | local ok, hl_autocmds = pcall(vim.api.nvim_get_autocmds, { 36 | group = group, 37 | buffer = bufnr, 38 | event = hl_events, 39 | }) 40 | 41 | if ok and #hl_autocmds > 0 then 42 | return 43 | end 44 | vim.api.nvim_create_augroup(group, { clear = false }) 45 | vim.api.nvim_create_autocmd(hl_events, { 46 | group = group, 47 | buffer = bufnr, 48 | callback = vim.lsp.buf.document_highlight, 49 | }) 50 | vim.api.nvim_create_autocmd("CursorMoved", { 51 | group = group, 52 | buffer = bufnr, 53 | callback = vim.lsp.buf.clear_references, 54 | }) 55 | end 56 | 57 | function M.get_client_capabilities(client_id) 58 | local client 59 | if not client_id then 60 | local buf_clients = vim.lsp.buf_get_clients() 61 | for _, buf_client in pairs(buf_clients) do 62 | if buf_client.name ~= "null-ls" then 63 | client = buf_client 64 | break 65 | end 66 | end 67 | else 68 | client = vim.lsp.get_client_by_id(tonumber(client_id)) 69 | end 70 | 71 | local lsp_caps = client.server_capabilities 72 | 73 | print("client id:", client.id) 74 | print("client name:", client.name) 75 | print("server capabilities:", vim.inspect(lsp_caps)) 76 | 77 | return lsp_caps 78 | end 79 | 80 | return M 81 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/telescope/custom-actions.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | M.import_entry = function(prompt_bufnr) 4 | local _, actions = pcall(require, "telescope.actions") 5 | local _, action_state = pcall(require, "telescope.actions.state") 6 | local current_picker = actions.get_current_picker(prompt_bufnr) 7 | local entry = action_state.get_selected_entry() 8 | 9 | if entry == false then 10 | return 11 | end 12 | 13 | current_picker:reset_prompt() 14 | if entry ~= nil then 15 | current_picker:set_prompt(entry.value) 16 | end 17 | end 18 | 19 | M.tmux_start_project = function() 20 | local _, action_state = pcall(require, "telescope.actions.state") 21 | local query = action_state.get_selected_entry() 22 | if query == false then 23 | return 24 | end 25 | local project_dir = query.path 26 | local project_name = string.match(project_dir, "/(%w+)$") 27 | local Job = require "plenary.job" 28 | -- local tmux_cmd = { 29 | -- command = "tmux", 30 | -- args = {"neww", "-c", project_dir, "-n", project_name, "'nvim'" }, 31 | -- } 32 | local tmux_cmd = { 33 | command = "tmuxp", 34 | args = { "load", "project", "PROJECT_DIR=" .. project_dir, "PROJECT_NAME=" .. project_name }, 35 | } 36 | Job:new(tmux_cmd):start() 37 | end 38 | 39 | M.run_builtin = function(prompt_bufnr, opts) 40 | local _, actions = pcall(require, "telescope.actions") 41 | -- make sure the options are cleanly separated 42 | local picker_opts = vim.deepcopy(opts) 43 | 44 | picker_opts.next_picker = nil 45 | picker_opts.entry_cb = nil 46 | 47 | if opts.entry_cb and type(opts.entry_cb) == "function" then 48 | picker_opts = vim.tbl_deep_extend("force", picker_opts, opts.entry_cb(prompt_bufnr, opts)) 49 | end 50 | 51 | actions.close(prompt_bufnr) 52 | 53 | -- until https://github.com/nvim-telescope/telescope.nvim/pull/1600 54 | -- vim.schedule(function() 55 | -- vim.cmd [[startinsert!]] 56 | -- end) 57 | 58 | if string.match(opts.next_picker, " : ") then 59 | -- Call appropriate function from extensions 60 | local split_string = vim.split(opts.next_picker, " : ") 61 | local ext = split_string[1] 62 | local func = split_string[2] 63 | require("telescope").extensions[ext][func](picker_opts) 64 | else 65 | -- Call appropriate telescope builtin 66 | require("telescope.builtin")[opts.next_picker](picker_opts) 67 | end 68 | end 69 | 70 | return M 71 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/providers/lua_ls.lua: -------------------------------------------------------------------------------- 1 | local default_workspace = { 2 | library = { 3 | vim.fn.expand "$VIMRUNTIME", 4 | require("neodev.config").types(), 5 | "${3rd}/busted/library", 6 | "${3rd}/luassert/library", 7 | "${3rd}/luv/library", 8 | }, 9 | 10 | maxPreload = 10000, 11 | preloadFileSize = 10000, 12 | } 13 | 14 | local add_packages_to_workspace = function(packages, config) 15 | -- config.settings.Lua = config.settings.Lua or { workspace = default_workspace } 16 | local runtimedirs = vim.api.nvim__get_runtime({ "lua" }, true, { is_lua = true }) 17 | local workspace = config.settings.Lua.workspace 18 | for _, v in pairs(runtimedirs) do 19 | for _, pack in ipairs(packages) do 20 | if v:match(pack) and not vim.tbl_contains(workspace.library, v) then 21 | table.insert(workspace.library, v) 22 | end 23 | end 24 | end 25 | end 26 | 27 | local lspconfig = require "lspconfig" 28 | 29 | local make_on_new_config = function(on_new_config, _) 30 | return lspconfig.util.add_hook_before(on_new_config, function(new_config, _) 31 | local server_name = new_config.name 32 | 33 | if server_name ~= "lua_ls" then 34 | return 35 | end 36 | local plugins = { "plenary.nvim", "telescope.nvim", "nvim-treesitter", "LuaSnip" } 37 | add_packages_to_workspace(plugins, new_config) 38 | end) 39 | end 40 | 41 | lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, { 42 | on_new_config = make_on_new_config(lspconfig.util.default_config.on_new_config), 43 | }) 44 | 45 | local opts = { 46 | settings = { 47 | Lua = { 48 | telemetry = { enable = false }, 49 | runtime = { 50 | version = "LuaJIT", 51 | special = { 52 | reload = "require", 53 | require_clean = "require", 54 | }, 55 | path = { 56 | -- paths for meta/3rd libraries 57 | "library/?.lua", 58 | "library/?/init.lua", 59 | -- Neovim lua files, config and plugins 60 | "lua/?.lua", 61 | "lua/?/init.lua", 62 | -- default 63 | "./?.lua", 64 | "./init.lua", 65 | }, 66 | -- pathStrict = true, -- seems broken for now 67 | }, 68 | diagnostics = { 69 | globals = { "vim", "lvim", "reload" }, 70 | }, 71 | workspace = default_workspace, 72 | }, 73 | }, 74 | } 75 | 76 | return opts 77 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/handlers.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | local signs = { 5 | { name = "DiagnosticSignError", text = "" }, 6 | { name = "DiagnosticSignWarn", text = "" }, 7 | { name = "DiagnosticSignHint", text = "󰌶" }, 8 | { name = "DiagnosticSignInfo", text = "" }, 9 | } 10 | 11 | for _, sign in ipairs(signs) do 12 | vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) 13 | end 14 | 15 | local config = { 16 | virtual_text = false, 17 | signs = signs, 18 | underline = true, 19 | update_in_insert = true, 20 | severity_sort = true, 21 | float = { 22 | focusable = true, 23 | style = "minimal", 24 | border = "rounded", 25 | source = "always", 26 | header = "", 27 | prefix = "", 28 | suffix = nil, 29 | format = nil, 30 | }, 31 | } 32 | 33 | vim.diagnostic.config(config) 34 | local float_opts = { 35 | focusable = false, 36 | style = "minimal", 37 | border = "rounded", 38 | } 39 | vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, float_opts) 40 | vim.lsp.handlers["textDocument/signatureHelp"] = 41 | vim.lsp.with(vim.lsp.handlers.signature_help, float_opts) 42 | 43 | -- Get a reference to the original signs handler 44 | local orig_signs_handler = vim.diagnostic.handlers.signs 45 | vim.diagnostic.handlers.signs = { 46 | show = function(ns, bufnr, diagnostics, opts) 47 | -- diagnostics from the whole buffer, not just those passed to the handler 48 | -- local diagnostics = vim.diagnostic.get(bufnr) -- disabled because slow! 49 | 50 | -- perf: avoid showing too many signs 51 | if #diagnostics > 90 then 52 | return 53 | end 54 | 55 | -- Find the "worst" diagnostic per line 56 | local max_severity_per_line = {} 57 | for _, d in pairs(diagnostics) do 58 | local m = max_severity_per_line[d.lnum] 59 | if not m or d.severity < m.severity then 60 | max_severity_per_line[d.lnum] = d 61 | end 62 | end 63 | 64 | -- Pass the filtered diagnostics (with our custom namespace) to 65 | -- the original handler 66 | local filtered_diagnostics = vim.tbl_values(max_severity_per_line) 67 | orig_signs_handler.show(ns, bufnr, filtered_diagnostics, opts) 68 | end, 69 | hide = function(ns, bufnr) 70 | orig_signs_handler.hide(ns, bufnr) 71 | end, 72 | } 73 | end 74 | 75 | return M 76 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/comment.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup() 4 | -- pre_hook = function(_ctx) 5 | -- return require("ts_context_commentstring.internal").calculate_commentstring() 6 | -- end 7 | local opts = { 8 | ---Add a space b/w comment and the line 9 | ---@type boolean|fun():boolean 10 | padding = true, 11 | 12 | ---Whether the cursor should stay at its position 13 | ---NOTE: This only affects NORMAL mode mappings and doesn't work with dot-repeat 14 | ---@type boolean 15 | sticky = true, 16 | 17 | ---Lines to be ignored while comment/uncomment. 18 | ---Could be a regex string or a function that returns a regex string. 19 | ---Example: Use '^$' to ignore empty lines 20 | ---@type string|fun():string 21 | ignore = nil, 22 | 23 | ---LHS of toggle mappings in NORMAL + VISUAL mode 24 | ---@type table 25 | toggler = { 26 | ---Line-comment toggle keymap 27 | line = "gcc", 28 | ---Block-comment toggle keymap 29 | block = "gbc", 30 | }, 31 | 32 | ---LHS of operator-pending mappings in NORMAL + VISUAL mode 33 | ---@type table 34 | opleader = { 35 | ---Line-comment keymap 36 | line = "gc", 37 | ---Block-comment keymap 38 | block = "gb", 39 | }, 40 | 41 | ---LHS of extra mappings 42 | ---@type table 43 | extra = { 44 | ---Add comment on the line above 45 | above = "gcO", 46 | ---Add comment on the line below 47 | below = "gco", 48 | ---Add comment at the end of line 49 | eol = "gcA", 50 | }, 51 | 52 | ---Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode 53 | ---@type table 54 | mappings = { 55 | ---Operator-pending mapping 56 | ---Includes `gcc`, `gbc`, `gc[count]{motion}` and `gb[count]{motion}` 57 | ---NOTE: These mappings can be changed individually by `opleader` and `toggler` config 58 | basic = true, 59 | ---Extra mapping 60 | ---Includes `gco`, `gcO`, `gcA` 61 | extra = true, 62 | }, 63 | 64 | ---Pre-hook, called before commenting the line 65 | ---@type fun(ctx: Ctx):string 66 | pre_hook = nil, 67 | 68 | ---Post-hook, called after commenting is done 69 | ---@type fun(ctx: Ctx) 70 | post_hook = nil, 71 | } 72 | 73 | local nvim_comment = require "Comment" 74 | nvim_comment.setup(opts) 75 | 76 | -- local ft = require "Comment.ft" 77 | -- ft.set("c", {"///%s", '/*%s*/'}) 78 | end 79 | 80 | return M 81 | -------------------------------------------------------------------------------- /.config/lf/lf.zsh: -------------------------------------------------------------------------------- 1 | export LF_ICONS="\ 2 | di=:\ 3 | fi=:\ 4 | ln=:\ 5 | or=:\ 6 | ex=:\ 7 | *.vimrc=:\ 8 | *.viminfo=:\ 9 | *.gitignore=:\ 10 | *.c=:\ 11 | *.cc=:\ 12 | *.clj=:\ 13 | *.coffee=:\ 14 | *.cpp=:\ 15 | *.css=:\ 16 | *.d=:\ 17 | *.dart=:\ 18 | *.erl=:\ 19 | *.exs=:\ 20 | *.fs=:\ 21 | *.go=:\ 22 | *.h=:\ 23 | *.hh=:\ 24 | *.hpp=:\ 25 | *.hs=:\ 26 | *.html=:\ 27 | *.java=:\ 28 | *.jl=:\ 29 | *.js=:\ 30 | *.json=:\ 31 | *.lua=:\ 32 | *.md=:\ 33 | *.php=:\ 34 | *.pl=:\ 35 | *.pro=:\ 36 | *.py=:\ 37 | *.rb=:\ 38 | *.rs=:\ 39 | *.scala=:\ 40 | *.ts=:\ 41 | *.vim=:\ 42 | *.cmd=:\ 43 | *.ps1=:\ 44 | *.sh=:\ 45 | *.bash=:\ 46 | *.zsh=:\ 47 | *.fish=:\ 48 | *.tar=:\ 49 | *.tgz=:\ 50 | *.arc=:\ 51 | *.arj=:\ 52 | *.taz=:\ 53 | *.lha=:\ 54 | *.lz4=:\ 55 | *.lzh=:\ 56 | *.lzma=:\ 57 | *.tlz=:\ 58 | *.txz=:\ 59 | *.tzo=:\ 60 | *.t7z=:\ 61 | *.zip=:\ 62 | *.z=:\ 63 | *.dz=:\ 64 | *.gz=:\ 65 | *.lrz=:\ 66 | *.lz=:\ 67 | *.lzo=:\ 68 | *.xz=:\ 69 | *.zst=:\ 70 | *.tzst=:\ 71 | *.bz2=:\ 72 | *.bz=:\ 73 | *.tbz=:\ 74 | *.tbz2=:\ 75 | *.tz=:\ 76 | *.deb=:\ 77 | *.rpm=:\ 78 | *.jar=:\ 79 | *.war=:\ 80 | *.ear=:\ 81 | *.sar=:\ 82 | *.rar=:\ 83 | *.alz=:\ 84 | *.ace=:\ 85 | *.zoo=:\ 86 | *.cpio=:\ 87 | *.7z=:\ 88 | *.rz=:\ 89 | *.cab=:\ 90 | *.wim=:\ 91 | *.swm=:\ 92 | *.dwm=:\ 93 | *.esd=:\ 94 | *.jpg=:\ 95 | *.jpeg=:\ 96 | *.mjpg=:\ 97 | *.mjpeg=:\ 98 | *.gif=:\ 99 | *.bmp=:\ 100 | *.pbm=:\ 101 | *.pgm=:\ 102 | *.ppm=:\ 103 | *.tga=:\ 104 | *.xbm=:\ 105 | *.xpm=:\ 106 | *.tif=:\ 107 | *.tiff=:\ 108 | *.png=:\ 109 | *.svg=:\ 110 | *.svgz=:\ 111 | *.mng=:\ 112 | *.pcx=:\ 113 | *.mov=:\ 114 | *.mpg=:\ 115 | *.mpeg=:\ 116 | *.m2v=:\ 117 | *.mkv=:\ 118 | *.webm=:\ 119 | *.ogm=:\ 120 | *.mp4=:\ 121 | *.m4v=:\ 122 | *.mp4v=:\ 123 | *.vob=:\ 124 | *.qt=:\ 125 | *.nuv=:\ 126 | *.wmv=:\ 127 | *.asf=:\ 128 | *.rm=:\ 129 | *.rmvb=:\ 130 | *.flc=:\ 131 | *.avi=:\ 132 | *.fli=:\ 133 | *.flv=:\ 134 | *.gl=:\ 135 | *.dl=:\ 136 | *.xcf=:\ 137 | *.xwd=:\ 138 | *.yuv=:\ 139 | *.cgm=:\ 140 | *.emf=:\ 141 | *.ogv=:\ 142 | *.ogx=:\ 143 | *.aac=:\ 144 | *.au=:\ 145 | *.flac=:\ 146 | *.m4a=:\ 147 | *.mid=:\ 148 | *.midi=:\ 149 | *.mka=:\ 150 | *.mp3=:\ 151 | *.mpc=:\ 152 | *.ogg=:\ 153 | *.ra=:\ 154 | *.wav=:\ 155 | *.oga=:\ 156 | *.opus=:\ 157 | *.spx=:\ 158 | *.xspf=:\ 159 | *.pdf=:\ 160 | *.nix=:\ 161 | " 162 | 163 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eou pipefail 3 | 4 | function check_reqs() { 5 | local reqs=( 6 | git 7 | zsh 8 | nvim 9 | ) 10 | for req in "${reqs[@]}"; do 11 | if ! command -v "$req"; then 12 | echo ">>> ERROR: missing requirement: $req" 13 | echo ">>> please install and re-run the script again" && exit 1 14 | fi 15 | done 16 | } 17 | 18 | function setup_default_exports() { 19 | 20 | export XDG_CACHE_HOME="$HOME/.cache" 21 | export XDG_CONFIG_HOME="$HOME/.config" 22 | export XDG_DATA_HOME="$HOME/.local/share" 23 | export XDG_STATE_HOME="$HOME/.local/state" 24 | 25 | export LANG=en_US.UTF-8 26 | export LANGUAGE=en_US.UTF-8 27 | 28 | export EDITOR=nvim 29 | 30 | export ZDOTDIR="$HOME/.config/zsh" 31 | 32 | export DOTBARE_DIR="$HOME/.dtf.git" 33 | export DOTBARE_TREE="$HOME" 34 | export DOTBARE_INSTALL_PREFIX="$XDG_DATA_HOME/zsh/plugins/dotbare" 35 | 36 | export TPM_DIR="$XDG_DATA_HOME/tmux/plugins/tpm" 37 | } 38 | 39 | function setup_xdg() { 40 | mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" \ 41 | "$XDG_CACHE_HOME" "$XDG_STATE_HOME" 42 | } 43 | 44 | function setup_dotfiles() { 45 | 46 | check_reqs 47 | setup_default_exports 48 | setup_xdg 49 | 50 | echo "Fetching dependencies.." 51 | 52 | if [ ! -d "$DOTBARE_INSTALL_PREFIX" ]; then 53 | git clone --depth=1 https://github.com/kazhala/dotbare "$DOTBARE_INSTALL_PREFIX" 54 | fi 55 | 56 | if [ ! -d "$HOME/.dtf.git" ]; then 57 | "$DOTBARE_INSTALL_PREFIX/dotbare" finit -u https://github.com/kylo252/dotfiles.git 58 | ln -sf "$XDG_CONFIG_HOME/git/hooks/dots_post_commit" "$DOTBARE_DIR/hooks/pre-push" 59 | chmod +x "$DOTBARE_DIR/hooks/pre-push" 60 | fi 61 | 62 | local znap_dir="$XDG_DATA_HOME/zsh/plugins/znap" 63 | if [ ! -d "$znap_dir" ]; then 64 | echo 'setting up zsh ...' 65 | git clone --depth=1 https://github.com/marlonrichert/zsh-snap "$znap_dir" 66 | zsh -c "source $ZDOTDIR/plugins.zsh" 67 | fi 68 | 69 | if [ ! -d "$XDG_DATA_HOME/fzf" ]; then 70 | git clone --depth=1 https://github.com/junegunn/fzf "$XDG_DATA_HOME/fzf" 71 | fi 72 | 73 | echo "setting up fzf .." 74 | "$XDG_DATA_HOME/fzf/install" --all --xdg --completion --no-update-rc 75 | 76 | echo "setting up tmux.." 77 | if [ ! -d "$TPM_DIR" ]; then 78 | git clone --depth=1 https://github.com/tmux-plugins/tpm "$TPM_DIR" 79 | fi 80 | echo "setup complete!" 81 | } 82 | 83 | setup_dotfiles 84 | 85 | unset -f check_reqs 86 | unset -f setup_dotfiles 87 | unset -f setup_default_exports 88 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/tmux.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.set_tmux_win_title(pattern) 4 | local bufnr = vim.api.nvim_get_current_buf() 5 | local buftype = vim.api.nvim_get_option_value("buftype", { buf = bufnr }) 6 | if not buftype or buftype == "nofile" or buftype == "quickfix" or buftype == "help" then 7 | return 8 | end 9 | local title = vim.fn.expand(pattern) 10 | vim.opt.titlestring = title 11 | local Job = require "plenary.job" 12 | Job:new({ 13 | command = "tmux", 14 | args = { "rename-window", title }, 15 | }):start() 16 | end 17 | 18 | function M.setup() 19 | require("tmux").setup { 20 | navigation = { 21 | -- cycles to opposite pane while navigating into the border 22 | cycle_navigation = true, 23 | 24 | -- enables default keybindings (C-hjkl) for normal mode 25 | enable_default_keybindings = true, 26 | 27 | -- prevents unzoom tmux when navigating beyond vim border 28 | persist_zoom = true, 29 | }, 30 | copy_sync = { 31 | -- enables copy sync. by default, all registers are synchronized. 32 | -- to control which registers are synced, see the `sync_*` options. 33 | enable = false, 34 | 35 | -- ignore specific tmux buffers e.g. buffer0 = true to ignore the 36 | -- first buffer or named_buffer_name = true to ignore a named tmux 37 | -- buffer with name named_buffer_name :) 38 | ignore_buffers = { empty = false }, 39 | 40 | -- TMUX >= 3.2: all yanks (and deletes) will get redirected to system 41 | -- clipboard by tmux 42 | redirect_to_clipboard = false, 43 | 44 | -- offset controls where register sync starts 45 | -- e.g. offset 2 lets registers 0 and 1 untouched 46 | register_offset = 0, 47 | 48 | -- overwrites vim.g.clipboard to redirect * and + to the system 49 | -- clipboard using tmux. If you sync your system clipboard without tmux, 50 | -- disable this option! 51 | sync_clipboard = true, 52 | 53 | -- synchronizes registers *, +, unnamed, and 0 till 9 with tmux buffers. 54 | sync_registers = true, 55 | 56 | -- syncs deletes with tmux clipboard as well, it is adviced to 57 | -- do so. Nvim does not allow syncing registers 0 and 1 without 58 | -- overwriting the unnamed register. Thus, ddp would not be possible. 59 | sync_deletes = true, 60 | 61 | -- syncs the unnamed register with the first buffer entry from tmux. 62 | sync_unnamed = true, 63 | }, 64 | resize = { 65 | -- enables default keybindings (A-hjkl) for normal mode 66 | enable_default_keybindings = true, 67 | }, 68 | } 69 | end 70 | 71 | return M 72 | -------------------------------------------------------------------------------- /.config/zsh/plugins.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | # load custom modules 4 | source "$XDG_CONFIG_HOME/fzf/fzf.zsh" 5 | 6 | source "$XDG_CONFIG_HOME/lf/lf.zsh" 7 | 8 | source "$XDG_DATA_HOME/zsh/plugins/znap/znap.zsh" 9 | 10 | if [ -d "/opt/homebrew" ]; then 11 | export PATH="/opt/homebrew/opt/python/libexec/bin:$PATH" 12 | export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" 13 | znap eval brew "/opt/homebrew/bin/brew shellenv" 14 | fi 15 | 16 | znap source kazhala/dotbare 17 | znap source romkatv/powerlevel10k 18 | znap source zdharma-continuum/fast-syntax-highlighting 19 | znap source zsh-users/zsh-autosuggestions 20 | znap source zsh-users/zsh-completions 21 | znap source Aloxaf/fzf-tab 22 | znap source reegnz/jq-zsh-plugin 23 | znap source RobSis/zsh-completion-generator 24 | znap source soimort/translate-shell 25 | 26 | znap function _pip_completion pip 'eval "$(pip completion --zsh)"' 27 | compctl -K _pip_completion pip 28 | 29 | znap eval zoxide 'zoxide init zsh' 30 | 31 | if command -v vivid >/dev/null; then 32 | export LS_COLORS="$(vivid -m 24-bit generate one-dark)" 33 | fi 34 | 35 | # broken with znap since /run/user would change 36 | eval "$(fnm env --shell=zsh)" 37 | 38 | autoload -Uz kp 39 | 40 | if [[ "$TERM" == "linux" ]]; then 41 | export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=7" 42 | else 43 | export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=240,italic,underline" 44 | fi 45 | 46 | export ZSH_AUTOSUGGEST_USE_ASYNC="ON" 47 | export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 48 | 49 | ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS+=(vi-add-next) 50 | export ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS 51 | 52 | # turn off git maintenance 53 | zstyle ':znap:*:*' git-maintenance off 54 | # disable sort when completing `git checkout` 55 | zstyle ':completion:*:git-checkout:*' sort false 56 | # set descriptions format to enable group support 57 | zstyle ':completion:*:descriptions' format '[%d]' 58 | # set list-colors to enable filename colorizing 59 | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} 60 | # preview directory's content with exa when completing cd 61 | zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --only-dirs --color=always $realpath 2>/dev/null || ls $realpath' 62 | # switch group using `,` and `.` 63 | zstyle ':fzf-tab:*' switch-group '[' ']' 64 | 65 | # https://wiki.archlinux.org/title/zsh#Persistent_rehash 66 | zstyle ':completion:*' rehash true 67 | 68 | # znap eval luarock "luarocks path --no-bin 2>/dev/null" 69 | 70 | znap function _vcpkg vcpkg 'source $HOME/.config/vcpkg/hook.sh' 71 | 72 | compctl -K _vcpkg vcpkg 73 | 74 | [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ] && source "$HOME/.nix-profile/etc/profile.d/nix.sh" 75 | -------------------------------------------------------------------------------- /.config/alacritty/colors/onedark.yaml: -------------------------------------------------------------------------------- 1 | colors: 2 | # Default colors 3 | primary: 4 | background: '#1e2127' 5 | foreground: '#abb2bf' 6 | 7 | # Bright and dim foreground colors 8 | # 9 | # The dimmed foreground color is calculated automatically if it is not present. 10 | # If the bright foreground color is not set, or `draw_bold_text_with_bright_colors` 11 | # is `false`, the normal foreground color will be used. 12 | #dim_foreground: '#9a9a9a' 13 | bright_foreground: '#e6efff' 14 | 15 | # Cursor colors 16 | # 17 | # Colors which should be used to draw the terminal cursor. If these are unset, 18 | # the cursor color will be the inverse of the cell color. 19 | #cursor: 20 | # text: '#000000' 21 | # cursor: '#ffffff' 22 | 23 | # Normal colors 24 | normal: 25 | black: '#1e2127' 26 | red: '#e06c75' 27 | green: '#98c379' 28 | yellow: '#d19a66' 29 | blue: '#61afef' 30 | magenta: '#c678dd' 31 | cyan: '#56b6c2' 32 | white: '#828791' 33 | 34 | # Bright colors 35 | bright: 36 | black: '#5c6370' 37 | red: '#e06c75' 38 | green: '#98c379' 39 | yellow: '#d19a66' 40 | blue: '#61afef' 41 | magenta: '#c678dd' 42 | cyan: '#56b6c2' 43 | white: '#e6efff' 44 | 45 | # Dim colors 46 | # 47 | # If the dim colors are not set, they will be calculated automatically based 48 | # on the `normal` colors. 49 | dim: 50 | black: '#1e2127' 51 | red: '#e06c75' 52 | green: '#98c379' 53 | yellow: '#d19a66' 54 | blue: '#61afef' 55 | magenta: '#c678dd' 56 | cyan: '#56b6c2' 57 | white: '#828791' 58 | 59 | # Indexed Colors 60 | # 61 | # The indexed colors include all colors from 16 to 256. 62 | # When these are not set, they're filled with sensible defaults. 63 | #indexed_colors: 64 | # - { index: 16, color: '#000000' } 65 | 66 | indexed_colors: 67 | - { index: 16, color: '#d19a66' } 68 | - { index: 17, color: '#f65866' } 69 | 70 | # Cursor colors 71 | # 72 | # Colors which should be used to draw the terminal cursor. If these are unset, 73 | # the cursor color will be the inverse of the cell color. 74 | # cursor: 75 | # text: '#191919' 76 | # cursor: '#d8dee9' 77 | 78 | vi_mode_cursor: 79 | text: CellBackground 80 | cursor: CellForeground 81 | 82 | search: 83 | # Allowed values are CellForeground/CellBackground, which reference the 84 | # affected cell, or hexadecimal colors like #ff00ff. 85 | matches: 86 | foreground: '#191919' 87 | background: '#5c5d5c' 88 | focused_match: 89 | foreground: '#191919' 90 | background: '#C7C7C7' 91 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/treesitter.lua: -------------------------------------------------------------------------------- 1 | -- avoid problems with old `gcc` on RHEL7 2 | local M = {} 3 | function M.setup() 4 | --[[ attempt to enable sh ]] 5 | require("nvim-treesitter.install").compilers = { "clang", "gcc" } 6 | 7 | require("nvim-treesitter.configs").setup { 8 | ensure_installed = { "bash", "lua", "c", "cpp", "vim", "json", "yaml", "python", "comment" }, 9 | highlight = { enable = true }, 10 | indent = { enable = true, disable = { "python", "yaml" } }, 11 | autotag = { enable = true }, 12 | rainbow = { enable = false }, 13 | incremental_selection = { 14 | enable = true, 15 | }, 16 | textobjects = { 17 | select = { 18 | enable = true, 19 | -- Automatically jump forward to textobj, similar to targets.vim 20 | lookahead = true, 21 | 22 | keymaps = { 23 | -- You can use the capture groups defined in textobjects.scm 24 | ["af"] = "@function.outer", 25 | ["if"] = "@function.inner", 26 | ["ac"] = "@class.outer", 27 | ["ic"] = "@class.inner", 28 | ["ak"] = "@comment.outer", 29 | ["aa"] = "@parameter.inner", -- "ap" is already used 30 | ["ia"] = "@parameter.outer", -- "ip" is already used 31 | }, 32 | }, 33 | lsp_interop = { 34 | enable = true, 35 | border = "rounded", 36 | peek_definition_code = { 37 | ["gpof"] = "@function.outer", 38 | ["gpoc"] = "@class.outer", 39 | }, 40 | }, 41 | move = { 42 | enable = true, 43 | set_jumps = true, -- whether to set jumps in the jumplist 44 | goto_next_start = { 45 | ["]m"] = "@function.outer", 46 | ["]]"] = "@class.outer", 47 | ["]k"] = "@comment.outer", 48 | }, 49 | goto_next_end = { 50 | ["]M"] = "@function.outer", 51 | ["]["] = "@class.outer", 52 | ["]K"] = "@comment.outer", 53 | }, 54 | goto_previous_start = { 55 | ["[m"] = "@function.outer", 56 | ["[["] = "@class.outer", 57 | ["[k"] = "@comment.outer", 58 | }, 59 | goto_previous_end = { 60 | ["[M"] = "@function.outer", 61 | ["[]"] = "@class.outer", 62 | ["[K"] = "@comment.outer", 63 | }, 64 | }, 65 | }, 66 | } 67 | 68 | -- local bash_parser = vim.api.nvim_get_runtime_file("parser/bash*", false)[1] 69 | -- if not bash_parser then 70 | -- return 71 | -- end 72 | -- vim.treesitter.require_language("sh", bash_parser, false, "bash") 73 | -- assert(vim.treesitter.inspect_language "sh", "parser created") 74 | -- assert(vim.treesitter.get_parser(nil, "sh", nil), "languageTree created") 75 | -- require("nvim-treesitter.parsers").filetype_to_parsername["sh"] = "bash" 76 | end 77 | 78 | return M 79 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/terminal.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local config = { 4 | size = 20, 5 | open_mapping = [[]], 6 | hide_numbers = true, -- hide the number column in toggleterm buffers 7 | shade_filetypes = {}, 8 | shade_terminals = false, 9 | shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light 10 | start_in_insert = true, 11 | insert_mappings = true, -- whether or not the open mapping applies in insert mode 12 | persist_size = false, 13 | -- direction = 'vertical' | 'horizontal' | 'window' | 'float', 14 | direction = "float", 15 | close_on_exit = true, -- close the terminal window when the process exits 16 | shell = vim.o.shell, -- change the default shell 17 | -- This field is only relevant if direction is set to 'float' 18 | float_opts = { 19 | -- The border key is *almost* the same as 'nvim_win_open' 20 | -- see :h nvim_win_open for details on borders however 21 | -- the 'curved' border is a custom border type 22 | -- not natively supported but implemented in this plugin. 23 | -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open 24 | border = "single", 25 | -- width = , 26 | -- height = , 27 | highlights = { 28 | border = "Normal", 29 | background = "Normal", 30 | }, 31 | winblend = 0, 32 | }, 33 | execs = { 34 | { "lazygit", "gg", "lazygit", "float" }, 35 | }, 36 | } 37 | 38 | M.setup = function() 39 | local terminal = require "toggleterm" 40 | terminal.setup(config) 41 | -- setup the default terminal so it's always reachable 42 | local default_term_opts = { 43 | cmd = config.shell, 44 | keymap = config.open_mapping, 45 | label = "terminal", 46 | count = 1, 47 | direction = "horizontal", 48 | size = config.size, 49 | } 50 | 51 | M.add_exec(default_term_opts) 52 | 53 | for i, exec in pairs(config.execs) do 54 | local opts = { 55 | cmd = exec[1], 56 | keymap = exec[2], 57 | label = exec[3], 58 | count = i + 1, 59 | direction = exec[4] or config.direction, 60 | size = config.size, 61 | } 62 | 63 | M.add_exec(opts) 64 | end 65 | end 66 | 67 | M.add_exec = function(opts) 68 | local binary = opts.cmd:match "(%S+)" 69 | if vim.fn.executable(binary) ~= 1 then 70 | return 71 | end 72 | 73 | vim.keymap.set({ "n", "t" }, opts.keymap, function() 74 | require("core.terminal")._exec_toggle(opts) 75 | end, { noremap = true, silent = true, desc = opts.label }) 76 | end 77 | 78 | M._exec_toggle = function(opts) 79 | local Terminal = require("toggleterm.terminal").Terminal 80 | local term = Terminal:new { cmd = opts.cmd, count = opts.count, direction = opts.direction } 81 | term:toggle(opts.size or config.size, opts.direction) 82 | end 83 | 84 | return M 85 | -------------------------------------------------------------------------------- /.config/zsh/.zshrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | # zmodload zsh/zprof 4 | 5 | # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc. 6 | # Initialization code that may require console input (password prompts, [y/n] 7 | # confirmations, etc.) must go above this block; everything else may go below. 8 | # There's a problem with starting instant-prompt and creating a new tmux session 9 | if [ -z "$VIRTUAL_ENV" ] && [ -n "$TMUX" ]; then 10 | if [[ -r "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then 11 | source "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh" 12 | fi 13 | fi 14 | 15 | source "$XDG_CONFIG_HOME/zsh/.p10k.lean.zsh" 16 | 17 | function __setup_x11() { 18 | if [ -n "$SSH_CONNECTION" ]; then 19 | return 20 | fi 21 | # How to check if WSL1/2 22 | # https://github.com/microsoft/WSL/issues/4555#issuecomment-609908080 23 | if [ -d /run/WSL ] && [ ! -d /mnt/wslg ] ; then 24 | # How to set up working X11 forwarding on WSL2 25 | # https://stackoverflow.com/a/61110604 26 | DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0 27 | # PULSE_SERVER=tcp:$(echo /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}') #GWSL 28 | export DISPLAY 29 | source "$ZDOTDIR/utils/ssh-agent.zsh" 30 | fi 31 | } 32 | 33 | function __setup_history() { 34 | setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. 35 | setopt HIST_FCNTL_LOCK # Use system’s fcntl call where available (better performance) 36 | setopt HIST_IGNORE_SPACE # Do not record an entry starting with a space. 37 | setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. 38 | setopt HIST_VERIFY # Do not execute immediately upon history expansion. 39 | setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. 40 | setopt SHARE_HISTORY # Share history between all sessions. 41 | } 42 | 43 | function __setup_defaults() { 44 | setopt NO_BEEP # disable the goddamn beep! 45 | # setopt CORRECT # Command auto-correction 46 | setopt IGNORE_EOF # Prevent accidental C-d from exiting shell 47 | setopt INTERACTIVE_COMMENTS # Allow comments, even in interactive shells 48 | setopt LIST_PACKED # Make completion lists more densely packed 49 | 50 | # https://unix.stackexchange.com/q/48577 51 | typeset -g WORDCHARS=${WORDCHARS/\//} 52 | } 53 | 54 | setup_functions=( 55 | __setup_history 56 | __setup_defaults 57 | __setup_x11 58 | ) 59 | 60 | for func in "${setup_functions[@]}"; do 61 | "$func" 62 | unset -f "$func" 63 | done 64 | unset setup_functions 65 | 66 | source "$ZDOTDIR/aliases.zsh" 67 | source "$ZDOTDIR/functions.zsh" 68 | source "$ZDOTDIR/completions.zsh" 69 | source "$ZDOTDIR/keymaps.zsh" 70 | source "$ZDOTDIR/plugins.zsh" 71 | 72 | # zprof 73 | -------------------------------------------------------------------------------- /.config/lf/preview: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | file="$1" 4 | 5 | if ! rg "$file" "$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 2>/dev/null; then 6 | offset=1 7 | else 8 | # Retrieve the current preview offset. 9 | offset="$(rg "(\d) $file" --only-matching --no-line-number --replace '$1' "$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 2>/dev/null)" 10 | fi 11 | 12 | image_preview="$HOME/.config/lf/image" 13 | # Clear the last preview (if any) 14 | # "$image_preview" clear 15 | 16 | # Calculate where the image should be placed on the screen. 17 | num=$(printf "%0.f\n" "$(echo "$(tput cols) / 2" | bc)") 18 | numb=$(printf "%0.f\n" "$(echo "$(tput cols) - $num - 1" | bc)") 19 | numc=$(printf "%0.f\n" "$(echo "$(tput lines) - 2" | bc)") 20 | 21 | case "$file" in 22 | *.tgz | *.tar.gz) tar tzf "$file" ;; 23 | *.tar.bz2 | *.tbz2) tar tjf "$file" ;; 24 | *.tar.txz | *.txz) xz --list "$file" ;; 25 | *.tar) tar tf "$file" ;; 26 | *.zip | *.jar | *.war | *.ear | *.oxt) unzip -l "$file" ;; 27 | *.rar) unrar l "$file" ;; 28 | *.7z) 7z l "$file" ;; 29 | *.[1-8]) man "$file" | col -b ;; 30 | *.o) nm "$file" | less ;; 31 | *.torrent) transmission-show "$file" ;; 32 | *.iso) iso-info --no-header -l "$file" ;; 33 | *odt,*.ods,*.odp,*.sxw) odt2txt "$file" ;; 34 | *.doc) catdoc "$file" ;; 35 | *.docx) docx2txt "$file" - ;; 36 | *.csv) bat "$file" | sed s/,/\\n/g ;; 37 | *.pdf) 38 | CACHE=$(mktemp /tmp/thumbcache.XXXXX) 39 | pdftoppm -png -f 1 -singlefile "$file" "$CACHE" 40 | "$image_preview" draw "$CACHE.png" "$num" 1 "$numb" "$numc" 41 | ;; 42 | *.epub) 43 | CACHE=$(mktemp /tmp/thumbcache.XXXXX) 44 | epub-thumbnailer "$file" "$CACHE" 1024 45 | "$image_preview" draw "$CACHE" "$num" 1 "$numb" "$numc" 46 | ;; 47 | *.bmp | *.jpg | *.jpeg | *.png | *.xpm) 48 | "$image_preview" draw "$file" "$num" 1 "$numb" "$numc" 49 | ;; 50 | *.wav | *.mp3 | *.flac | *.m4a | *.wma | *.ape | *.ac3 | *.og[agx] | *.spx | *.opus | *.as[fx]) exiftool "$file" ;; 51 | *.avi | *.mp4 | *.wmv | *.dat | *.3gp | *.ogv | *.mkv | *.mpg | *.mpeg | *.vob | *.fl[icv] | *.m2v | *.mov | *.webm | *.ts | *.mts | *.m4v | *.r[am] | *.qt | *.divx) 52 | CACHE=$(mktemp /tmp/thumbcache.XXXXX) 53 | ffmpegthumbnailer -i "$file" -o "$CACHE" -s 0 54 | "$image_preview" draw "$CACHE" "$num" 1 "$numb" "$numc" 55 | ;; 56 | *.md) glow -s dark "$file" | bat ;; 57 | *) 58 | case $(file --mime-type "$file" -b) in 59 | text/*) 60 | unset COLORTERM 61 | bat --pager='less -Rf' --color=always --number --wrap auto --paging=always --line-range "${offset}:" "$file" 62 | ;; 63 | application/json) 64 | jq --color-output '.' "$file" 65 | ;; 66 | *) 67 | cat < message 90 | silent execute a:cmd 91 | redir END 92 | if empty(message) 93 | echoerr "no output" 94 | else 95 | " use "new" instead of "tabnew" below if you prefer split windows instead of tabs 96 | new 97 | nnoremap q :close 98 | setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted nomodified 99 | silent put=message 100 | endif 101 | endfunction 102 | command! -nargs=+ -complete=command Dump call Dump() 103 | ]] 104 | 105 | return M 106 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/sessions.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local uv = vim.loop 4 | local join_paths = require("user.utils").join_paths 5 | local path_sep = uv.os_uname().version:match "Windows" and "\\" or "/" 6 | local fnameescape = vim.fn.fnameescape 7 | local fnamemodify = vim.fn.fnamemodify 8 | 9 | local function is_directory(filename) 10 | local stat = vim.loop.fs_stat(filename) 11 | return stat and stat.type == "directory" or false 12 | end 13 | 14 | local default_session_name = function() 15 | -- get the cwd but strip the homeprefix and replace the path_sep with underscores 16 | local def_name = fnamemodify(vim.loop.cwd(), ":~:?") 17 | def_name = def_name:gsub("~" .. path_sep, ""):gsub(path_sep, "__") 18 | return def_name 19 | end 20 | 21 | local defaults = { 22 | -- directory where session files are saved 23 | dir = join_paths(vim.fn.stdpath "cache", "sessions"), 24 | -- sessionoptions used for saving 25 | options = { "buffers", "curdir", "tabpages", "winsize" }, 26 | -- default session name 27 | default_session_name = default_session_name, 28 | } 29 | 30 | local function basename(p) 31 | return fnamemodify(p, ":t:r") 32 | end 33 | 34 | local function get_session_path(name) 35 | name = name or defaults.default_session_name() 36 | return fnameescape(join_paths(defaults.dir, name .. ".vim")) 37 | end 38 | 39 | function M.save_session(name) 40 | -- readability: replace the expanded homedir 41 | local tmp = vim.o.sessionoptions 42 | vim.o.sessionoptions = table.concat(defaults.options, ",") 43 | vim.cmd("mks! " .. get_session_path(name)) 44 | vim.o.sessionoptions = tmp 45 | end 46 | 47 | function M.get_sessions() 48 | if not is_directory(defaults.dir) then 49 | vim.fn.mkdir(defaults.dir, "p") 50 | end 51 | return vim.tbl_map(function(v) 52 | return basename(v) 53 | end, vim.fn.glob(defaults.dir .. "/*", false, true)) 54 | end 55 | 56 | local function load_session_by_name(name) 57 | vim.validate { requested = { name, "s", true } } 58 | local full_path = get_session_path(name) 59 | vim.schedule(function() 60 | vim.cmd("source " .. full_path) 61 | end) 62 | end 63 | 64 | function M.load_session(name) 65 | name = name or "" 66 | 67 | if name ~= "" then 68 | load_session_by_name(name) 69 | return 70 | end 71 | 72 | local actions = require "telescope.actions" 73 | local action_state = require "telescope.actions.state" 74 | require("telescope.builtin").find_files { 75 | prompt_title = "Select a session to load", 76 | search_dirs = { join_paths(vim.fn.stdpath "cache", "sessions") }, 77 | path_display = function(_, path) 78 | return basename(path) 79 | end, 80 | attach_mappings = function(prompt_bufnr) 81 | actions.select_default:replace(function() 82 | local entry = action_state.get_selected_entry() 83 | actions.close(prompt_bufnr) 84 | -- NOTE: the result would still include the search result from fd, and not the displayed value 85 | load_session_by_name(basename(entry.value)) 86 | end) 87 | return true 88 | end, 89 | } 90 | end 91 | 92 | return M 93 | -------------------------------------------------------------------------------- /.config/git/config: -------------------------------------------------------------------------------- 1 | [core] 2 | pager = delta 3 | autocrlf = false 4 | eol = lf 5 | [interactive] 6 | diffFilter = delta --color-only 7 | [add.interactive] 8 | useBuiltin = false # required for git 2.37.0 9 | [delta] 10 | features = decorations unobtrusive-line-numbers 11 | line-numbers = true 12 | whitespace-error-style = 22 reverse 13 | [delta "decorations"] 14 | commit-style = yellow bold 15 | commit-decoration-style = bold yellow box ul 16 | [color] 17 | ui = true 18 | colorMoved = default 19 | [pull] 20 | rebase = true 21 | [fetch] 22 | prune = true 23 | [merge] 24 | tool = nvim 25 | [mergetool "nvim"] 26 | cmd = nvim -d -c \"wincmd l\" -c \"norm ]c\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\" 27 | [diff] 28 | tool = difftastic 29 | [difftool] 30 | prompt = false 31 | [difftool "difftastic"] 32 | cmd = difft "$LOCAL" "$REMOTE" 33 | [pager] 34 | difftool = true # use a pager for large output, just like other git commands 35 | [filter "spacify"] 36 | clean = expand --tabs=4 --initial 37 | [rebase] 38 | instructionFormat = %s%nexec git blameless commit --amend --no-edit%n 39 | [alias] 40 | ############# 41 | aliases = !git config --get-regexp '^alias.' | sed -e 's/^alias\\.\\([^ ]*\\)/\\x1B[33m\\1\\x1B[0m =/' 42 | ############# 43 | branches = branch -a 44 | remotes = remote -v 45 | graph = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit 46 | ############# 47 | amend = commit --amend --date=now 48 | auto-commit = !git add -A && git commit -m "updates" 49 | force-push = push --force -u 50 | last = log -1 HEAD --stat 51 | reuse-msg = commit --reuse-message=ORIG_HEAD 52 | soft-reset = reset HEAD~1 --soft 53 | unshallow = !(git fetch --unshallow || git fetch --all) && git remote set-branches origin '*' 54 | unstage = restore --staged . 55 | ############# 56 | fa = fetch --all 57 | qa = amend --no-edit 58 | ro = !git rebase $(git rev-parse --abbrev-ref HEAD) 59 | smu = submodule update --init --recursive --depth=1 60 | st = status -sb 61 | dft = difftool 62 | rbi = rebase --interactive 63 | ############# 64 | dots = !git --git-dir="$HOME/.dtf.git" --work-tree="$HOME/" 65 | dots-lazy = !lazygit --git-dir="$HOME/.dtf.git" --work-tree="$HOME/" 66 | ############# 67 | fuzzy = !dotbare -g 68 | fedit = fuzzy fedit 69 | fgrep = fuzzy fgrep 70 | flog = fuzzy flog 71 | fstat = fuzzy fstat 72 | ############# 73 | ignore = update-index --assume-unchanged 74 | unignore = update-index --no-assume-unchanged 75 | ############ 76 | copy-last-hash = !git log --pretty='%H' -1 -z | tmux load-buffer -w - 77 | print-ignored = !git ls-files -v | grep "^[[:lower:]]" 78 | print-author = log --pretty='%an %ae' -1 79 | print-author-name = log --pretty='%an' -1 80 | print-author-email = log --pretty='%ae' -1 81 | print-committer = log --pretty='%cn %ce' -1 82 | print-committer-name = log --pretty='%cn' -1 83 | print-committer-email = log --pretty='%ce' -1 84 | ############ 85 | blameless = !env GIT_COMMITTER_NAME=\"$(git print-author-name)\" GIT_COMMITTER_EMAIL=\"$(git print-author-email)\" git 86 | blameless-cp = !env GIT_COMMITTER_NAME=\"$(git log --pretty='%an' \"$1\"^!)\" GIT_COMMITTER_EMAIL=\"$(git log --pretty='%ae' \"$1\"^!)\" git cherry-pick 87 | [user] 88 | email = 59826753+kylo252@users.noreply.github.com 89 | name = kylo252 90 | [credential "https://github.com"] 91 | helper = !gh auth git-credential 92 | [credential "https://gist.github.com"] 93 | helper = !gh auth git-credential 94 | [push] 95 | autoSetupRemote = true 96 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/settings.lua: -------------------------------------------------------------------------------- 1 | vim.cmd "set syntax=off" 2 | 3 | --- SETTINGS --- 4 | vim.opt.backup = false -- creates a backup file 5 | vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard 6 | vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying messages 7 | vim.opt.colorcolumn = "99999" -- fix indentline for now 8 | vim.opt.conceallevel = 0 -- so that `` is visible in markdown files 9 | vim.opt.cursorline = true -- highlight the current line 10 | vim.opt.expandtab = true -- convert tabs to spaces 11 | vim.opt.fileencoding = "utf-8" -- the encoding written to a file 12 | vim.opt.fillchars = { fold = " " } -- remove folding chars 13 | -- vim.opt.foldexpr = "nvim_treesitter#foldexpr()" 14 | vim.opt.foldlevel = 10 -- don't close any folds by default 15 | vim.opt.foldmethod = "manual" 16 | vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications 17 | vim.opt.hidden = true -- required to keep multiple buffers and open multiple buffers 18 | vim.opt.ignorecase = true -- ignore case in search patterns (needed for smartcase to work) 19 | vim.opt.inccommand = "split" -- showsthe effects of :s as you type. 20 | vim.opt.mouse = "a" -- allow the mouse to be used in neovim 21 | vim.opt.number = true -- set numbered lines 22 | vim.opt.pumheight = 10 -- pop up menu height 23 | vim.opt.relativenumber = false -- set relative numbered lines 24 | vim.opt.scrolloff = 8 -- minimal number of screen lines to keep above and below the cursor. 25 | vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation 26 | vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore 27 | vim.opt.showtabline = 2 -- always show tabs 28 | vim.opt.sidescrolloff = 8 -- minimal number of screen lines to keep left and right of the cursor. 29 | vim.opt.signcolumn = "auto:1-2" -- always show the sign column, otherwise it would shift the text each time 30 | vim.opt.smartcase = true -- overrides ignorecase (does not work for '*', '#') 31 | vim.opt.smartindent = false -- make indenting smarter again 32 | vim.opt.splitbelow = true -- force all horizontal splits to go below current window 33 | vim.opt.splitright = true -- force all vertical splits to go to the right of current window 34 | vim.opt.swapfile = false -- creates a swapfile 35 | vim.opt.tabstop = 2 -- insert 4 spaces for a tab 36 | vim.opt.termguicolors = true -- set term gui colors (most terminals support this) 37 | vim.opt.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds) 38 | vim.opt.title = true -- set the title of window to the value of the titlestring 39 | vim.opt.undodir = vim.fn.stdpath "cache" .. "/undo" -- set an undo directory 40 | vim.opt.undofile = true -- enable persisten undo 41 | vim.opt.updatetime = 300 -- faster completion 42 | vim.opt.wrap = false -- display lines as one long line 43 | vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited 44 | vim.opt.laststatus = 3 -- global statusline 45 | 46 | vim.opt.iskeyword:append "-" -- used in searching and recognizing with many commands 47 | vim.opt.whichwrap:append "<,>,[,],h,l" -- let movement keys reach the previous line 48 | vim.opt.shortmess:append "c" -- don't show the dumb matching stuff 49 | 50 | vim.g.loaded_perl_provider = 0 51 | vim.g.loaded_ruby_provider = 0 52 | 53 | vim.filetype.add { 54 | extension = { 55 | ["*.pc"] = "csh", 56 | ["*.tpp"] = "cpp", 57 | ["*.pc.in"] = "csh", 58 | ["*.dsl"] = "groovy", 59 | }, 60 | pattern = { 61 | [".clang*"] = "yaml", 62 | ["Jenkinsfile"] = "groovy", 63 | }, 64 | } 65 | -------------------------------------------------------------------------------- /.config/tmux/scripts/theme.tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## onedark 4 | black="#282c34" 5 | white="#aab2bf" 6 | blue="#61afef" 7 | yellow="#e5c07b" 8 | red="#e06c75" 9 | green="#98c379" 10 | dark_grey="#3e4452" 11 | 12 | time_format="%R" 13 | extra_widget=" " 14 | date_format="%d/%m/%y" 15 | 16 | if [ -n "$SSH_CONNECTION" ]; then 17 | host_format="#h" 18 | else 19 | host_format="local" 20 | fi 21 | 22 | tmux set -g status "on" 23 | 24 | # bg=default will set the color automatically as the terminal 25 | tmux set -g status-style bg=default,none 26 | tmux set -g status-justify "left" 27 | 28 | tmux set -g status-right-style none 29 | tmux set -g status-left-style none 30 | 31 | tmux set -g status-left-length "100" 32 | tmux set -g status-right-length "100" 33 | 34 | tmux set -g message-style fg="$white" 35 | tmux set -g message-command-style fg="$white" 36 | 37 | tmux set -g window-style fg="$dark_grey" 38 | tmux set -g window-active-style fg="$white" 39 | 40 | tmux set -g pane-border-style fg="$white" 41 | tmux set -g pane-active-border-style fg="$green" 42 | 43 | tmux set -g display-panes-active-colour "$yellow" 44 | tmux set -g display-panes-colour "$blue" 45 | 46 | tmux setw -g window-status-style none 47 | tmux setw -g window-status-activity-style none 48 | 49 | tmux setw -g window-status-separator "" 50 | 51 | tmux set -g "@prefix_highlight_fg" "$black" 52 | tmux set -g "@prefix_highlight_bg" "$green" 53 | tmux set -g "@prefix_highlight_copy_mode_attr" "fg=$black,bg=$green" 54 | tmux set -g "@prefix_highlight_output_prefix" "  " 55 | 56 | # checking `#{pane_current_command}` does not work when neovim is invoked from another program, e.g. `lf`. 57 | current_cmd="#(ps -o command= -t '#{pane_tty}' | rg -o '^(n?l?vim)' || echo '#{pane_current_command}')" 58 | # pgrep wasn't that useful here since the output format doesn't seem configurable 59 | # current_cmd="#(pgrep -t '#{pane_tty}' -la '^(nvim|lvim|vim)' | grep -oP '\d+ \K(n?l?vim)' || echo '#{pane_current_command}')" 60 | 61 | # automatically rename windows to the current directory 62 | current_path='#{b:pane_current_path}' 63 | 64 | # TODO: consider adding a git-status "#(gitmux '#{pane_current_path}')" 65 | status_right=( 66 | "#[fg=$white,bg=default,nounderscore,noitalics]${extra_widget}" 67 | "#[fg=$black,bg=default]#[bg=$black]" 68 | "#[fg=$white,bg=$black]${date_format}" 69 | "#[fg=$dark_grey,bg=$black]#[fg=$white,bg=$dark_grey]" 70 | "${time_format}" 71 | "#[fg=$green,bg=$dark_grey,nobold,nounderscore,noitalics]#[fg=$black,bg=$green,bold]" 72 | "$host_format" 73 | "#[fg=$yellow,bg=$green]#[fg=$red,bg=$yellow]" 74 | ) 75 | 76 | status_left=( 77 | "#[fg=$black,bg=$green,bold] #S" 78 | "#{prefix_highlight}#[fg=$green,bg=default,nobold,nounderscore,noitalics]" 79 | ) 80 | 81 | current_win_status_format=( 82 | "#[fg=$dark_grey,bg=default,nobold,nounderscore,noitalics]#[fg=$white,bg=$dark_grey,nobold]" 83 | "#I" 84 | "" 85 | "#[fg=$green]$current_cmd" 86 | "#[fg=$blue]$current_path" 87 | "#[fg=$dark_grey,bg=default,nobold,nounderscore,noitalics]" 88 | ) 89 | 90 | win_status_format=( 91 | "#[fg=$black,bg=default,nobold,nounderscore,noitalics]#[fg=$white, bg=$black]" 92 | "#I " 93 | "#[fg=$green]$current_cmd" 94 | "#[fg=$dark_grey]$current_path" 95 | "#[fg=$black,bg=default,nobold,nounderscore,noitalics]" 96 | ) 97 | 98 | tmux set -g status-right "${status_right[*]}" 99 | tmux set -g status-left "${status_left[*]}" 100 | 101 | tmux setw -g window-status-current-format "${current_win_status_format[*]}" 102 | tmux setw -g window-status-format "${win_status_format[*]}" 103 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/utils.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.open_uri(uri) 4 | vim.notify("opening: " .. uri, vim.log.levels.INFO) 5 | local task = { 6 | command = "xdg-open", 7 | args = { uri }, 8 | } 9 | local Job = require "plenary.job" 10 | Job:new(task):start() 11 | end 12 | 13 | function M.xdg_open_handler() 14 | if vim.fn.executable "xdg-open" ~= 1 then 15 | vim.notify("xdg-open was not found", vim.log.levels.WARN) 16 | return 17 | end 18 | 19 | local ts_utils = require "nvim-treesitter.ts_utils" 20 | local n = ts_utils.get_node_at_cursor() 21 | local uri = vim.treesitter.query.get_node_text(n, 0) 22 | M.open_uri(uri) 23 | end 24 | 25 | function M.copy_help_url() 26 | if vim.bo.filetype ~= "help" then 27 | return 28 | end 29 | local last_search_query = function() 30 | local history_string = vim.fn.execute "history :" 31 | local history_list = vim.split(history_string, "\n") 32 | for i = #history_list, 3, -1 do 33 | local item = history_list[i] 34 | local _, finish = string.find(item, "%d+ +") 35 | local hist_item = string.sub(item, finish + 1) 36 | local query = hist_item:match "h (%S+)" 37 | if query then 38 | return query 39 | end 40 | end 41 | return "" 42 | end 43 | 44 | local base_url = "https://neovim.io/doc/user/%s.html#%s" 45 | local help_url = string.format(base_url, vim.fn.expand "%:t:r", last_search_query()) 46 | vim.notify(help_url, vim.log.levels.INFO, { title = "help url" }) 47 | vim.fn.setreg("+", help_url) 48 | M.open_uri(help_url) 49 | end 50 | 51 | function M.gsub_args(args) 52 | if args == nil or type(args) ~= "table" then 53 | return args 54 | end 55 | local buffer_filepath = vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) 56 | for i = 1, #args do 57 | args[i] = string.gsub(args[i], "${FILEPATH}", buffer_filepath) 58 | end 59 | return args 60 | end 61 | 62 | function M.is_file(filename) 63 | local stat = vim.loop.fs_stat(filename) 64 | return stat and stat.type == "file" or false 65 | end 66 | 67 | function M.is_directory(filename) 68 | local stat = vim.loop.fs_stat(filename) 69 | return stat and stat.type == "directory" or false 70 | end 71 | 72 | function M.join_paths(...) 73 | local path_sep = vim.loop.os_uname().version:match "Windows" and "\\" or "/" 74 | local result = table.concat({ ... }, path_sep) 75 | return result 76 | end 77 | 78 | function M.on_dir_changed() 79 | local entry = vim.loop.cwd() 80 | local Job = require "plenary.job" 81 | local job = Job:new { 82 | command = "zoxide", 83 | args = { "add", entry }, 84 | } 85 | job:start() 86 | end 87 | 88 | local function log_entry(...) 89 | local objects = vim.tbl_map(vim.inspect, { ... }) 90 | local log = require("plenary.log").new { 91 | level = "info", 92 | plugin = "user_debug", 93 | info_level = 3, 94 | use_console = "sync", 95 | } 96 | log.info(unpack(objects)) 97 | return ... 98 | end 99 | 100 | local function require_safe(m) 101 | local status_ok, module = pcall(require, m) 102 | if not status_ok then 103 | local trace = debug.getinfo(2, "SL") 104 | local shorter_src = trace.short_src:gsub(vim.fn.stdpath "config", ".") 105 | local lineinfo = shorter_src .. ":" .. (trace.currentline or trace.linedefined) 106 | local msg = string.format("%s : skipped loading [%s]", lineinfo, m) 107 | vim.notify_once(msg, vim.log.levels.TRACE) 108 | end 109 | return module 110 | end 111 | 112 | local function reload(m) 113 | local reloader = require_safe "plenary.reload" 114 | if reloader then 115 | reloader.reload_module(m, false) 116 | else 117 | package.loaded[m] = nil 118 | end 119 | return require_safe(m) 120 | end 121 | 122 | _G.reload = reload 123 | _G.log_entry = log_entry 124 | _G.P = vim.pretty_print 125 | _G.dump = vim.pretty_print 126 | 127 | return M 128 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | set runtimepath^=$XDG_CONFIG_HOME/vim 2 | set runtimepath+=$XDG_DATA_HOME/vim 3 | set runtimepath+=$XDG_CONFIG_HOME/vim/after 4 | 5 | set packpath+=$XDG_CONFIG_HOME/vim/after,$XDG_DATA_HOME/vim/after 6 | set packpath^=$XDG_DATA_HOME/vim,$XDG_CONFIG_HOME/vim 7 | 8 | let g:netrw_home = $XDG_DATA_HOME."/vim" 9 | call mkdir($XDG_DATA_HOME."/vim/spell", 'p') 10 | 11 | set backupdir=$XDG_STATE_HOME/vim/backup | call mkdir(&backupdir, 'p') 12 | set directory=$XDG_STATE_HOME/vim/swap | call mkdir(&directory, 'p') 13 | set undodir=$XDG_STATE_HOME/vim/undo | call mkdir(&undodir, 'p') 14 | set viewdir=$XDG_STATE_HOME/vim/view | call mkdir(&viewdir, 'p') 15 | 16 | if !has('nvim') | set viminfofile=$XDG_STATE_HOME/vim/viminfo | endif 17 | 18 | let g:c_syntax_for_h = 1 19 | 20 | let g:netrw_home = $XDG_DATA_HOME . '/vim' 21 | 22 | " set leader key 23 | let g:mapleader = "\" 24 | 25 | syntax enable " Enables syntax highlighing 26 | 27 | " Settings {{{ 28 | set nocompatible 29 | set autochdir " Your working directory will alway be the same as your working directory 30 | set clipboard=unnamedplus " Copy paste between vim and everything else 31 | set cmdheight=2 " More space for displaying messages 32 | set conceallevel=0 " So that I can see `` in markdown files 33 | set expandtab " Converts tabs to spaces 34 | set formatoptions-=cro " Stop newline continution of comments 35 | set hidden " Required to keep multiple buffers open multiple buffers 36 | set ignorecase 37 | set incsearch 38 | set iskeyword+=- " treat dash separated words as a word text object" 39 | set mouse=a " Enable your mouse 40 | set nobackup " This is recommended by coc 41 | set novisualbell " I don't know why this on by default.. 42 | set nowrap " Display long lines as just one line 43 | set nowritebackup " This is recommended by coc 44 | set number relativenumber " Line numbers 45 | set pumheight=10 " Makes popup menu smaller 46 | set ruler " Show the cursor position all the time 47 | set shiftwidth=2 " Change the number of space characters inserted for indentation 48 | set showtabline=2 " Always show tabs 49 | set smartindent " Makes indenting smart 50 | set smarttab " Makes tabbing smarter will realize you have 2 vs 4 51 | set splitbelow " Horizontal splits will automatically be below 52 | set splitright " Vertical splits will automatically be to the right 53 | set tabstop=2 " Insert 2 spaces for a tab 54 | set timeoutlen=1000 " By default timeoutlen is 1000 ms 55 | set updatetime=300 " Faster completion 56 | " }}} 57 | 58 | " if you have vim >=8.0 or neovim >= 0.1.5 59 | " if (has("termguicolors")) 60 | " set termguicolors 61 | " endif 62 | 63 | "" You can't stop me 64 | cmap w!! w !sudo tee % 65 | 66 | augroup myvimrc 67 | au! 68 | au BufWritePost .vimrc ++nested so $MYVIMRC 69 | augroup END 70 | 71 | if &term =~ '^xterm' 72 | " solid underscore 73 | let &t_SI .= "\[5 q" 74 | " solid block 75 | let &t_EI .= "\[2 q" 76 | " 1 or 0 -> blinking block 77 | " 3 -> blinking underscore 78 | " Recent versions of xterm (282 or above) also support 79 | " 5 -> blinking vertical bar 80 | " 6 -> solid vertical bar 81 | endif 82 | 83 | " " https://vi.stackexchange.com/a/25107 84 | augroup RestoreCursorShapeOnExit 85 | autocmd! 86 | autocmd VimLeave * set guicursor=a:ver20-blinkon1 87 | augroup END 88 | 89 | " {{{ KEYBINDINGS 90 | inoremap jj 91 | inoremap jk 92 | 93 | nnoremap h :noh 94 | nnoremap :w 95 | " }}} 96 | -------------------------------------------------------------------------------- /.config/bash/exports.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function __setup_defaults() { 4 | export XDG_CACHE_HOME="$HOME/.cache" 5 | export XDG_CONFIG_HOME="$HOME/.config" 6 | export XDG_DATA_HOME="$HOME/.local/share" 7 | export XDG_STATE_HOME="$HOME/.local/state" 8 | export LANG=en_US.UTF-8 9 | export LANGUAGE=en_US.UTF-8 10 | 11 | export EDITOR=nvim 12 | 13 | export DOTBARE_DIR="$HOME/.dtf.git" 14 | export DOTBARE_TREE="$HOME" 15 | 16 | export FONTCONFIG_PATH=/etc/fonts 17 | } 18 | 19 | function __setup_cli_colors() { 20 | export CLICOLOR=1 21 | export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 22 | } 23 | 24 | function __setup_xdg() { 25 | export CARGO_HOME="$XDG_DATA_HOME/cargo" 26 | export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" 27 | export GEM_HOME="$XDG_DATA_HOME/gem" 28 | export GEM_SPEC_CACHE="$XDG_CACHE_HOME/gem" 29 | export GNUPGHOME="$XDG_DATA_HOME/gnupg" 30 | export GOPATH="$XDG_DATA_HOME/go" 31 | export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" 32 | export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" 33 | export LESSHISTFILE="$XDG_STATE_HOME/less/history" 34 | export PARALLEL_HOME="$XDG_CONFIG_HOME/parallel" 35 | export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/ripgreprc" 36 | export RUSTUP_HOME="$XDG_DATA_HOME/rustup" 37 | export TERMINFO="$XDG_DATA_HOME/terminfo" 38 | export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo" 39 | export TMUX_CONFIG_DIR="$XDG_CONFIG_HOME/tmux" 40 | export TREE_SITTER_DIR="$XDG_CONFIG_HOME/tree-sitter" 41 | export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" 42 | export ZK_NOTEBOOK_DIR="$HOME/notes/pages" 43 | } 44 | 45 | function __setup_history() { 46 | export HISTCONTROL=ignoreboth 47 | export HISTFILE="$XDG_STATE_HOME/bash/history" 48 | export HISTFILESIZE=100000 49 | export HISTIGNORE="ls:ps:history"NIT=1 50 | export HISTSIZE=100000 # History size in memory 51 | export HISTTIMEFORMAT="%h %d %H:%M:%S " 52 | export LISTMAX=50 # The size of asking history 53 | export SAVEHIST=1000000 # The number of histsize 54 | } 55 | 56 | function __setup_fzf() { 57 | export FZF_DEFAULT_COMMAND="fd --type f" 58 | export FZF_DEFAULT_OPTS=" \ 59 | --layout=reverse --multi \ 60 | --bind '?:toggle-preview' \ 61 | --bind 'ctrl-a:select-all' \ 62 | --bind 'ctrl-y:execute-silent(echo {+} | xclip)' \ 63 | --bind 'ctrl-e:execute(echo {+} | xargs -o nvim)' \ 64 | --bind 'ctrl-x:execute(code {+})' " 65 | export FZF_CTRL_R_OPTS=" \ 66 | --preview 'echo {}' \ 67 | --preview-window down:3:hidden:wrap \ 68 | --bind '?:toggle-preview' \ 69 | --bind 'ctrl-y:execute-silent(echo -n {2..} | xclip)+abort' \ 70 | --header 'Press CTRL-Y to copy command into clipboard'\ 71 | --border" 72 | export FZF_PREVIEW_DEFAULT_SETTING=" \ 73 | --sync \ 74 | --height='80%' \ 75 | --preview-window='down:60%' \ 76 | --expect='ctrl-space' \ 77 | --header='C-Space: continue fzf completion'" 78 | } 79 | 80 | function __setup_misc() { 81 | export BAT_PAGER="less -RF" 82 | export BAT_THEME="TwoDark" 83 | 84 | export CMAKE_BUILD_TYPE=RelWithDebInfo 85 | export CMAKE_EXPORT_COMPILE_COMMANDS=1 86 | export CMAKE_GENERATOR=Ninja 87 | 88 | export DELTA_PAGER="less -RF" 89 | 90 | export MANPAGER='less -s -M +Gg' 91 | } 92 | 93 | setup_functions=( 94 | __setup_defaults 95 | __setup_cli_colors 96 | __setup_xdg 97 | __setup_history 98 | __setup_fzf 99 | __setup_misc 100 | ) 101 | 102 | for func in "${setup_functions[@]}"; do 103 | "$func" 104 | unset -f "$func" 105 | done 106 | unset setup_functions 107 | 108 | bin_list=( 109 | "$HOME/.local/bin" 110 | "$HOME/local/bin" 111 | "$HOME/bin" 112 | "$CARGO_HOME/bin" 113 | "$GEM_HOME/bin" 114 | "$NPM_HOME/bin" 115 | "$GOPATH/bin" 116 | "$XDG_CONFIG_HOME/rofi/bin" 117 | "$XDG_CONFIG_HOME/tmux/bin" 118 | ) 119 | 120 | for extra in "${bin_list[@]}"; do 121 | PATH=$extra:$PATH 122 | done 123 | export PATH 124 | unset bin_list 125 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/telescope.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.config() 4 | local _, actions = pcall(require, "telescope.actions") 5 | local _, builtin = pcall(require, "telescope.builtin") 6 | local _, themes = pcall(require, "telescope.themes") 7 | 8 | return { 9 | defaults = themes.get_ivy { 10 | layout_config = { 11 | center = { 12 | preview_cutoff = 70, 13 | }, 14 | cursor = { 15 | preview_cutoff = 70, 16 | }, 17 | horizontal = { 18 | preview_cutoff = 120, 19 | prompt_position = "bottom", 20 | }, 21 | vertical = { 22 | preview_cutoff = 70, 23 | }, 24 | }, 25 | vimgrep_arguments = { 26 | "rg", 27 | "--color=never", 28 | "--no-heading", 29 | "--hidden", 30 | "--with-filename", 31 | "--line-number", 32 | "--column", 33 | "--smart-case", 34 | "--glob=!.git/", 35 | }, 36 | winblend = 0, 37 | find_command = { "fd", "--type=file", "--hidden" }, 38 | mappings = { 39 | i = { 40 | [""] = actions.close, 41 | [""] = actions.cycle_history_next, 42 | [""] = actions.cycle_history_prev, 43 | [""] = actions.cycle_previewers_prev, 44 | [""] = actions.cycle_previewers_next, 45 | [""] = actions.smart_send_to_qflist + actions.open_qflist, 46 | [""] = actions.which_key, -- keys from pressing 47 | [""] = actions.to_fuzzy_refine, 48 | -- [""] = my_cool_custom_action, 49 | }, 50 | n = { 51 | [""] = actions.close, 52 | [""] = actions.cycle_previewers_prev, 53 | [""] = actions.cycle_previewers_next, 54 | [""] = actions.smart_send_to_qflist + actions.open_qflist, 55 | -- [""] = custom_actions.fuzzy_filter_results, 56 | -- [""] = my_cool_custom_action, 57 | }, 58 | }, 59 | }, 60 | pickers = { 61 | find_files = { 62 | hidden = true, 63 | }, 64 | live_grep = { 65 | only_sort_text = true, 66 | }, 67 | }, 68 | extensions = { 69 | fzf = { 70 | fuzzy = true, 71 | override_generic_sorter = true, 72 | override_file_sorter = true, 73 | case_mode = "smart_case", 74 | }, 75 | zoxide = { 76 | prompt = ">> ", 77 | prompt_title = "~ Zoxide ~", 78 | mappings = { 79 | default = { 80 | action = function(selection) 81 | vim.api.nvim_set_current_dir(selection.path) 82 | vim.cmd("lcd " .. selection.path) 83 | end, 84 | }, 85 | [""] = { 86 | action = function(selection) 87 | builtin.find_files { cwd = selection.path } 88 | end, 89 | }, 90 | [""] = { 91 | action = function(selection) 92 | builtin.live_grep { cwd = selection.path } 93 | end, 94 | }, 95 | }, 96 | }, 97 | }, 98 | } 99 | end 100 | 101 | function M.setup() 102 | local opts = M.config() 103 | 104 | require("telescope").setup(opts) 105 | local finders = require "core.telescope.custom-finders" 106 | local keymaps = { 107 | normal_mode = { 108 | [""] = { "Telescope find_files", "find project files" }, 109 | ["ft"] = { 110 | function() 111 | finders.dynamic_grep { args = "ft=" .. vim.bo.filetype } 112 | end, 113 | "live grep (same filetype)", 114 | }, 115 | }, 116 | } 117 | require("user.keymaps").load(keymaps) 118 | 119 | pcall(function() 120 | require("telescope").load_extension "fzf" 121 | require("telescope").load_extension "projects" 122 | require("telescope").load_extension "zoxide" 123 | end) 124 | end 125 | 126 | return M 127 | -------------------------------------------------------------------------------- /.config/waybar/style.css: -------------------------------------------------------------------------------- 1 | window#waybar { 2 | /* background-color: rgba(30, 34, 42, 0.5); */ 3 | font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif; 4 | font-size: 16px; 5 | background-color: rgba(43, 48, 59, 0.5); 6 | border-bottom: 3px solid rgba(100, 114, 125, 0.5); 7 | color: #ffffff; 8 | transition-property: background-color; 9 | transition-duration: 0.5s; 10 | } 11 | 12 | window#waybar.hidden { 13 | opacity: 0.2; 14 | } 15 | #workspaces button { 16 | /* font-weight: bolder; */ 17 | font-size: 17px; 18 | margin-left: 2px; 19 | margin-right: 2px; 20 | background-color: transparent; 21 | color: #5e81ac; 22 | /* Use box-shadow instead of border so the text isn't offset */ 23 | box-shadow: inset 0 -3px transparent; 24 | /* Avoid rounded borders under each workspace name */ 25 | border: none; 26 | padding: 0 7px; 27 | border-radius: 0; 28 | } 29 | 30 | /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ 31 | #workspaces button:hover { 32 | background: rgba(0, 0, 0, 0.2); 33 | color: #bf616a; 34 | } 35 | 36 | #workspaces button.active { 37 | color: #c68a75; 38 | background: #64727d; 39 | /* border-bottom: 3px solid; */ 40 | box-shadow: inset 0 -3px black; 41 | } 42 | 43 | #workspaces button.urgent { 44 | background-color: #eb4d4b; 45 | } 46 | 47 | #workspaces button.hidden { 48 | color: #2a2e38; 49 | border-bottom: 3px solid transparent; 50 | } 51 | 52 | #workspaces button.visible { 53 | box-shadow: 2px 2px 6px 1px black; 54 | color: #2a2e38; 55 | background-color: #5a5d5f; 56 | /* border-radius: 15px; */ 57 | border: none; 58 | } 59 | 60 | #taskbar button:hover { 61 | background: rgba(0, 0, 0, 0.2); 62 | box-shadow: inset 0 -3px #ffffff; 63 | } 64 | 65 | #taskbar button.active { 66 | background: #64727d; 67 | } 68 | 69 | #taskbar button.minimized { 70 | font-style: italic; 71 | } 72 | 73 | #taskbar button.maximized { 74 | font-style: oblique; 75 | } 76 | 77 | #hyprland.window { 78 | font-style: italic; 79 | background-color: transparent; 80 | } 81 | 82 | #mode { 83 | background-color: #64727d; 84 | } 85 | 86 | label:focus { 87 | background-color: #000000; 88 | } 89 | 90 | #upower, 91 | #cpu, 92 | #memory, 93 | #temperature, 94 | #network, 95 | #pulseaudio, 96 | #tray, 97 | #idle_inhibitor, 98 | #bluetooth, 99 | #custom-language, 100 | #custom-powermenu, 101 | #clock { 102 | background-color: #31353f; 103 | padding: 2px 8px; 104 | margin-top: 5px; 105 | margin-bottom: 7px; 106 | margin-left: 2px; 107 | margin-right: 2px; 108 | border-radius: 5px; 109 | } 110 | 111 | #clock { 112 | color: #abb2bf; 113 | font-weight: bold; 114 | } 115 | 116 | #bluetooth.connected { 117 | color: #42A5F2; 118 | } 119 | 120 | #bluetooth.on { 121 | color: #abb2bf; 122 | } 123 | 124 | #upower.charging { 125 | color: #a3be8c; 126 | } 127 | 128 | #upower.discharging { 129 | color: #abb2bf; 130 | } 131 | 132 | #mpd { 133 | color: #ffffff; 134 | } 135 | 136 | #cpu { 137 | color: #ff5555; 138 | } 139 | 140 | #memory { 141 | background-color: #9b59b6; 142 | } 143 | 144 | #pulseaudio { 145 | color: #b48ead; 146 | } 147 | 148 | #pulseaudio.muted { 149 | color: #f53c3c; 150 | } 151 | 152 | #pulseaudio.bluetooth { 153 | color: #42A5F2; 154 | } 155 | 156 | #temperature { 157 | color: #f0932b; 158 | } 159 | 160 | #temperature.critical { 161 | background-color: #eb4d4b; 162 | } 163 | 164 | #network { 165 | color: #88c0d0; 166 | } 167 | 168 | #network.disconnected { 169 | background-color: #f53c3c; 170 | } 171 | 172 | #tray { 173 | background-color: transparent; 174 | } 175 | 176 | #tray > .passive { 177 | -gtk-icon-effect: dim; 178 | } 179 | 180 | #tray > .needs-attention { 181 | -gtk-icon-effect: highlight; 182 | background-color: #eb4d4b; 183 | } 184 | 185 | /* #idle_inhibitor { */ 186 | /* background-color: transparent; */ 187 | /* color: #2d3436; */ 188 | /* } */ 189 | 190 | /* #idle_inhibitor.activated { */ 191 | /* color: #808080; */ 192 | /* } */ 193 | 194 | @keyframes blink { 195 | to { 196 | background-color: rgba(30, 34, 42, 0.5); 197 | color: #abb2bf; 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/manager.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local lsp_utils = require "user.lsp.utils" 4 | 5 | ---Resolve the configuration for a server 6 | ---@param name string 7 | ---@return table 8 | local function resolve_config(name) 9 | local config = { 10 | on_attach = require("user.lsp").common_on_attach, 11 | on_init = require("user.lsp").common_on_init, 12 | on_exit = require("user.lsp").common_on_exit, 13 | capabilities = require("user.lsp").common_capabilities(), 14 | flags = { 15 | debounce_text_changes = 150, 16 | }, 17 | } 18 | 19 | local status_ok, custom_config = pcall(require, "user.lsp.providers." .. name) 20 | if status_ok then 21 | config = vim.tbl_deep_extend("force", config, custom_config) 22 | end 23 | 24 | return config 25 | end 26 | 27 | ---Setup a language server by providing a name 28 | ---@param server_name string name of the language server 29 | function M.setup(server_name) 30 | vim.validate { name = { server_name, "string" } } 31 | 32 | if lsp_utils.is_client_active(server_name) then 33 | return 34 | end 35 | 36 | local config = resolve_config(server_name) 37 | require("lspconfig")[server_name].setup(config) 38 | end 39 | 40 | local function resolve_bufnr(bufnr) 41 | vim.validate { bufnr = { bufnr, "n", true } } 42 | if bufnr == nil or bufnr == 0 then 43 | return vim.api.nvim_get_current_buf() 44 | end 45 | return bufnr 46 | end 47 | 48 | ---@private 49 | ---Resolve a workspace for a client 50 | --- 51 | ---@param markers string[] list of search patterns 52 | ---@param bufnr number 53 | ---@return table|nil list of `{ uri:string, name: string }` 54 | local function resolve_workspace(markers, bufnr) 55 | if not markers then 56 | return 57 | end 58 | bufnr = resolve_bufnr(bufnr) 59 | local bufname = vim.api.nvim_buf_get_name(bufnr) 60 | local buf_path = vim.fs.dirname(bufname) 61 | local anchor = 62 | vim.fs.find(markers, { path = buf_path, stop = vim.loop.os_homedir(), upward = true })[1] 63 | if not anchor then 64 | return 65 | end 66 | local root_dir = vim.fs.dirname(anchor) 67 | local ws = { 68 | name = root_dir, 69 | uri = vim.uri_from_fname(root_dir), 70 | } 71 | return ws 72 | end 73 | 74 | ---@private 75 | ---Returns true if a workspace marker for a given client is found 76 | --- 77 | ---@param client table see |vim.lsp.client| 78 | ---@param config table 79 | ---@param bufnr number 80 | ---@return boolean|nil 81 | local function should_reuse_client(client, config, bufnr) 82 | if client.name == config.name then 83 | return 84 | end 85 | bufnr = resolve_bufnr(bufnr) 86 | local ws = resolve_workspace(config.workspace_markers, bufnr) 87 | if not ws then 88 | return 89 | end 90 | for _, folder in ipairs(client.workspace_folders) do 91 | if ws.uri == folder.uri then 92 | return true 93 | end 94 | end 95 | return vim.lsp.add_workspace_folder(ws, { id = client.id }) 96 | end 97 | 98 | ---Setup a language server by providing a name 99 | ---@param server_name string name of the language server 100 | ---@param overrrides table? when available it will take predence over any default configurations 101 | function M.setup_manual(server_name, overrrides) 102 | vim.validate { name = { server_name, "string" } } 103 | overrrides = overrrides or {} 104 | local success, conf = pcall(require, "lspconfig.server_configurations." .. server_name) 105 | if not success then 106 | vim.notify( 107 | string.format("[lspconfig] This setup API is not supported for (%s) ..", server_name), 108 | vim.log.levels.WARN 109 | ) 110 | return 111 | end 112 | local config = vim.tbl_deep_extend("force", conf.default_config, overrrides) 113 | 114 | -- this is missing by default for some reason.. 115 | config.name = config.name or server_name 116 | 117 | -- only use git repos by default 118 | config.workspace_markers = config.workspace_markers or { ".git" } 119 | 120 | local bufnr = vim.api.nvim_get_current_buf() 121 | config.workspace_folders = config.workspace_folders 122 | or { resolve_workspace(config.workspace_markers, bufnr) } 123 | local opts = { 124 | reuse_client = should_reuse_client, 125 | } 126 | vim.lsp.start(config, opts) 127 | end 128 | 129 | return M 130 | -------------------------------------------------------------------------------- /.config/nvim/scripts/minimal_init.lua: -------------------------------------------------------------------------------- 1 | local on_windows = vim.loop.os_uname().version:match "Windows" 2 | 3 | local function join_paths(...) 4 | local path_sep = on_windows and "\\" or "/" 5 | local result = table.concat({ ... }, path_sep) 6 | return result 7 | end 8 | 9 | vim.cmd [[set runtimepath=$VIMRUNTIME]] 10 | 11 | local temp_dir = vim.loop.os_getenv "TEMP" or "/tmp" 12 | 13 | vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site")) 14 | 15 | local package_root = join_paths(temp_dir, "nvim", "site", "pack") 16 | local install_path = join_paths(package_root, "packer", "start", "packer.nvim") 17 | local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua") 18 | 19 | -- Choose whether to use the executable that's managed by mason 20 | local use_mason = true 21 | 22 | local function load_plugins() 23 | require("packer").startup { 24 | { 25 | "wbthomason/packer.nvim", 26 | "neovim/nvim-lspconfig", 27 | "williamboman/mason-lspconfig.nvim", 28 | "williamboman/mason.nvim", 29 | }, 30 | config = { 31 | package_root = package_root, 32 | compile_path = compile_path, 33 | }, 34 | } 35 | end 36 | 37 | local load_config = function() 38 | vim.lsp.set_log_level "trace" 39 | vim.cmd [[syntax off]] 40 | require("vim.lsp.log").set_format_func(vim.inspect) 41 | local nvim_lsp = require "lspconfig" 42 | local on_attach = function(_, bufnr) 43 | local function buf_set_option(...) 44 | vim.api.nvim_buf_set_option(bufnr, ...) 45 | end 46 | 47 | buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") 48 | 49 | -- Mappings. 50 | local opts = { buffer = bufnr, noremap = true, silent = true } 51 | vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) 52 | vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 53 | vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) 54 | vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) 55 | vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) 56 | vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) 57 | vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) 58 | vim.keymap.set("n", "wl", function() 59 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) 60 | end, opts) 61 | vim.keymap.set("n", "lD", vim.lsp.buf.type_definition, opts) 62 | vim.keymap.set("n", "lr", vim.lsp.buf.rename, opts) 63 | vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) 64 | vim.keymap.set("n", "gl", vim.diagnostic.open_float, opts) 65 | vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) 66 | vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) 67 | vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) 68 | vim.keymap.set("n", "li", "LspInfo", opts) 69 | vim.keymap.set("n", "lI", "Mason", opts) 70 | vim.keymap.set("n", "ll", vim.fn.execute("edit " .. vim.lsp.get_log_path()), opts) 71 | end 72 | 73 | -- Add the server that troubles you here, e.g. "clangd", "pyright", "tsserver" 74 | local name = "clangd" 75 | 76 | local setup_opts = { 77 | on_attach = on_attach, 78 | } 79 | 80 | if not name then 81 | print "You have not defined a server name, please edit minimal_init.lua" 82 | end 83 | if not nvim_lsp[name].document_config.default_config.cmd and not setup_opts.cmd then 84 | print [[You have not defined a server default cmd for a server 85 | that requires it please edit minimal_init.lua]] 86 | end 87 | 88 | nvim_lsp[name].setup(setup_opts) 89 | if use_mason then 90 | require("mason-lspconfig").setup { automatic_installation = true } 91 | end 92 | 93 | print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]] 94 | end 95 | 96 | if vim.fn.isdirectory(install_path) == 0 then 97 | vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path } 98 | load_plugins() 99 | require("packer").sync() 100 | local packer_group = vim.api.nvim_create_augroup("Packer", { clear = true }) 101 | vim.api.nvim_create_autocmd( 102 | "User", 103 | { pattern = "PackerComplete", callback = load_config, group = packer_group, once = true } 104 | ) 105 | else 106 | load_plugins() 107 | require("packer").sync() 108 | load_config() 109 | end 110 | -------------------------------------------------------------------------------- /.config/zsh/functions.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | function ex() { 4 | if [ -f "$1" ]; then 5 | case $1 in 6 | *.tar) tar xf "$1" ;; 7 | *.tar.bz2 | *.tbz | *.tbz2) tar xjf "$1" ;; 8 | *.tar.gz | *.tgz) tar xzf "$1" ;; 9 | *.tar.lz4 ) lz4 -c -d "$1" | tar xvf - ;; 10 | *.tar.xz | *.txz) tar --xz -xf "$1" ;; 11 | *.tar.zma ) tar --lzma -xf "$1" ;; 12 | *.tar.zst | *.tzst) tar --zstd -xf "$1" ;; 13 | *.7z) 7z x "$1" ;; 14 | *.bz2) bunzip2 "$1" ;; 15 | *.gz) gunzip "$1" ;; 16 | *.lz4) lz4 -d "$1" ;; 17 | *.lzma) unlzma "$1" ;; 18 | *.rar) unrar x "$1" ;; 19 | *.zip) unzip "$1" ;; 20 | *.zst) unzstd "$1" ;; 21 | *.Z) uncompress "$1" ;; 22 | *) echo "'$1' cannot be extracted via ex()" ;; 23 | esac 24 | else 25 | echo "'$1' is not a valid file" 26 | fi 27 | } 28 | 29 | function ta() { 30 | [ -n "$TMUX" ] && local change="switch-client" || local change="attach-session" 31 | if [ $1 ]; then 32 | tmux "$change" -t "$1" 2>/dev/null || (tmux new-session -d -s "$1" && tmux "$change" -t "$1"); return 33 | fi 34 | local session="$(tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf --exit-0)" && tmux "$change" -t "$session" || echo "No sessions found." 35 | } 36 | 37 | function ts() { 38 | if command -v smug &>/dev/null; then 39 | smug start default -a 40 | else 41 | local session="$(tmuxp ls | fzf --exit-0)" 42 | tmuxp load -y "$session" 43 | fi 44 | } 45 | 46 | # an alias is not enough since we can only pass `depth` flag as a git command 47 | function grc() { 48 | [ -n "$1" ] || echo "argument missing" || exit 1 49 | set -x 50 | gh repo clone "$1" -- --depth=1 51 | } 52 | 53 | function cpr() { 54 | rsync --archive -hh --partial --info=stats1 --info=progress2 --modify-window=1 "$@" 55 | } 56 | 57 | function jqz(){ 58 | emulate -L bash 59 | set -x 60 | args="${2:-}" 61 | file="$1" 62 | jq --color-output "$args" "$file" | fzf --ansi 63 | } 64 | 65 | function mvr() { 66 | rsync --archive -hh --partial --info=stats1 --info=progress2 --modify-window=1 --remove-source-files "$@" 67 | } 68 | 69 | # find-in-file - usage: fif 70 | function fif() { 71 | [ ! "$#" -gt 0 ] && echo "please provoide an argument, these are pass to rg directly" && return 1 72 | local initial_query="$@" 73 | local rg_prefix="rg --column --line-number --no-heading --color=always --smart-case " 74 | FZF_DEFAULT_COMMAND="$rg_prefix '$initial_query'" \ 75 | fzf --bind "change:reload:$rg_prefix {q} || true" \ 76 | --ansi --disabled --query "$initial_query" \ 77 | --bind 'ctrl-o:execute:${EDITOR:-vim} <(xdg {1}) > /dev/tty' \ 78 | --preview "rg -i --pretty --context 2 {q} {}" | cut -d":" -f1,2 | awk -F":" '{ printf("%s +%s\n",$1,$2) }' 79 | # --layout=reverse | xargs "$EDITOR" 80 | 81 | } 82 | 83 | # TODO: add the ability to open in an editor 84 | function fif-v2() { 85 | [ ! "$#" -gt 0 ] && echo "please provoide an argument, these are pass to rg directly" && return 1 86 | local initial_query="$@" 87 | local rg_prefix="rg --column --line-number --no-heading --color=always --smart-case " 88 | FZF_DEFAULT_COMMAND="$rg_prefix '$initial_query'" \ 89 | fzf --bind "change:reload:$rg_prefix {q} || true" \ 90 | --ansi --phony --query "$initial_query" \ 91 | --height=50% --layout=reverse --preview "$XDG_CONFIG_HOME/fzf/helper/previewer.sh $PWD/{}" | 92 | awk -F ":" -v home="$PWD" '{ print home "/" $1 ":" $2 }' 93 | } 94 | 95 | function dev-nvim() { 96 | local nvim_repo="$HOME/.local/share/neovim" 97 | local xdg_cache="$nvim_repo/build/Xtest_xdg/cache" 98 | rm -rf "$xdg_cache"; 99 | mkdir -p "$xdg_cache"; 100 | env VIMRUNTIME="$nvim_repo/runtime" \ 101 | XDG_CACHE_HOME="$xdg_cache" \ 102 | XDG_STATE_HOME="$xdg_cache" \ 103 | "$nvim_repo/build/bin/nvim" "$@" 104 | } 105 | 106 | function min-nvim() { 107 | local minimal_init_rc="$HOME/.config/nvim/scripts/minimal_init.lua" 108 | dev-nvim -u "$minimal_init_rc" "$@" 109 | } 110 | 111 | # zsh force reset 112 | function zfr() { 113 | fd . "$ZDOTDIR" --hidden -e zwc -x rm 114 | fd . "$XDG_CACHE_HOME/zsh" --type file --hidden -x rm 115 | znap restart 116 | } 117 | 118 | function gh-latest-release() { 119 | local repo="$1" 120 | gh api "repos/$repo/releases/latest" \ 121 | --jq '.assets[].browser_download_url' \ 122 | | fzf --exit-0 123 | } 124 | 125 | function __printkeys() { 126 | stdbuf -o0 showkey -a | cat - 127 | } 128 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/init.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.get_lsp_kind() 4 | return { 5 | Class = "", 6 | Color = "", 7 | Constant = "", 8 | Constructor = "", 9 | Enum = "了", 10 | EnumMember = "", 11 | Event = "", 12 | Field = "ﴲ", 13 | File = "", 14 | Folder = "", 15 | Function = "", 16 | Interface = "ﰮ", 17 | Keyword = "", 18 | Method = "", 19 | Module = "", 20 | Operator = "", 21 | Property = " ", 22 | Reference = "", 23 | Snippet = "", 24 | Struct = "", 25 | Text = " ", 26 | TypeParameter = "", 27 | Unit = "", 28 | Value = "", 29 | Variable = "", 30 | } 31 | end 32 | 33 | vim.lsp.protocol.CompletionItemKind = M.get_lsp_kind() 34 | 35 | local function setup_lsp_keybindings(bufnr) 36 | local buffer_mappings = { 37 | normal_mode = { 38 | ["K"] = { vim.lsp.buf.hover, "Show hover" }, 39 | ["gd"] = { vim.lsp.buf.definition, "Goto definition" }, 40 | ["[d"] = { vim.diagnostic.goto_next, "Next diagnostic" }, 41 | ["]d"] = { vim.diagnostic.goto_prev, "Prev diagnostic" }, 42 | ["gD"] = { vim.lsp.buf.declaration, "Goto declaration" }, 43 | ["gr"] = { vim.lsp.buf.references, "Goto references" }, 44 | ["gI"] = { vim.lsp.buf.implementation, "Goto implementation" }, 45 | ["gs"] = { vim.lsp.buf.signature_help, "Show signature help" }, 46 | ["gl"] = { vim.diagnostic.open_float, "Show line diagnostics" }, 47 | ["la"] = { vim.lsp.buf.code_action, "Code Action" }, 48 | ["lf"] = { vim.lsp.buf.format, "Format" }, 49 | ["lr"] = { vim.lsp.buf.rename, "Rename" }, 50 | ["lq"] = { vim.diagnostic.setloclist, "Jumplist Diagnostics" }, 51 | }, 52 | insert_mode = {}, 53 | visual_mode = {}, 54 | } 55 | 56 | local mappings = { 57 | normal_mode = "n", 58 | insert_mode = "i", 59 | visual_mode = "v", 60 | } 61 | 62 | for mode_name, mode_char in pairs(mappings) do 63 | for key, remap in pairs(buffer_mappings[mode_name]) do 64 | local opts = { buffer = bufnr, desc = remap[2], noremap = true, silent = true } 65 | vim.keymap.set(mode_char, key, remap[1], opts) 66 | end 67 | end 68 | end 69 | 70 | --luacheck: no unused args 71 | ---@diagnostic disable-next-line: unused-local 72 | function M.common_on_init(client, bufnr) end 73 | 74 | function M.common_on_exit(_, _) 75 | require("user.autocmds").clear_augroup "lsp_document_highlight" 76 | end 77 | 78 | function M.common_on_attach(client, bufnr) 79 | require("user.lsp.utils").setup_document_highlight(client, bufnr) 80 | setup_lsp_keybindings(bufnr) 81 | 82 | local function buf_set_option(...) 83 | vim.api.nvim_buf_set_option(bufnr, ...) 84 | end 85 | 86 | --Enable completion triggered by 87 | buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") 88 | 89 | -- use gq for formatting 90 | buf_set_option("formatexpr", "v:lua.vim.lsp.formatexpr(#{timeout_ms:250})") 91 | end 92 | 93 | function M.common_capabilities() 94 | local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") 95 | if status_ok and cmp_nvim_lsp then 96 | return cmp_nvim_lsp.default_capabilities() 97 | end 98 | return vim.lsp.protocol.make_client_capabilities() 99 | end 100 | 101 | function M.get_common_opts() 102 | return { 103 | on_attach = M.common_on_attach, 104 | on_init = M.common_on_init, 105 | on_exit = M.common_on_exit, 106 | capabilities = M.common_capabilities(), 107 | } 108 | end 109 | 110 | function M.setup() 111 | require("user.lsp.handlers").setup() 112 | require("vim.lsp.log").set_format_func(vim.inspect) 113 | 114 | require("user.lsp.null-ls").setup() 115 | 116 | -- needs to be called before setting up jsonls 117 | pcall(function() 118 | require("nlspsettings").setup { 119 | config_home = vim.fn.stdpath "config" .. "/lsp-settings", 120 | append_default_schemas = true, 121 | local_settings_dir = ".lsp", 122 | local_settings_root_markers = { ".git", ".lsp" }, 123 | loader = "json", 124 | ignored_servers = {}, 125 | open_strictly = false, 126 | } 127 | end) 128 | 129 | local servers = { 130 | "clangd", 131 | "lua_ls", 132 | "bashls", 133 | "dockerls", 134 | "jsonls", 135 | "yamlls", 136 | "pyright", 137 | "ruff_lsp", 138 | "cmake", 139 | } 140 | 141 | for _, server in ipairs(servers) do 142 | require("user.lsp.manager").setup(server) 143 | end 144 | end 145 | 146 | return M 147 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/statusline.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local colors = { 4 | bg = "#1C1F24", 5 | 6 | black = "#1B1B1B", 7 | skyblue = "#51AFEF", 8 | 9 | fg = "#bbc2cf", 10 | green = "#98BE65", 11 | oceanblue = "#2257A0", 12 | magenta = "#C26BDB", 13 | orange = "#DA8548", 14 | red = "#FF6C6B", 15 | violet = "#A9A1E1", 16 | white = "#EFEFEF", 17 | yellow = "#ECBE7B", 18 | dark_yellow = "#D7BA7D", 19 | cyan = "#4EC9B0", 20 | light_green = "#B5CEA8", 21 | string_orange = "#CE9178", 22 | purple = "#C586C0", 23 | grey = "#858585", 24 | blue = "#569CD6", 25 | vivid_blue = "#4FC1FF", 26 | light_blue = "#9CDCFE", 27 | error_red = "#F44747", 28 | info_yellow = "#FFCC66", 29 | } 30 | 31 | local conditions = { 32 | buffer_not_empty = function() 33 | return vim.fn.empty(vim.fn.expand "%:t") ~= 1 34 | end, 35 | hide_in_width = function() 36 | return vim.o.columns > 100 37 | end, 38 | } 39 | local function diff_source() 40 | local gitsigns = vim.b.gitsigns_status_dict 41 | if gitsigns then 42 | return { 43 | added = gitsigns.added, 44 | modified = gitsigns.changed, 45 | removed = gitsigns.removed, 46 | } 47 | end 48 | end 49 | 50 | local components = { 51 | diagnostics = { 52 | "diagnostics", 53 | sources = { "nvim_diagnostic" }, 54 | symbols = { error = " ", warn = " ", info = " ", hint = " " }, 55 | color = {}, 56 | cond = conditions.hide_in_width, 57 | }, 58 | lsp_clients = { 59 | function(msg) 60 | local buf_clients = vim.lsp.get_active_clients { bufnr = 0 } 61 | if next(buf_clients) == nil then 62 | -- TODO: clean up this if statement 63 | if type(msg) == "boolean" or #msg == 0 then 64 | return "LS Inactive" 65 | end 66 | return msg 67 | end 68 | 69 | local buf_client_names = {} 70 | local buf_ft = vim.bo.filetype 71 | local n = require "user.lsp.null-ls" 72 | for _, client in pairs(buf_clients) do 73 | if client.name == "null-ls" then 74 | local null_ls_formatters = n.list_registered_formatters(buf_ft) 75 | vim.list_extend(buf_client_names, null_ls_formatters) 76 | local null_ls_linters = n.list_registered_linters(buf_ft) 77 | vim.list_extend(buf_client_names, null_ls_linters) 78 | else 79 | table.insert(buf_client_names, client.name) 80 | end 81 | end 82 | 83 | return table.concat(buf_client_names, ", ") 84 | end, 85 | color = { gui = "bold" }, 86 | }, 87 | treesitter = { 88 | function() 89 | local b = vim.api.nvim_get_current_buf() 90 | if next(vim.treesitter.highlighter.active[b]) then 91 | return "  " 92 | end 93 | return "" 94 | end, 95 | color = { fg = colors.green }, 96 | cond = conditions.hide_in_width, 97 | }, 98 | filename = { 99 | "filename", 100 | color = {}, 101 | cond = nil, 102 | path = 1, 103 | }, 104 | diff = { 105 | "diff", 106 | source = diff_source, 107 | symbols = { 108 | added = " ", 109 | modified = " ", 110 | removed = " ", 111 | }, 112 | padding = { left = 2, right = 1 }, 113 | diff_color = { 114 | added = { fg = colors.green }, 115 | modified = { fg = colors.yellow }, 116 | removed = { fg = colors.red }, 117 | }, 118 | cond = nil, 119 | }, 120 | } 121 | 122 | local config = { 123 | options = { 124 | icons_enabled = true, 125 | theme = "onedark", 126 | component_separators = { left = "", right = "" }, 127 | section_separators = { left = "", right = "" }, 128 | disabled_filetypes = { "NvimTree" }, 129 | always_divide_middle = true, 130 | globalstatus = true, 131 | }, 132 | sections = { 133 | lualine_a = { "mode" }, 134 | lualine_b = { "branch", components.diff }, 135 | lualine_c = { components.filename }, 136 | lualine_x = { 137 | { "lsp_progress", colors = { use = true } }, 138 | components.diagnostics, 139 | components.lsp_clients, 140 | "filetype", 141 | }, 142 | lualine_y = { components.treesitter }, 143 | lualine_z = { "location" }, 144 | }, 145 | inactive_sections = { 146 | lualine_a = {}, 147 | lualine_b = {}, 148 | lualine_c = { "filename" }, 149 | lualine_x = { "location" }, 150 | lualine_y = {}, 151 | lualine_z = {}, 152 | }, 153 | tabline = {}, 154 | extensions = {}, 155 | } 156 | 157 | function M.setup() 158 | require("lualine").setup(config) 159 | end 160 | 161 | return M 162 | -------------------------------------------------------------------------------- /.config/nvim/lazy-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, 3 | "LuaSnip": { "branch": "master", "commit": "5de556a3e970346debd43b686deab4ed1f9bf18a" }, 4 | "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, 5 | "bufferline.nvim": { "branch": "main", "commit": "81820cac7c85e51e4cf179f8a66d13dbf7b032d9" }, 6 | "clangd_extensions.nvim": { "branch": "main", "commit": "a8500531c4ed3a207e744a374ea038744a0f93eb" }, 7 | "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, 8 | "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, 9 | "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, 10 | "cmp-tmux": { "branch": "main", "commit": "95b1b921802e6f60627b3e76afb9380fddd87f9a" }, 11 | "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, 12 | "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, 13 | "gitsigns.nvim": { "branch": "main", "commit": "0595724fa9516a35696ff6b1e3cb95b6462b38b1" }, 14 | "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, 15 | "lazy.nvim": { "branch": "main", "commit": "60fe75c88db22025989600bb53dba247654d9ed5" }, 16 | "lf-vim": { "branch": "master", "commit": "23d38227077f09a926f00424b6dfcdb1613da6d2" }, 17 | "lightspeed.nvim": { "branch": "main", "commit": "fcc72d8a4d5f4ebba62d8a3a0660f88f1b5c3b05" }, 18 | "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, 19 | "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, 20 | "mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" }, 21 | "mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" }, 22 | "neodev.nvim": { "branch": "main", "commit": "02893eeb9d6e8503817bd52385e111cba9a90500" }, 23 | "neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" }, 24 | "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, 25 | "nlsp-settings.nvim": { "branch": "main", "commit": "aa33f56ff70ef9a37ecabc34178420b3e2d5ed7b" }, 26 | "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, 27 | "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, 28 | "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, 29 | "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, 30 | "nvim-lspconfig": { "branch": "master", "commit": "95b2fc427353e42318c974d10685d500441b821b" }, 31 | "nvim-toggleterm.lua": { "branch": "main", "commit": "cd55bf6aab3f88c259fa29ea86bbdcb1a325687d" }, 32 | "nvim-tree.lua": { "branch": "master", "commit": "8b2c5c678be4b49dff6a2df794877000113fd77b" }, 33 | "nvim-treesitter": { "branch": "master", "commit": "cf7baac35aa5c103b960bcb3f15c690a4aa5c6f1" }, 34 | "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, 35 | "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, 36 | "onedark.nvim": { "branch": "master", "commit": "5d417ee8f27773cffab1978b1f142e7bbda86009" }, 37 | "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, 38 | "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, 39 | "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, 40 | "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, 41 | "schemastore.nvim": { "branch": "main", "commit": "73594484edfa33ec9301e42c6c7a4af25c48266f" }, 42 | "sniprun": { "branch": "master", "commit": "1420cff041a0582636f63960d7160f7832463c10" }, 43 | "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, 44 | "telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" }, 45 | "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, 46 | "tmux.nvim": { "branch": "main", "commit": "da618e075f42793400c3ee1e59ef3ebada2cb23c" }, 47 | "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }, 48 | "zk-nvim": { "branch": "main", "commit": "15e24e96cb90889ebd12b5dbe800a958c716f520" } 49 | } -------------------------------------------------------------------------------- /.config/nvim/lua/core/bufferline.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | --stylua: ignore start 4 | 5 | -- Common kill function for bdelete and bwipeout 6 | -- credits: based on bbye and nvim-bufdel 7 | ---@param kill_command? string defaults to "bd" 8 | ---@param bufnr? number defaults to the current buffer 9 | ---@param force? boolean defaults to false 10 | function M.buf_kill(kill_command, bufnr, force) 11 | kill_command = kill_command or "bd" 12 | 13 | local bo = vim.bo 14 | local api = vim.api 15 | local fmt = string.format 16 | local fnamemodify = vim.fn.fnamemodify 17 | 18 | if bufnr == 0 or bufnr == nil then 19 | bufnr = api.nvim_get_current_buf() 20 | end 21 | 22 | local bufname = api.nvim_buf_get_name(bufnr) 23 | 24 | if not force then 25 | local warning 26 | if bo[bufnr].modified then 27 | warning = fmt([[No write since last change for (%s)]], fnamemodify(bufname, ":t")) 28 | elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then 29 | warning = fmt([[Terminal %s will be killed]], bufname) 30 | end 31 | if warning then 32 | vim.ui.input({ 33 | prompt = string.format([[%s. Close it anyway? [y]es or [n]o (default: no): ]], warning), 34 | }, function(choice) 35 | if choice == "y" then force = true end 36 | end) 37 | if not force then return end 38 | end 39 | end 40 | 41 | -- Get list of windows IDs with the buffer to close 42 | local windows = vim.tbl_filter(function(win) 43 | return api.nvim_win_get_buf(win) == bufnr 44 | end, api.nvim_list_wins()) 45 | 46 | if #windows == 0 then return end 47 | 48 | if force then 49 | kill_command = kill_command .. "!" 50 | end 51 | 52 | -- Get list of active buffers 53 | local buffers = vim.tbl_filter(function(buf) 54 | return api.nvim_buf_is_valid(buf) and bo[buf].buflisted 55 | end, api.nvim_list_bufs()) 56 | 57 | -- If there is only one buffer (which has to be the current one), vim will 58 | -- create a new buffer on :bd. 59 | -- For more than one buffer, pick the previous buffer (wrapping around if necessary) 60 | if #buffers > 1 then 61 | for i, v in ipairs(buffers) do 62 | if v == bufnr then 63 | local prev_buf_idx = i == 1 and (#buffers - 1) or (i - 1) 64 | local prev_buffer = buffers[prev_buf_idx] 65 | for _, win in ipairs(windows) do 66 | api.nvim_win_set_buf(win, prev_buffer) 67 | end 68 | end 69 | end 70 | end 71 | 72 | -- Check if buffer still exists, to ensure the target buffer wasn't killed 73 | -- due to options like bufhidden=wipe. 74 | if api.nvim_buf_is_valid(bufnr) and bo[bufnr].buflisted then 75 | vim.cmd(string.format("%s %d", kill_command, bufnr)) 76 | end 77 | end 78 | 79 | --stylua: ignore end 80 | 81 | M.setup = function() 82 | require("bufferline").setup { 83 | highlights = { 84 | background = { 85 | italic = true, 86 | }, 87 | buffer_selected = { 88 | bold = true, 89 | }, 90 | }, 91 | options = { 92 | right_mouse_command = "vert sbuffer %d", 93 | show_close_icon = false, 94 | show_buffer_icons = true, 95 | separator_style = "thin", 96 | enforce_regular_tabs = true, 97 | always_show_bufferline = true, 98 | show_tab_indicators = true, 99 | persist_buffer_sort = true, -- whether or not custom sorted buffers should persist 100 | diagnostics = "nvim-lsp", 101 | diagnostics_update_in_insert = false, 102 | offsets = { 103 | { 104 | filetype = "NvimTree", 105 | text = "Explorer", 106 | -- highlight = "PanelHeading", 107 | padding = 1, 108 | }, 109 | { 110 | filetype = "DiffviewFiles", 111 | text = "Diff View", 112 | highlight = "PanelHeading", 113 | padding = 1, 114 | }, 115 | }, 116 | 117 | groups = { 118 | items = { 119 | require("bufferline.groups").builtin.ungrouped, -- the ungrouped buffers will be in the middle of the grouped ones 120 | { 121 | name = "docs", 122 | display_name = "  ", 123 | matcher = function(buf) 124 | return buf.name:match "%.md" 125 | end, 126 | }, 127 | }, 128 | }, 129 | }, 130 | } 131 | 132 | local commands = { 133 | { 134 | name = "BufferKill", 135 | fn = function() 136 | require("core.bufferline").buf_kill() 137 | end, 138 | opts = { bang = true, force = true }, 139 | }, 140 | } 141 | 142 | require("user.commands").load_commands(commands) 143 | end 144 | 145 | return M 146 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/cmp.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local has_words_before = function() 4 | local line, col = unpack(vim.api.nvim_win_get_cursor(0)) 5 | return col ~= 0 6 | and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil 7 | end 8 | 9 | local cmp_format_layout = function(entry, vim_item) 10 | local icons = require("user.lsp").get_lsp_kind() 11 | vim_item.kind = icons[vim_item.kind] 12 | vim_item.menu = ({ 13 | nvim_lsp = "(LSP)", 14 | nvim_lua = "(API)", 15 | path = "(Path)", 16 | luasnip = "(Snippet)", 17 | buffer = "(Buffer)", 18 | tmux = "(TMUX)", 19 | })[entry.source.name] 20 | return vim_item 21 | end 22 | 23 | M.config = function() 24 | local status_cmp_ok, cmp = pcall(require, "cmp") 25 | if not status_cmp_ok then 26 | return 27 | end 28 | 29 | local status_luasnip_ok, luasnip = pcall(require, "luasnip") 30 | if not status_luasnip_ok then 31 | return 32 | end 33 | cmp.setup { 34 | formatting = { format = cmp_format_layout }, 35 | snippet = { 36 | expand = function(args) 37 | require("luasnip").lsp_expand(args.body) 38 | end, 39 | }, 40 | window = { 41 | documentation = { 42 | border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, 43 | }, 44 | }, 45 | sources = { 46 | { name = "nvim_lsp", keyword_length = 2 }, 47 | { name = "nvim_lua", keyword_length = 2 }, 48 | { name = "luasnip", keyword_length = 2 }, 49 | { name = "buffer", keyword_length = 4 }, 50 | { 51 | name = "tmux", 52 | keyword_length = 4, 53 | options = { 54 | all_panes = false, 55 | label = "[tmux]", 56 | }, 57 | }, 58 | { name = "path", keyword_length = 4 }, 59 | }, 60 | experimental = { 61 | -- I like the new menu better! Nice work hrsh7th 62 | native_menu = false, 63 | 64 | -- Let's play with this for a day or two 65 | ghost_text = true, 66 | }, 67 | mapping = cmp.mapping.preset.insert { 68 | [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), 69 | [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), 70 | [""] = cmp.mapping( 71 | cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, 72 | { "i" } 73 | ), 74 | [""] = cmp.mapping( 75 | cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, 76 | { "i" } 77 | ), 78 | [""] = cmp.mapping.scroll_docs(-4), 79 | [""] = cmp.mapping.scroll_docs(4), 80 | [""] = cmp.mapping { 81 | i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, 82 | }, 83 | [""] = cmp.mapping(function(fallback) 84 | if cmp.visible() then 85 | cmp.select_next_item() 86 | elseif luasnip.expand_or_locally_jumpable() then 87 | luasnip.expand_or_jump() 88 | elseif luasnip.jumpable(1) then 89 | luasnip.jump(1) 90 | elseif has_words_before() then 91 | cmp.complete() 92 | else 93 | fallback() 94 | end 95 | end, { 96 | "i", 97 | "s", 98 | }), 99 | [""] = cmp.mapping(function(fallback) 100 | if cmp.visible() then 101 | cmp.select_prev_item() 102 | elseif luasnip.jumpable(-1) then 103 | luasnip.jump(-1) 104 | else 105 | fallback() 106 | end 107 | end, { 108 | "i", 109 | "s", 110 | }), 111 | [""] = cmp.mapping.complete(), 112 | [""] = cmp.mapping { 113 | i = cmp.mapping.abort(), 114 | }, 115 | [""] = cmp.mapping.confirm { 116 | behavior = cmp.ConfirmBehavior.Replace, 117 | select = true, 118 | }, 119 | [""] = function() 120 | cmp.mapping.close() 121 | vim.cmd [[stopinsert]] 122 | end, 123 | [""] = cmp.mapping(function() 124 | if cmp.visible() then 125 | cmp.select_prev_item() 126 | elseif has_words_before() then 127 | cmp.complete() 128 | else 129 | return false 130 | end 131 | end, { 132 | "i", 133 | }), 134 | [""] = cmp.mapping(function() 135 | if cmp.visible() then 136 | cmp.select_next_item() 137 | elseif has_words_before() then 138 | cmp.complete() 139 | else 140 | return false 141 | end 142 | end, { 143 | "i", 144 | }), 145 | }, 146 | } 147 | end 148 | 149 | return M 150 | -------------------------------------------------------------------------------- /.config/fzf/helper/previewer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # dynamic preview command for dotbare 4 | # borrowed and modified from fzf.vim 5 | # 6 | # @params 7 | # Globals 8 | # reverse_seq: reverse highlight sequence for easier print 9 | # reset_seq: reset highlight sequence for eaiser print 10 | # input_option: the array containing informaiton from cmd argument 11 | # preview_file: the file path to be previewed 12 | # preview_center: the center/highlight line of the preview, if not set, display entire file 13 | # preview_lines: total lines to be previed, used to determine the first line and last line to be printed 14 | # preview_first: the first line number of the file to be printed 15 | # preview_last: the last line number of the file to be printed 16 | # file_mime: mime of the file, used to display information for binary file 17 | # Arguments 18 | # $1: The filename and line info to be previewed 19 | # Format: filepath[:lineno][:ignored] 20 | # Example 21 | # preview "$HOME/.bashrc:15" 22 | 23 | ####################################### 24 | # display the preview of the file 25 | # construct argument for the action, execute and exit 26 | # Arguments: 27 | # $1: the file path to be previewed 28 | # $2: the first line number to be previewd, optional 29 | # $3: the center/highlight line in the preview, optional 30 | # $4: the last line number to be previewed, optional 31 | # Note: 32 | # if the line number information such as $2 $3 $4 is not given, the entire 33 | # file will be printed. 34 | # Otherwise only the $2-$4 parts of the file will be printed and $3 will be highlighted 35 | ####################################### 36 | function display_preview() { 37 | local preview_cmd preview_file preview_first preview_last preview_center 38 | preview_file="$1" 39 | preview_first="$2" 40 | preview_center="$3" 41 | preview_last="$4" 42 | preview_cmd="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}" 43 | preview_cmd=${preview_cmd//{\}/$(printf %q "${preview_file}")} 44 | 45 | if [[ -z "${preview_first}" ]] || [[ -z "${preview_center}" ]] || [[ -z "${preview_last}" ]]; then 46 | if command -v bat >/dev/null; then 47 | bat --color=always --pager=never "${preview_file}" 48 | exit $? 49 | fi 50 | eval "${preview_cmd}" 2>/dev/null 51 | exit 0 52 | else 53 | if command -v bat >/dev/null; then 54 | bat --color=always --pager=never \ 55 | --line-range="${preview_first}":"${preview_last}" --highlight-line="${preview_center}" "${preview_file}" 56 | exit $? 57 | fi 58 | eval "${preview_cmd}" 2>/dev/null | 59 | awk "NR >= ${preview_first} && NR <= ${preview_last} { \ 60 | if (NR == ${preview_center}) \ 61 | { gsub(/\x1b[[0-9;]*m/, \"&${reverse_seq}\"); printf(\"${reverse_seq}%s\n${reset_seq}\", \$0); } \ 62 | else \ 63 | printf(\"${reset_seq}%s\n\", \$0); \ 64 | }" 65 | exit 0 66 | fi 67 | } 68 | 69 | reverse_seq="\x1b[7m" 70 | reset_seq="\x1b[m" 71 | 72 | IFS=':' read -r -a input_option <<<"$1" 73 | preview_file=${input_option[0]} 74 | preview_center=${input_option[1]} 75 | 76 | # potential fix for windows? Although I don't think dotbare will be usable in windows yet 77 | if [[ $1 =~ ^[A-Z]:\\ ]]; then 78 | preview_file=$preview_file:${input_option[1]} 79 | preview_center=${input_option[2]} 80 | fi 81 | 82 | preview_file="${preview_file/#\~\//$HOME/}" 83 | if [ ! -r "${preview_file}" ]; then 84 | echo "File not found ${preview_file}" 85 | exit 1 86 | fi 87 | 88 | # if binary, display binary info and exit 89 | file_mime=$(file --dereference --mime "${preview_file}") 90 | [[ "${file_mime}" =~ binary ]] && 91 | echo "${file_mime}" && 92 | exit 0 93 | 94 | # if no line number was given, just preview the entire file 95 | [[ -z "${preview_center}" ]] && display_preview "${preview_file}" 96 | 97 | # if invalid line number was given, just preview the entire file 98 | [[ -n "${preview_center}" && ! "${preview_center}" =~ ^[0-9] ]] && display_preview "${preview_file}" 99 | 100 | # get the size of the termianl window and determine the first line and last line 101 | preview_center=${preview_center/[^0-9]*/} 102 | 103 | if [ -n "${FZF_PREVIEW_LINES}" ]; then 104 | preview_lines="${FZF_PREVIEW_LINES}" 105 | else 106 | if [ -r /dev/tty ]; then 107 | preview_lines=$(stty size /dev/null) 104 | 105 | export MANPAGER='less -s -M +Gg' 106 | 107 | export VCPKG_DISABLE_METRICS=1 108 | } 109 | 110 | setup_functions=( 111 | __setup_defaults 112 | __setup_cli_colors 113 | __setup_xdg 114 | __setup_history 115 | __setup_fzf 116 | __setup_misc 117 | ) 118 | 119 | for func in "${setup_functions[@]}"; do 120 | "$func" 121 | unset -f "$func" 122 | done 123 | unset setup_functions 124 | 125 | bin_list=( 126 | "$HOME/.local/bin" 127 | "$HOME/local/bin" 128 | "$HOME/bin" 129 | "$CARGO_HOME/bin" 130 | "$GEM_HOME/bin" 131 | "$NPM_HOME/bin" 132 | "$GOPATH/bin" 133 | "$XDG_CONFIG_HOME/rofi/bin" 134 | "$XDG_CONFIG_HOME/tmux/bin" 135 | "$XDG_DATA_HOME/nvim/mason/bin" 136 | ) 137 | 138 | for extra in "${bin_list[@]}"; do 139 | PATH=$extra:$PATH 140 | done 141 | export PATH 142 | unset bin_list 143 | 144 | # just in case latest zsh is not in '/usr/bin' 145 | # it's probably unnecessary 146 | SHELL="$(command -v zsh)" 147 | export SHELL 148 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/lsp/null-ls.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local path = require("null-ls.utils").path 4 | local root_pattern = require("null-ls.utils").root_pattern 5 | local nls_cache = require("null-ls.helpers").cache 6 | 7 | local py_cwd = function(params) 8 | local root_files = { 9 | "pyproject.toml", 10 | "setup.py", 11 | "setup.cfg", 12 | "requirements.txt", 13 | "Pipfile", 14 | "pyrightconfig.json", 15 | ".flake8", 16 | } 17 | return root_pattern(unpack(root_files))(params.bufname) 18 | end 19 | 20 | function M.config() 21 | return { 22 | formatters = { 23 | -- { command = "black", extra_args = {}, filetypes = { "python" }, cwd = py_cwd }, 24 | { command = "cmake-format" }, 25 | -- { command = "isort", extra_args = {}, filetypes = { "python" }, cwd = py_cwd }, 26 | { command = "stylua", extra_args = {}, filetypes = { "lua" } }, 27 | { command = "shfmt", extra_args = { "-i", "2", "-ci", "-bn" }, filetypes = { "sh" } }, 28 | { 29 | command = "uncrustify", 30 | filetypes = { "c" }, 31 | extra_args = { "-q", "-l", "C", "-c", "src/uncrustify.cfg", "--no-backup" }, 32 | cwd = nls_cache.by_bufnr(function(params) 33 | return root_pattern "src/uncrustify.cfg"(params.bufname) 34 | end), 35 | condition = function(utils) 36 | return utils.root_has_file "src/uncrustify.cfg" 37 | end, 38 | }, 39 | }, 40 | linters = { 41 | { 42 | command = "luacheck", 43 | extra_args = {}, 44 | filetypes = { "lua" }, 45 | -- cwd = nls_cache.by_bufnr(function(params) -- force luacheck to find its '.luacheckrc' file 46 | -- return root_pattern ".luacheckrc"(params.bufname) 47 | -- end), 48 | runtime_condition = nls_cache.by_bufnr(function(params) 49 | return path.exists(path.join(params.root, ".luacheckrc")) 50 | end), 51 | }, 52 | -- { command = "flake8", extra_args = {}, filetypes = { "python" }, cwd = py_cwd }, 53 | }, 54 | code_actions = { 55 | -- { command = "proselint" }, 56 | }, 57 | } 58 | end 59 | 60 | function M.list_registered_providers_names(filetype) 61 | local s = require "null-ls.sources" 62 | local available_sources = s.get_available(filetype) 63 | local registered = {} 64 | for _, source in ipairs(available_sources) do 65 | for method in pairs(source.methods) do 66 | registered[method] = registered[method] or {} 67 | table.insert(registered[method], source.name) 68 | end 69 | end 70 | return registered 71 | end 72 | 73 | function M.list_registered_formatters(filetype) 74 | local null_ls_methods = require "null-ls.methods" 75 | local formatter_method = null_ls_methods.internal["FORMATTING"] 76 | local registered_providers = M.list_registered_providers_names(filetype) 77 | return registered_providers[formatter_method] or {} 78 | end 79 | 80 | function M.list_registered_linters(filetype) 81 | local null_ls_methods = require "null-ls.methods" 82 | local linter_method = null_ls_methods.internal["DIAGNOSTICS"] 83 | local registered_providers = M.list_registered_providers_names(filetype) 84 | return registered_providers[linter_method] or {} 85 | end 86 | 87 | function M.register_sources(configs, method) 88 | local null_ls = require "null-ls" 89 | 90 | local sources, registered_names = {}, {} 91 | 92 | for _, config in ipairs(configs) do 93 | local cmd = config.exe or config.command 94 | local name = config.name or cmd:gsub("-", "_") 95 | local type = method == null_ls.methods.CODE_ACTION and "code_actions" 96 | or null_ls.methods[method]:lower() 97 | local source = type and null_ls.builtins[type][name] 98 | if not source then 99 | vim.notify("Not a valid source: " .. name, vim.log.levels.ERROR) 100 | else 101 | local command = source._opts.command 102 | 103 | -- treat `args` as `extra_args` for backwards compatibility. Can otherwise use `generator_opts.args` 104 | local compat_opts = vim.deepcopy(config) 105 | if config.args then 106 | compat_opts.extra_args = config.args or config.extra_args 107 | compat_opts.args = nil 108 | end 109 | 110 | local opts = vim.tbl_deep_extend("keep", { command = command }, compat_opts) 111 | table.insert(sources, source.with(opts)) 112 | vim.list_extend(registered_names, { source.name }) 113 | end 114 | end 115 | 116 | if #sources > 0 then 117 | null_ls.register { sources = sources } 118 | end 119 | return registered_names 120 | end 121 | 122 | function M.setup() 123 | local config = M.config() 124 | 125 | local null_ls = require "null-ls" 126 | 127 | local default_opts = require("user.lsp").get_common_opts() 128 | local opts = vim.tbl_deep_extend("force", default_opts, { log = { level = "warn" } }) 129 | null_ls.setup(opts) 130 | 131 | M.register_sources(config.formatters, null_ls.methods.FORMATTING) 132 | M.register_sources(config.linters, null_ls.methods.DIAGNOSTICS) 133 | M.register_sources(config.code_actions, null_ls.methods.CODE_ACTION) 134 | end 135 | 136 | return M 137 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/nvimtree.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local function on_attach(bufnr) 4 | local api = require "nvim-tree.api" 5 | 6 | local function opts(desc) 7 | return { 8 | desc = "nvim-tree: " .. desc, 9 | buffer = bufnr, 10 | noremap = true, 11 | silent = true, 12 | nowait = true, 13 | } 14 | end 15 | 16 | local function telescope_find_files(_) 17 | require("core.nvimtree").start_telescope "find_files" 18 | end 19 | 20 | local function telescope_live_grep(_) 21 | require("core.nvimtree").start_telescope "live_grep" 22 | end 23 | 24 | api.config.mappings.default_on_attach(bufnr) 25 | 26 | local useful_keys = { 27 | ["l"] = { api.node.open.edit, opts "Open" }, 28 | ["o"] = { api.node.open.edit, opts "Open" }, 29 | [""] = { api.node.open.edit, opts "Open" }, 30 | ["v"] = { api.node.open.vertical, opts "Open: Vertical Split" }, 31 | ["h"] = { api.node.navigate.parent_close, opts "Close Directory" }, 32 | ["C"] = { api.tree.change_root_to_node, opts "CD" }, 33 | ["gtg"] = { telescope_live_grep, opts "Telescope Live Grep" }, 34 | ["gtf"] = { telescope_find_files, opts "Telescope Find File" }, 35 | } 36 | 37 | require("user.keymaps").load_mode("n", useful_keys) 38 | end 39 | 40 | function M.setup() 41 | local status_ok, _ = pcall(require, "nvim-tree") 42 | if not status_ok then 43 | error "failed to load nvim-tree.config" 44 | return 45 | end 46 | 47 | local setup_opts = { 48 | auto_reload_on_write = true, 49 | create_in_closed_folder = false, 50 | disable_netrw = true, 51 | hijack_cursor = true, 52 | hijack_netrw = true, 53 | hijack_unnamed_buffer_when_opening = false, 54 | -- ignore_buffer_on_setup = false, 55 | ignore_buf_on_tab_change = {}, 56 | sort_by = "name", 57 | root_dirs = {}, 58 | prefer_startup_root = false, 59 | sync_root_with_cwd = true, 60 | reload_on_bufenter = false, 61 | respect_buf_cwd = true, 62 | select_prompts = false, 63 | update_focused_file = { 64 | enable = true, 65 | update_root = true, -- maybe replace with fs_event 66 | ignore_list = {}, 67 | }, 68 | hijack_directories = { 69 | -- kyazdani42/nvim-tree.lua#1363 70 | enable = false, 71 | }, 72 | system_open = { 73 | cmd = nil, 74 | args = {}, 75 | }, 76 | notify = { 77 | threshold = vim.log.levels.INFO, 78 | }, 79 | git = { 80 | enable = true, 81 | ignore = false, 82 | show_on_dirs = true, 83 | timeout = 200, 84 | }, 85 | on_attach = on_attach, 86 | view = { 87 | adaptive_size = false, 88 | -- hide_root_folder = false, 89 | centralize_selection = true, 90 | side = "left", 91 | preserve_window_proportions = false, 92 | number = false, 93 | relativenumber = false, 94 | signcolumn = "yes", 95 | }, 96 | renderer = { 97 | add_trailing = false, 98 | group_empty = false, 99 | highlight_git = false, 100 | highlight_opened_files = "none", 101 | root_folder_modifier = ":~", 102 | indent_markers = { 103 | enable = false, 104 | icons = {}, 105 | }, 106 | icons = { 107 | webdev_colors = true, 108 | git_placement = "before", 109 | padding = " ", 110 | symlink_arrow = " ➛ ", 111 | show = { 112 | file = true, 113 | folder = true, 114 | folder_arrow = true, 115 | git = true, 116 | }, 117 | glyphs = {}, 118 | }, 119 | special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" }, 120 | }, 121 | filters = { 122 | dotfiles = false, 123 | custom = {}, 124 | exclude = {}, 125 | }, 126 | filesystem_watchers = { 127 | enable = true, 128 | debounce_delay = 50, 129 | }, 130 | actions = { 131 | use_system_clipboard = true, 132 | change_dir = { 133 | enable = false, 134 | global = false, 135 | restrict_above_cwd = false, 136 | }, 137 | expand_all = { 138 | max_folder_discovery = 300, 139 | }, 140 | open_file = { 141 | quit_on_open = false, 142 | resize_window = true, 143 | window_picker = { 144 | enable = false, 145 | }, 146 | }, 147 | remove_file = { 148 | close_window = true, 149 | }, 150 | }, 151 | diagnostics = nil, 152 | live_filter = { 153 | prefix = "[FILTER]: ", 154 | always_show_folders = true, -- this gets confusing otherwise 155 | }, 156 | log = { 157 | enable = false, 158 | truncate = false, 159 | types = { 160 | all = false, 161 | config = false, 162 | copy_paste = false, 163 | diagnostics = false, 164 | git = false, 165 | profile = false, 166 | }, 167 | }, 168 | } 169 | 170 | require("nvim-tree").setup(setup_opts) 171 | end 172 | 173 | function M.start_telescope(telescope_mode) 174 | local node = require("nvim-tree.lib").get_node_at_cursor() 175 | local abspath = node.link_to or node.absolute_path 176 | local is_folder = node.open ~= nil 177 | local basedir = is_folder and abspath or vim.fn.fnamemodify(abspath, ":h") 178 | require("telescope.builtin")[telescope_mode] { 179 | cwd = basedir, 180 | } 181 | end 182 | 183 | return M 184 | -------------------------------------------------------------------------------- /.config/lf/lfrc: -------------------------------------------------------------------------------- 1 | set shellopts '-eu' 2 | 3 | set hidden true 4 | set icons true 5 | set ignorecase true 6 | set info size:time 7 | set period 1 8 | set preview true 9 | set previewer ~/.config/lf/preview 10 | set ratios 1:1:3 11 | set scrolloff 10 12 | 13 | map scrollup 14 | map scrolldown 15 | 16 | cmd scrolldown &{{ 17 | file="$f" 18 | step=5 19 | # Retrieve the current preview offset. 20 | 21 | if ! rg "$file" "$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 2>/dev/null; then 22 | offset=1 23 | else 24 | offset="$(rg "(\d) $file" --only-matching --no-line-number --replace '$1' "$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 2>/dev/null)" 25 | offset=$((offset+step)) 26 | fi 27 | # Increment the offset. 28 | echo "$offset $file" >"$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 29 | 30 | # Trigger a reload. 31 | lf -remote "send $id reload" 32 | }} 33 | 34 | cmd scrollup &{{ 35 | file="$f" 36 | step=5 37 | if ! rg "$file" "$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 2>/dev/null; then 38 | offset=1 39 | else 40 | # Retrieve the current preview offset. 41 | offset="$(rg "(\d) $file" --only-matching --no-line-number --replace '$1' "$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 2>/dev/null)" 42 | if [ "$offset" -gt step ]; then 43 | offset=$((offset-step)) 44 | fi 45 | fi 46 | 47 | echo "$offset $file" >"$LF_SCROLLINGPREVIEW_TEMPDIR/offset" 48 | lf -remote "send $id reload" 49 | }} 50 | 51 | # TODO: figure out why zle-cd is broken.. 52 | cmd zle-cd %printf 'cd %q && zle reset-prompt\n' "$PWD" >&$ZLE_FIFO 53 | 54 | cmd zle-insert-relative %{{ 55 | for f in "$fx"; do 56 | printf 'LBUFFER+="${LBUFFER:+ }${(q)$(realpath %q --relative-to=$PWD)}"\n' "$f" >&$ZLE_FIFO 57 | done 58 | }} 59 | cmd zle-insert-absolute %{{ 60 | for f in "$fx"; do 61 | printf 'LBUFFER+="${LBUFFER:+ }%q"\n' "$f" >&$ZLE_FIFO 62 | done 63 | }} 64 | 65 | cmd zle-init :{{ 66 | map . zle-cd 67 | map x zle-insert-relative 68 | map X zle-insert-absolute 69 | }} 70 | 71 | # fzf integration 72 | cmd fzf_jump ${{ 73 | res="$(find . -maxdepth 1 | fzf --reverse --header='Jump to location')" 74 | if [ -f "$res" ]; then 75 | cmd="select" 76 | elif [ -d "$res" ]; then 77 | cmd="cd" 78 | fi 79 | lf -remote "send $id $cmd \"$res\"" 80 | }} 81 | 82 | # zoxide integration https://github.com/gokcehan/lf/issues/540 83 | cmd zoxide %lf -remote "send $id cd '$(zoxide query $1)'" 84 | 85 | 86 | cmd open ${{ 87 | case $(file --mime-type "$f" -b) in 88 | text/*) $EDITOR "$fx";; 89 | *) for f in "$fx"; do setsid $OPENER "$f" > /dev/null 2> /dev/null & done;; 90 | esac 91 | }} 92 | 93 | cmd toggle-preview ${{ 94 | case $(file --mime-type "$f" -b) in 95 | text/*) 96 | ~/.config/lf/preview "$f" 97 | ;; 98 | *) 99 | ~/.config/lf/preview "$f" | bat --paging=always --language=yaml 100 | ;; 101 | esac 102 | }} 103 | 104 | cmd open_with_lnav ${{ 105 | lnav "$f" 106 | }} 107 | 108 | cmd rpc_nvim_edit ${{ 109 | nvim --server ${NVIM_LISTEN_ADDRESS:-/run/user/1000/nvim.*} --remote "$f" 110 | }} 111 | 112 | cmd yank-dirname $dirname -- "$f" | head -c-1 | xclip -i -selection clipboard 113 | cmd yank-path $printf '%s' "$fx" | xclip -i -selection clipboard 114 | cmd yank-basename $basename -a -- "$fx" | head -c-1 | xclip -i -selection clipboard 115 | 116 | cmd mkdir %[ -n "${1}" ] && mkdir -p ${@} || echo "Argument needed" 117 | cmd mkfile %[ -n "${1}" ] && touch ${@} || echo "Argument needed" 118 | 119 | cmd trash ${{ 120 | IFS="$(printf '\n\t')"; gio trash $fx 121 | }} 122 | 123 | 124 | # define a custom 'delete' command 125 | cmd delete ${{ 126 | printf "delete?[y/n]" 127 | read ans 128 | [ $ans = "y" ] && rm -rf $fs 129 | }} 130 | 131 | # FIXME: not working currently 132 | cmd bulkrename ${{ 133 | bash -c "vimv $fx" 134 | }} 135 | 136 | # check the terminal width on startup and set number of columns accordingly 137 | %{{ 138 | w=$(tput cols) 139 | if [ $w -le 80 ]; then 140 | lf -remote "send $id set ratios 1:2" 141 | elif [ $w -le 160 ]; then 142 | lf -remote "send $id set ratios 1:2:3" 143 | else 144 | lf -remote "send $id set ratios 1:2:3:5" 145 | fi 146 | }} 147 | 148 | # start an lf server for ZLE integration 149 | &[[ -n "$ZLE_FIFO" ]] && lf -remote "send $id zle-init" 150 | 151 | # make sure trash folder exists 152 | %mkdir -p ~/.local/share/Trash 153 | 154 | # Basic Functions 155 | map quit 156 | map quit 157 | map reload 158 | map open 159 | map C clear 160 | map H top 161 | map L bottom 162 | map u unselect 163 | map br bulkrename 164 | map r rename 165 | map i toggle-preview 166 | 167 | # create dir/file 168 | map ad push $mkdir 169 | map af push $touch 170 | 171 | # Tmux 172 | map tv &tmux split-window -h zsh 173 | map tb &tmux split-window -v zsh 174 | map t+ &tmux split-window -h zsh 175 | map t- &tmux split-window -v zsh 176 | 177 | map d cut 178 | map y copy 179 | map p paste 180 | 181 | map yank-path 182 | map Yd yank-dirname 183 | map Yb yank-basename 184 | 185 | map Dd trash 186 | map DD delete 187 | 188 | map :fzf_jump 189 | map $lf -remote "send $id select '$(fzf)'" 190 | 191 | map L open_with_lnav 192 | map E rpc_nvim_edit 193 | map Xvp push :!nvim 194 | 195 | # Zoxide jump 196 | map gj push :zoxide 197 | map gc z ~/.config 198 | map gd z ~/.local/share 199 | map gT z ~/local/share/Trash 200 | 201 | # show documentation 202 | map g? $lf -doc | bat -l man 203 | 204 | # vim: ft=lfrc 205 | -------------------------------------------------------------------------------- /.config/nvim/lua/user/autocmds.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local base_definitions = { 4 | { 5 | "TextYankPost", 6 | { 7 | group = "_general_settings", 8 | pattern = "*", 9 | desc = "Highlight text on yank", 10 | callback = function() 11 | vim.highlight.on_yank { higroup = "Search", timeout = 200 } 12 | end, 13 | }, 14 | }, 15 | { 16 | "FileType", 17 | { 18 | group = "_filetype_settings", 19 | pattern = { "gitcommit", "markdown" }, 20 | command = "setl fdm=indent fdl=4 spc= cole=1 cocu=nc list lcs=trail:* tw=100", 21 | }, 22 | }, 23 | { 24 | "FileType", 25 | { 26 | group = "_buffer_mappings", 27 | pattern = { 28 | "qf", 29 | "help", 30 | "man", 31 | "floaterm", 32 | "lspinfo", 33 | "lir", 34 | "lsp-installer", 35 | "null-ls-info", 36 | "tsplayground", 37 | }, 38 | callback = function() 39 | vim.keymap.set("n", "q", "close", { buffer = true }) 40 | vim.opt_local.buflisted = false 41 | end, 42 | }, 43 | }, 44 | 45 | { 46 | "FileType", 47 | { 48 | group = "_filetype_settings", 49 | pattern = "TelescopePrompt", 50 | callback = function() 51 | require("cmp").setup.buffer { enabled = false } 52 | end, 53 | }, 54 | }, 55 | { 56 | "VimResized", 57 | { 58 | group = "_auto_resize", 59 | pattern = "*", 60 | command = "tabdo wincmd =", 61 | }, 62 | }, 63 | { 64 | "DirChanged", 65 | { 66 | group = "_general_settings", 67 | pattern = "*", 68 | callback = require("user.utils").on_dir_changed, 69 | }, 70 | }, 71 | { 72 | "DirChanged", 73 | { 74 | group = "_general_settings", 75 | pattern = "*", 76 | desc = "set osc7 so that tmux can see it", 77 | command = [[call chansend(v:stderr, printf("\033]7;%s\033", v:event.cwd))]], 78 | }, 79 | }, 80 | { 81 | "ExitPre", 82 | { 83 | group = "_general_settings", 84 | pattern = "*", 85 | desc = "reset cursor back when leaving Neovim", 86 | command = "set guicursor=a:ver90", 87 | }, 88 | }, 89 | } 90 | 91 | function M.toggle_format_on_save(opts) 92 | opts = opts 93 | or { 94 | ---used for the autocommand, see |autpat| 95 | pattern = vim.fn.stdpath "config" .. "/**/*.lua", 96 | ---time in ms for the format request 97 | timeout = 1000, 98 | ---function to select client 99 | filter = function(clients) 100 | return vim.tbl_filter(function(client) 101 | local status_ok, method_supported = pcall(function() 102 | return client.server_capabilities.documentFormattingProvider 103 | end) 104 | -- give higher prio to null-ls 105 | if status_ok and method_supported and client.name == "null-ls" then 106 | return true 107 | else 108 | return status_ok and method_supported and client.name 109 | end 110 | end, clients) 111 | end, 112 | } 113 | local status, _ = pcall(vim.api.nvim_get_autocmds, { 114 | group = "lsp_format_on_save", 115 | event = "BufWritePre", 116 | }) 117 | if not status then 118 | -- vim.notify("setting up fmt_on_save", vim.log.levels.DEBUG) 119 | vim.api.nvim_create_augroup("lsp_format_on_save", {}) 120 | vim.api.nvim_create_autocmd("BufWritePre", { 121 | group = "lsp_format_on_save", 122 | pattern = opts.pattern, 123 | callback = function() 124 | vim.lsp.buf.format { timeout_ms = opts.timeout, filter = opts.filter } 125 | end, 126 | }) 127 | else 128 | vim.api.nvim_del_augroup_by_name "lsp_format_on_save" 129 | end 130 | end 131 | 132 | --- Clean autocommand in a group if it exists 133 | --- This is safer than trying to delete the augroup itself 134 | ---@param name string the augroup name 135 | function M.clear_augroup(name) 136 | vim.schedule(function() 137 | local status_ok, _ = xpcall(function() 138 | vim.api.nvim_clear_autocmds { group = name } 139 | end, debug.traceback) 140 | if not status_ok then 141 | vim.notify("problems detected while clearing autocmds from " .. name) 142 | end 143 | end) 144 | end 145 | 146 | --- Create autocommand groups based on the passed definitions 147 | --- Also creates the augroup automatically if it doesn't exist 148 | ---@param definitions table contains a tuple of event, opts, see `:h nvim_create_autocmd` 149 | function M.define_autocmds(definitions) 150 | for _, entry in ipairs(definitions) do 151 | local event = entry[1] 152 | local opts = entry[2] 153 | if type(opts.group) == "string" and opts.group ~= "" then 154 | local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group }) 155 | if not exists then 156 | vim.api.nvim_create_augroup(opts.group, {}) 157 | end 158 | end 159 | vim.api.nvim_create_autocmd(event, opts) 160 | end 161 | end 162 | 163 | function M.hide_eol() 164 | vim.opt.conceallevel = 3 165 | vim.opt.concealcursor = "nvic" 166 | vim.api.nvim_set_hl(0, "Ignore", { ctermfg = 15, fg = "bg" }) 167 | vim.api.nvim_create_autocmd("BufReadPost", { 168 | buffer = 0, 169 | command = "match Ignore /\r$/", 170 | }) 171 | vim.cmd ":e" 172 | end 173 | 174 | function M.setup() 175 | M.define_autocmds(base_definitions) 176 | M.toggle_format_on_save() 177 | vim.filetype.add { extension = { ["rasi"] = "rasi" } } 178 | end 179 | 180 | return M 181 | -------------------------------------------------------------------------------- /.config/hypr/hyprland.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Please note not all available settings / options are set here. 3 | # For a full list, see the wiki (basic and advanced configuring) 4 | # 5 | 6 | exec-once=bash ~/.config/hypr/scripts/fix-portals.sh 7 | exec=bash ~/.config/hypr/scripts/import-gsettings.sh 8 | 9 | exec-once=bash ~/.config/hypr/scripts/autostart.sh 10 | exec-once=/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 11 | 12 | monitor=,preferred,auto,1 13 | 14 | master { 15 | new_on_top=true 16 | # new_is_master=true 17 | no_gaps_when_only=false 18 | } 19 | 20 | dwindle { 21 | pseudotile=1 # enable pseudotiling on dwindle 22 | special_scale_factor=0.8 23 | force_split=1 24 | no_gaps_when_only=false 25 | preserve_split=true 26 | } 27 | 28 | general { 29 | gaps_in=5 30 | gaps_out=10 31 | border_size=2 32 | col.active_border=0xff5e81ac 33 | col.inactive_border=0x66333333 34 | 35 | # no_cu sor_warps=true # don't move the cursor when changing focus 36 | # cursor_inactive_timeout=3 37 | 38 | layout=master 39 | } 40 | 41 | decoration { 42 | rounding=10 43 | inactive_opacity=1 44 | 45 | drop_shadow= true 46 | shadow_range= 4 47 | shadow_render_power=3 48 | col.shadow=rgba(1a1a1aee) 49 | } 50 | 51 | animations { 52 | enabled=true 53 | } 54 | 55 | input { 56 | # kb_layout=us 57 | # kb_options=caps:escape 58 | # follow_mouse=0 59 | 60 | touchpad { 61 | natural_scroll=false 62 | # disable_while_typing=false 63 | } 64 | 65 | # sensitivity=0 # -1.0 - 1.0, 0 means no modification. 66 | } 67 | 68 | gestures { 69 | workspace_swipe=true 70 | workspace_swipe_min_speed_to_force=4 71 | } 72 | 73 | binds { 74 | # scroll_event_delay=1000 75 | allow_workspace_cycles=false 76 | workspace_back_and_forth=false 77 | } 78 | 79 | xwayland { 80 | force_zero_scaling = false 81 | } 82 | 83 | misc { 84 | # VFR increases battery life at the expense of possible issues on a few monitors. 85 | # no_vfr=true 86 | # If DPMS is set to off, wake up the monitors if the mouse moves. default: false 87 | mouse_move_enables_dpms=true 88 | # to stop Hyprland from reloading configuration 89 | disable_autoreload=true 90 | # background logo 91 | disable_hyprland_logo=true 92 | } 93 | 94 | windowrulev2=float,class:(blueman-manager|rofi|nemo|Nautilus|imv|feh|pavucontrol|Tk) 95 | windowrulev2=workspace 3,class:([Ee]lement) 96 | windowrulev2=workspace 5,class:([Ee]dge) 97 | windowrulev2=float,class:([Ee]dge) 98 | 99 | $launcher = bash ~/.config/hypr/scripts/launcher.sh 100 | $clipper = bash ~/.config/hypr/scripts/clip.sh 101 | $menu = rofi -show drun -display-drun '> ' -no-disable-history -theme dmenu 102 | $chrmium = bash ~/.local/bin/chromium 103 | $kbSwitch = bash ~/.config/hypr/scripts/switch-kb.sh 104 | $fileManager = nemo --geometry=1200x800 105 | 106 | bind=CTRLSUPER,R,exec,hyprctl reload 107 | 108 | bind=SHIFT_L,SHIFT_R,exec,$kbSwitch 109 | bind=ALT,G,exec,librewolf 110 | bind=ALT,p,pin, 111 | bind=SUPER,G,exec,$chromium 112 | bind=SUPER,RETURN,exec,alacritty 113 | bind=SUPER,C,killactive, 114 | bind=SUPER,Q,killactive, 115 | bind=SUPER,E,exec,$fileManager 116 | bind=SUPER,P,exec,$clipper 117 | bind=SUPER,F,togglefloating, 118 | bind=SUPER,space,exec,$launcher 119 | bind=SUPER,R,exec,$menu 120 | 121 | bind=CTRLALT,RETURN,fullscreen,0 122 | bind=ALT,RETURN,fullscreen,1 123 | bind=ALTSUPER,RETURN,fullscreen,2 124 | 125 | bind=SUPER,h,movefocus,l 126 | bind=SUPER,l,movefocus,r 127 | bind=SUPER,k,movefocus,u 128 | bind=SUPER,j,movefocus,d 129 | 130 | bind=SUPER,left,movefocus,l 131 | bind=SUPER,right,movefocus,r 132 | bind=SUPER,up,movefocus,u 133 | bind=SUPER,down,movefocus,d 134 | 135 | bind=CTRLSUPER,left,resizeactive,-40 0 136 | bind=CTRLSUPER,right,resizeactive,40 0 137 | 138 | bind=SUPERSHIFT,left,swapnext 139 | bind=SUPERSHIFT,right,swapnext,prev 140 | 141 | bind=ALT,TAB,cyclenext 142 | bind=ALTSHIFT,TAB,cyclenext,prev 143 | 144 | bind=SUPER,TAB,workspace,e+1 145 | bind=SUPERSHIFT,TAB,workspace,e-1 146 | 147 | bind=SUPER,1,workspace,1 148 | bind=SUPER,2,workspace,2 149 | bind=SUPER,3,workspace,3 150 | bind=SUPER,4,workspace,4 151 | bind=SUPER,5,workspace,5 152 | bind=SUPER,6,workspace,6 153 | bind=SUPER,7,workspace,7 154 | bind=SUPER,8,workspace,8 155 | 156 | bind=SUPERSHIFT,1,movetoworkspace,1 157 | bind=SUPERSHIFT,2,movetoworkspace,2 158 | bind=SUPERSHIFT,3,movetoworkspace,3 159 | bind=SUPERSHIFT,4,movetoworkspace,4 160 | bind=SUPERSHIFT,5,movetoworkspace,5 161 | bind=SUPERSHIFT,6,movetoworkspace,6 162 | bind=SUPERSHIFT,7,movetoworkspace,7 163 | bind=SUPERSHIFT,8,movetoworkspace,8 164 | 165 | bind=SUPER,d,togglespecialworkspace 166 | bind=SUPERSHIFT,d,movetoworkspace,special 167 | 168 | bindl=,XF86AudioLowerVolume,exec,amixer -Mq set Master 5%- unmute 169 | bindl=,XF86AudioRaiseVolume,exec,amixer -Mq set Master 5%+ unmute 170 | bindl=,XF86AudioMute,exec,amixer -Mq set Master toggle 171 | 172 | # Move/resize windows with mainMod + LMB/RMB and dragging 173 | bindm=SUPER,mouse:272,movewindow 174 | bindm=SUPER,mouse:273,resizewindow 175 | 176 | # toolkit-specific scale 177 | env = WLR_DRM_DEVICES,$HOME/.config/hypr/card 178 | env = QT_AUTO_SCREEN_SCALE_FACTOR,1 # enables automatic scaling, based on the monitor's pixel density 179 | env = QT_QPA_PLATFORM,"wayland;xcb" # - Tell QT applications to use the Wayland backend, and fall back to x11 if Wayland is unavailable 180 | env = QT_WAYLAND_DISABLE_WINDOWDECORATION.1 # - Disables window decorations on QT applications 181 | env = QT_QPA_PLATFORMTHEME,qt5ct # - Tells QT based applications to pick your theme from qt5ct, use with Kvantum. 182 | # env = GDK_SCALE,2 183 | # env = XCURSOR_SIZE,32 184 | 185 | 186 | # vim: ft=toml 187 | -------------------------------------------------------------------------------- /.config/nvim/lua/core/git.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.setup_gitsigns() 4 | require("gitsigns").setup { 5 | signs = { 6 | add = { text = "│" }, 7 | change = { text = "│" }, 8 | delete = { text = "_" }, 9 | topdelete = { text = "‾" }, 10 | changedelete = { text = "~" }, 11 | }, 12 | sign_priority = 10000, 13 | current_line_blame_formatter = " (, )", 14 | on_attach = function(bufnr) 15 | local gs = package.loaded.gitsigns 16 | 17 | local function map(mode, l, r, opts) 18 | opts = opts or {} 19 | if type(opts) == "string" then 20 | opts = { desc = opts } 21 | end 22 | opts.buffer = bufnr 23 | vim.keymap.set(mode, l, r, opts) 24 | end 25 | 26 | -- Navigation 27 | map("n", "]c", function() 28 | if vim.wo.diff then 29 | return "]c" 30 | end 31 | vim.schedule(function() 32 | gs.next_hunk() 33 | end) 34 | return "" 35 | end, { expr = true, desc = "next hunk" }) 36 | 37 | map("n", "[c", function() 38 | if vim.wo.diff then 39 | return "[c" 40 | end 41 | vim.schedule(function() 42 | gs.prev_hunk() 43 | end) 44 | return "" 45 | end, { expr = true, desc = "prev hunk" }) 46 | 47 | -- Actions 48 | map({ "n", "v" }, "gs", gs.stage_hunk, "stage hunk") 49 | map({ "n", "v" }, "gu", gs.undo_stage_hunk, "undo stage hunk") 50 | map({ "n", "v" }, "gr", gs.reset_hunk, "reset hunk") 51 | map("n", "gS", gs.stage_buffer, "stage buffer") 52 | map("n", "gR", gs.reset_buffer, "reset buffer") 53 | map("n", "gp", gs.preview_hunk, "preview hunk") 54 | map("n", "gl", function() 55 | gs.blame_line { ignore_whitespace = true } 56 | end, "line blame") 57 | map("n", "gt", gs.toggle_current_line_blame, "toggle current line blame") 58 | map("n", "ghd", gs.diffthis, "diff this") 59 | map("n", "ghD", function() 60 | gs.diffthis "~" 61 | end, "diff this with ~") 62 | 63 | -- Text object 64 | map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "select hunk") 65 | end, 66 | } 67 | end 68 | 69 | local function get_gerrit_gitlies_type_url(url_data) 70 | local url = "https://" .. url_data.host .. "/plugins/gitiles/" .. url_data.repo 71 | if not url_data.file or not url_data.rev then 72 | return url 73 | end 74 | url = url .. "/+/" .. url_data.rev .. "/" .. url_data.file 75 | if not url_data.lstart then 76 | return url 77 | end 78 | url = url .. "#" .. url_data.lstart 79 | return url 80 | end 81 | 82 | function M.setup_gitlinker() 83 | local gitlinker = require "gitlinker" 84 | 85 | gitlinker.setup { 86 | callbacks = { 87 | ["gerrit"] = get_gerrit_gitlies_type_url, 88 | ["gitlab.*"] = require("gitlinker.hosts").get_gitlab_type_url, 89 | }, 90 | mappings = nil, 91 | } 92 | 93 | local keymaps = { 94 | normal_mode = { 95 | ["gy"] = { 96 | function() 97 | gitlinker.get_buf_range_url "n" 98 | end, 99 | "Copy line URL", 100 | }, 101 | ["gYy"] = { 102 | function() 103 | gitlinker.get_buf_range_url("n", { remote = "origin" }) 104 | end, 105 | "Copy line URL (origin)", 106 | }, 107 | ["gYr"] = { 108 | function() 109 | gitlinker.get_repo_url { remote = "origin" } 110 | end, 111 | "Copy repo URL", 112 | }, 113 | ["gYb"] = { 114 | function() 115 | M.get_github_blame_url { remote = "origin" } 116 | end, 117 | "Copy blame URL", 118 | }, 119 | }, 120 | visual_mode = { 121 | ["gy"] = { 122 | function() 123 | gitlinker.get_buf_range_url "v" 124 | end, 125 | "Copy range URL", 126 | }, 127 | ["gY"] = { 128 | function() 129 | gitlinker.get_buf_range_url("v", { remote = "origin" }) 130 | end, 131 | "Copy range URL (origin)", 132 | }, 133 | }, 134 | } 135 | 136 | require("user.keymaps").load(keymaps) 137 | end 138 | 139 | function M.get_github_blame_url(opts) 140 | local gitlinker = require "gitlinker" 141 | local user_opts = vim.tbl_deep_extend("force", { 142 | print_url = false, 143 | remote = "origin", 144 | }, opts or {}) 145 | local repo_url = gitlinker.get_repo_url(user_opts) 146 | 147 | local win_id = vim.api.nvim_get_current_win() 148 | local bufnr = vim.api.nvim_get_current_buf() 149 | local cur_pos = vim.api.nvim_win_get_cursor(win_id) 150 | ---@diagnostic disable-next-line: missing-parameter 151 | local filename = vim.api.nvim_buf_get_name(bufnr) 152 | local repo = vim.loop.cwd() 153 | local lnum = cur_pos[1] 154 | local args = { 155 | "log", 156 | "-L" .. lnum .. "," .. lnum + 1 .. ":" .. filename, 157 | "--pretty=%H", 158 | "--no-patch", 159 | } 160 | local job = require("plenary.job"):new { command = "git", args = args, cwd = repo } 161 | local commit_url 162 | job:after_success(function(this_job) 163 | local commit_sha = this_job:result()[1] 164 | commit_url = repo_url .. "/commit/" .. commit_sha 165 | vim.schedule(function() 166 | vim.notify(commit_url, vim.log.levels.INFO, { title = "commit url" }) 167 | vim.fn.setreg("+", commit_url) 168 | end) 169 | end) 170 | job:start() 171 | end 172 | 173 | return M 174 | --------------------------------------------------------------------------------