Compare commits

...

17 Commits

Author SHA1 Message Date
af123e5138 chore(deps): update brewfile 2024-11-19 11:20:24 +02:00
3879289559 feat(tmux): removal of tmux-resurrect 2024-11-18 11:42:58 +02:00
392628e733 fix(shell): fixes to zsh and bash configs 2024-11-16 16:30:57 +02:00
aa70eab5fb fix(nvim): disable statuscol on certain ft and bt 2024-11-12 05:22:01 +02:00
e5311ca285 fix(nvim): finally a working colorcolumn 2024-11-12 05:21:26 +02:00
d5618c9b5f chore(config): tweaks to nvim config, autogroups 2024-11-09 19:49:21 +02:00
d091f5a88f feat(base): add tms bundle to antigen 2024-11-09 19:48:12 +02:00
cb9195e3ad chore(config): asdf, add libtmux to python 2024-11-09 19:47:42 +02:00
c91cc387b6 chore(docs): update working on readme 2024-11-09 19:47:02 +02:00
083091ea46 chore(deps): update asdf tool-versions, plugins 2024-11-08 15:59:54 +02:00
7ff74f0e15 feat(dfm): add asdf helpers 2024-11-08 15:36:47 +02:00
9d1f62fcca feat(dfm): more helpers, enable multiple commands 2024-11-08 15:35:56 +02:00
a563e82e33 chore(base): add lando, eza fix if missing 2024-11-08 15:33:43 +02:00
62ff7836e7 chore(config): wezterm config formatting, fonts 2024-11-08 15:32:04 +02:00
88cb573027 chore(config): update oh-my-posh cfg, completions 2024-11-08 15:31:29 +02:00
82772d8208 feat(config): tms configs 2024-11-07 10:04:33 +02:00
github-actions[bot]
240035569c chore: update pre-commit hooks (#42)
Co-authored-by: ivuorinen <11024+ivuorinen@users.noreply.github.com>
2024-11-06 13:56:19 +02:00
27 changed files with 725 additions and 260 deletions

View File

@@ -8,6 +8,9 @@ indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.md]
max_line_length = 100
[*.php] [*.php]
indent_size = 4 indent_size = 4

10
.github/README.md vendored
View File

@@ -6,10 +6,10 @@ aware of yet. As I find more interesting tools, configs and other stuff,
this repository will live accordingly. this repository will live accordingly.
Please for the love of everything good do not use these 1:1 as your own dotfiles, Please for the love of everything good do not use these 1:1 as your own dotfiles,
fork or download the repo as a zip and go from there with your own configs. fork or download the repository as a zip and go from there with your own configs.
It would be nice if you'd add an issue linking to your fork or repo so I can It would be nice if you'd add an issue linking to your fork or repo so I can
see what interesing stuff you've done with it. Sharing is caring. see what interesting stuff you've done with it. Sharing is caring.
## Setup ## Setup
@@ -28,9 +28,9 @@ see what interesing stuff you've done with it. Sharing is caring.
![screenshot of the oh-my-posh shell](./screenshots/oh-my-posh.png) ![screenshot of the oh-my-posh shell](./screenshots/oh-my-posh.png)
![screenshot of light version of tmux with nvim editing this repo](./screenshots/tmux-nvim-kickstart-light.png) ![screenshot of light version of tmux with nvim editing this repository](./screenshots/tmux-nvim-kickstart-light.png)
![screenshot of dark version of tmux with nvim editing this repo](./screenshots/tmux-nvim-kickstart-dark.png) ![screenshot of dark version of tmux with nvim editing this repository](./screenshots/tmux-nvim-kickstart-dark.png)
## Interesting files and locations ## Interesting files and locations
@@ -52,7 +52,7 @@ see what interesing stuff you've done with it. Sharing is caring.
| `local/` | `.local/` | XDG Base folder: `bin`, `share` and `state` | | `local/` | `.local/` | XDG Base folder: `bin`, `share` and `state` |
| `ssh/` | `.ssh/` | SSH Configurations. | | `ssh/` | `.ssh/` | SSH Configurations. |
### dfm - the dotfiles manager ### `dfm` - the dotfiles manager
[`.local/bin/dfm`][dfm] is a shell script that has some tools that help with dotfiles management. [`.local/bin/dfm`][dfm] is a shell script that has some tools that help with dotfiles management.

4
.gitmodules vendored
View File

@@ -23,10 +23,6 @@
path = config/tmux/plugins/tmux-continuum path = config/tmux/plugins/tmux-continuum
url = https://github.com/tmux-plugins/tmux-continuum url = https://github.com/tmux-plugins/tmux-continuum
ignore = dirty ignore = dirty
[submodule "tmux/tmux-resurrect"]
path = config/tmux/plugins/tmux-resurrect
url = https://github.com/tmux-plugins/tmux-resurrect
ignore = dirty
[submodule "tmux/tmux-sensible"] [submodule "tmux/tmux-sensible"]
path = config/tmux/plugins/tmux-sensible path = config/tmux/plugins/tmux-sensible
url = https://github.com/tmux-plugins/tmux-sensible.git url = https://github.com/tmux-plugins/tmux-sensible.git

View File

@@ -45,6 +45,6 @@ repos:
- id: shfmt - id: shfmt
- repo: https://github.com/rhysd/actionlint - repo: https://github.com/rhysd/actionlint
rev: v1.7.3 rev: v1.7.4
hooks: hooks:
- id: actionlint - id: actionlint

View File

@@ -23,8 +23,6 @@ git submodule add --name tmux/tmux-continuum \
-f https://github.com/tmux-plugins/tmux-continuum config/tmux/plugins/tmux-continuum -f https://github.com/tmux-plugins/tmux-continuum config/tmux/plugins/tmux-continuum
git submodule add --name tmux/tmux-mode-indicator \ git submodule add --name tmux/tmux-mode-indicator \
-f https://github.com/MunifTanjim/tmux-mode-indicator.git config/tmux/plugins/tmux-mode-indicator -f https://github.com/MunifTanjim/tmux-mode-indicator.git config/tmux/plugins/tmux-mode-indicator
git submodule add --name tmux/tmux-resurrect \
-f https://github.com/tmux-plugins/tmux-resurrect config/tmux/plugins/tmux-resurrect
git submodule add --name tmux/tmux-sensible \ git submodule add --name tmux/tmux-sensible \
-f https://github.com/tmux-plugins/tmux-sensible.git config/tmux/plugins/tmux-sensible -f https://github.com/tmux-plugins/tmux-sensible.git config/tmux/plugins/tmux-sensible
git submodule add --name tmux/tmux-sessionist \ git submodule add --name tmux/tmux-sessionist \
@@ -49,6 +47,7 @@ done
[ -d "config/tmux/plugins/tpm" ] && rm -rf config/tmux/plugins/tpm [ -d "config/tmux/plugins/tpm" ] && rm -rf config/tmux/plugins/tpm
[ -d "config/tmux/plugins/tmux" ] && rm -rf config/tmux/plugins/tmux [ -d "config/tmux/plugins/tmux" ] && rm -rf config/tmux/plugins/tmux
[ -d "config/tmux/plugins/tmux-menus" ] && rm -rf config/tmux/plugins/tmux-menus [ -d "config/tmux/plugins/tmux-menus" ] && rm -rf config/tmux/plugins/tmux-menus
[ -d "config/tmux/plugins/tmux-resurrect" ] && rm -rf config/tmux/plugins/tmux-resurrect
[ -d "tools/dotbot-crontab" ] && rm -rf tools/dotbot-crontab [ -d "tools/dotbot-crontab" ] && rm -rf tools/dotbot-crontab
[ -d "tools/dotbot-snap" ] && rm -rf tools/dotbot-snap [ -d "tools/dotbot-snap" ] && rm -rf tools/dotbot-snap
[ -d "config/nvim-kickstart" ] && rm -rf config/nvim-kickstart [ -d "config/nvim-kickstart" ] && rm -rf config/nvim-kickstart

View File

@@ -14,10 +14,45 @@ source "$DOTFILES/config/shared.sh"
# Import ssh keys in keychain # Import ssh keys in keychain
ssh-add -A 2>/dev/null ssh-add -A 2>/dev/null
x-have oh-my-posh && {
eval "$(oh-my-posh init bash --config "$DOTFILES/config/omp/own.toml")"
}
x-have antidot && { x-have antidot && {
eval "$(antidot init)" eval "$(antidot init)"
} }
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return ;;
esac
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm* | rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*) ;;
esac
x-have oh-my-posh && {
eval "$(oh-my-posh init bash --config "$DOTFILES/config/omp/own.toml")"
}

View File

@@ -1,26 +1,26 @@
asdf-plugin-manager 1.4.0 asdf-plugin-manager 1.4.0
nodejs 23.0.0 nodejs 23.1.0
golang 1.23.2 golang 1.23.3
python 3.12.7 python 3.12.7
ruby 3.3.4 ruby 3.3.4
rust 1.82.0 rust 1.82.0
direnv 2.35.0 direnv 2.35.0
fd 10.2.0 fd 10.2.0
1password-cli 2.30.0 1password-cli 2.30.3
age 1.2.0 age 1.2.0
bottom 0.10.2 bottom 0.10.2
dotenv-linter 3.3.0 dotenv-linter 3.3.0
editorconfig-checker 2.8.0 editorconfig-checker 2.8.0
github-cli 2.59.0 github-cli 2.61.0
hadolint 2.12.0 hadolint 2.12.0
kubectl 1.31.1 kubectl 1.31.2
pipx 1.7.1 pipx 1.7.1
pre-commit 4.0.1 pre-commit 4.0.1
ripgrep 14.1.1 ripgrep 14.1.1
shellcheck 0.10.0 shellcheck 0.10.0
shfmt 3.9.0 shfmt 3.10.0
terragrunt 0.67.15 terragrunt 0.68.8
tf-summarize 0.3.11 tf-summarize 0.3.13
yamllint 1.35.1 yamllint 1.35.1
yq 4.44.3 yq 4.44.3
bats 1.11.0 bats 1.11.0

39
base/zshrc → base/zshenv Executable file → Normal file
View File

@@ -1,4 +1,5 @@
# this is my zsh config. there are many like it, but this one is mine. # this is my zsh config. there are many like it, but this one is mine.
# https://zsh.sourceforge.io/Intro/intro_3.html
# shellcheck shell=bash # shellcheck shell=bash
# export VERBOSE=1 # export VERBOSE=1
@@ -10,6 +11,16 @@ export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$LOCAL_SHARE/nvim/mason/bin:$L
export SHARED_SCRIPTS_SOURCED=0 export SHARED_SCRIPTS_SOURCED=0
source "$DOTFILES/config/shared.sh" source "$DOTFILES/config/shared.sh"
source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc"
export ZDOTDIR="$DOTFILES/zsh"
ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
eval "$(oh-my-posh init zsh --config "$DOTFILES/config/omp/own.toml")" eval "$(oh-my-posh init zsh --config "$DOTFILES/config/omp/own.toml")"
@@ -53,9 +64,10 @@ load_antigen()
antigen bundle brew antigen bundle brew
antigen bundle colored-man-pages antigen bundle colored-man-pages
antigen bundle zsh-users/zsh-completions antigen bundle zsh-users/zsh-completions
antigen bundle eza x-have eza && antigen bundle eza
x-have tms && antigen bundle yuki-ycino/tms
# this needs to be the last item # this needs to be the last bundle
antigen bundle zsh-users/zsh-syntax-highlighting antigen bundle zsh-users/zsh-syntax-highlighting
antigen apply antigen apply
fi fi
@@ -87,15 +99,16 @@ setup_tmux_window_name_plugin()
fi fi
} }
main() load_antigen
{ source_fzf_config
load_antigen setup_tmux_window_name_plugin
source_fzf_config if x-have antidot; then
setup_tmux_window_name_plugin eval "$(antidot init)"
if x-have antidot; then fi
eval "$(antidot init)"
fi
source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc"
}
main "$@" # Lando
export PATH="$HOME/.lando/bin${PATH+:$PATH}"; #landopath
autoload -Uz compinit bashcompinit
compinit -d $ZSH_COMPDUMP
bashcompinit

View File

@@ -1,6 +1,6 @@
1password-cli https://github.com/NeoHsu/asdf-1password-cli.git f5d5aab 1password-cli https://github.com/NeoHsu/asdf-1password-cli.git f5d5aab
age https://github.com/threkk/asdf-age.git 396bdf6 age https://github.com/threkk/asdf-age.git 396bdf6
asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git c721275 asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git b5862c1
bats https://github.com/timgluz/asdf-bats.git 299551f bats https://github.com/timgluz/asdf-bats.git 299551f
bottom https://github.com/carbonteq/asdf-btm.git fd8a55a bottom https://github.com/carbonteq/asdf-btm.git fd8a55a
delta https://github.com/andweeb/asdf-delta.git 501318b delta https://github.com/andweeb/asdf-delta.git 501318b
@@ -14,16 +14,16 @@ golang https://github.com/asdf-community/asdf-golang.git
hadolint https://github.com/devlincashman/asdf-hadolint.git 335e230 hadolint https://github.com/devlincashman/asdf-hadolint.git 335e230
kubectl https://github.com/asdf-community/asdf-kubectl.git 2fb3b57 kubectl https://github.com/asdf-community/asdf-kubectl.git 2fb3b57
nodejs https://github.com/asdf-vm/asdf-nodejs.git c36e6f0 nodejs https://github.com/asdf-vm/asdf-nodejs.git c36e6f0
php https://github.com/asdf-community/asdf-php.git 52c669a
pipx https://github.com/yozachar/asdf-pipx.git 31db618 pipx https://github.com/yozachar/asdf-pipx.git 31db618
pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git 26bfc42 pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git 26bfc42
python https://github.com/asdf-community/asdf-python a3a0185 python https://github.com/asdf-community/asdf-python a3a0185
ripgrep https://gitlab.com/wt0f/asdf-ripgrep.git e836665 ripgrep https://gitlab.com/wt0f/asdf-ripgrep.git e836665
ruby https://github.com/asdf-vm/asdf-ruby.git e955978 ruby https://github.com/asdf-vm/asdf-ruby.git 194fe45
rust https://github.com/code-lever/asdf-rust.git 95acf4f rust https://github.com/code-lever/asdf-rust.git 95acf4f
shellcheck https://github.com/luizm/asdf-shellcheck.git 66200ff shellcheck https://github.com/luizm/asdf-shellcheck.git 66200ff
shfmt https://github.com/luizm/asdf-shfmt.git a42c5ff shfmt https://github.com/luizm/asdf-shfmt.git a42c5ff
sops https://github.com/feniix/asdf-sops.git 5c7a2fb
terragrunt https://github.com/ohmer/asdf-terragrunt.git 4a6651a terragrunt https://github.com/ohmer/asdf-terragrunt.git 4a6651a
tf-summarize https://github.com/adamcrews/asdf-tf-summarize.git 880ad26 tf-summarize https://github.com/adamcrews/asdf-tf-summarize.git 880ad26
yamllint https://github.com/ericcornelissen/asdf-yamllint.git 2f825d9 yamllint https://github.com/ericcornelissen/asdf-yamllint.git bc2813e
yq https://github.com/sudermanjr/asdf-yq.git 772992f yq https://github.com/sudermanjr/asdf-yq.git 772992f

View File

@@ -2,3 +2,4 @@ ansible
pipenv pipenv
semgrep semgrep
neovim neovim
libtmux

View File

@@ -14,22 +14,21 @@
# if DOTFILES is not set, set it to the default location # if DOTFILES is not set, set it to the default location
[ -z "$DOTFILES" ] && export DOTFILES="$HOME/.dotfiles" [ -z "$DOTFILES" ] && export DOTFILES="$HOME/.dotfiles"
# zsh completions directory
[ -z "$ZSH_COMPLETIONS" ] && export ZSH_COMPLETIONS="$XDG_CONFIG_HOME/zsh/completion"
export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$XDG_DATA_HOME/bob/nvim-bin:$XDG_DATA_HOME/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$XDG_DATA_HOME/bob/nvim-bin:$XDG_DATA_HOME/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
# Load bash completions if available for zsh # Add zsh completions to FPATH, compinit will be called later
if [[ -n "$ZSH_VERSION" ]]; then FPATH="$ZSH_COMPLETIONS:$FPATH"
autoload bashcompinit
bashcompinit
fi
# Load asdf # Load asdf
export ASDF_DIR="$XDG_BIN_HOME/asdf" export ASDF_DIR="$XDG_BIN_HOME/asdf"
if [[ -d $ASDF_DIR ]]; then if [[ -d $ASDF_DIR ]]; then
[[ -d $ASDF_DIR/completions ]] && fpath=("$ASDF_DIR/completions" $fpath) [[ -d $ASDF_DIR/completions ]] && FPATH="$ASDF_DIR/completions:$FPATH"
[[ -d $ASDF_DIR/plugins ]] && fpath=("$ASDF_DIR/plugins" $fpath) [[ -d $ASDF_DIR/plugins ]] && FPATH="$ASDF_DIR/plugins:$FPATH"
source "$ASDF_DIR/asdf.sh" source "$ASDF_DIR/asdf.sh"
fi fi
export PATH="$ASDF_DIR/bin:$ASDF_DIR/shims:$PATH"
if ! command -v msg &> /dev/null; then if ! command -v msg &> /dev/null; then
# Function to print messages if VERBOSE is enabled # Function to print messages if VERBOSE is enabled
@@ -124,7 +123,7 @@ preexec()
dfu() dfu()
{ {
( (
cd "$DOTFILES" && git pull --ff-only && ./install cd "$DOTFILES" && git rebase --ff --autostash && ./install
) )
} }
@@ -465,6 +464,9 @@ export TF_PLUGIN_CACHE_DIR="$XDG_CACHE_HOME/terraform/plugin-cache"
msg "Setting up tmux configuration" msg "Setting up tmux configuration"
export TMUX_CONF="$XDG_CONFIG_HOME/tmux/tmux.conf" export TMUX_CONF="$XDG_CONFIG_HOME/tmux/tmux.conf"
# tms, https://github.com/jrmoulton/tmux-sessionizer
export TMS_CONFIG_FILE="${XDG_CONFIG_HOME}/tms/config.toml"
# wakatime, https://github.com/wakatime/wakatime-cli # wakatime, https://github.com/wakatime/wakatime-cli
msg "Setting up Wakatime configuration" msg "Setting up Wakatime configuration"
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime" export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"

View File

@@ -53,6 +53,10 @@ brew "aspell"
brew "autoconf" brew "autoconf"
# Collection of over 500 reusable autoconf macros # Collection of over 500 reusable autoconf macros
brew "autoconf-archive" brew "autoconf-archive"
# Cryptographic recipes and primitives for Python
brew "cryptography"
# Official Amazon AWS command-line interface
brew "awscli"
# Bourne-Again SHell, a UNIX command interpreter # Bourne-Again SHell, a UNIX command interpreter
brew "bash" brew "bash"
# GNU multiple precision arithmetic library # GNU multiple precision arithmetic library
@@ -71,8 +75,6 @@ brew "gettext"
brew "glib" brew "glib"
# Mozilla CA bundle for Python # Mozilla CA bundle for Python
brew "certifi" brew "certifi"
# Cryptographic recipes and primitives for Python
brew "cryptography"
# Get a file from an HTTP, HTTPS or FTP server # Get a file from an HTTP, HTTPS or FTP server
brew "curl" brew "curl"
# Lightweight DNS forwarder and DHCP server # Lightweight DNS forwarder and DHCP server
@@ -85,6 +87,12 @@ brew "freetds"
brew "gd" brew "gd"
# GitHub command-line tool # GitHub command-line tool
brew "gh" brew "gh"
# OpenType text shaping engine
brew "harfbuzz"
# Secure hashing function
brew "libb2"
# Framework for layout and rendering of i18n text
brew "pango"
# Distributed revision control system # Distributed revision control system
brew "git" brew "git"
# Render markdown on the CLI # Render markdown on the CLI
@@ -97,12 +105,6 @@ brew "gnutls"
brew "gnupg" brew "gnupg"
# Image manipulation # Image manipulation
brew "netpbm" brew "netpbm"
# C/C++ and Java libraries for Unicode and globalization
brew "icu4c"
# OpenType text shaping engine
brew "harfbuzz"
# Framework for layout and rendering of i18n text
brew "pango"
# Library to render SVG files using Cairo # Library to render SVG files using Cairo
brew "librsvg" brew "librsvg"
# Graph visualization software from AT&T and Bell Labs # Graph visualization software from AT&T and Bell Labs
@@ -127,8 +129,6 @@ brew "json-c"
brew "krb5" brew "krb5"
# Tool to detect/remediate misconfig and security risks of GitHub/GitLab assets # Tool to detect/remediate misconfig and security risks of GitHub/GitLab assets
brew "legitify" brew "legitify"
# Secure hashing function
brew "libb2"
# Postgres C API library # Postgres C API library
brew "libpq" brew "libpq"
# Multi-platform support library with a focus on asynchronous I/O # Multi-platform support library with a focus on asynchronous I/O
@@ -143,10 +143,14 @@ brew "m-cli"
brew "nginx" brew "nginx"
# Port scanning utility for large networks # Port scanning utility for large networks
brew "nmap" brew "nmap"
# Libraries for security-enabled client and server applications
brew "nss"
# Open source suite of directory software # Open source suite of directory software
brew "openldap" brew "openldap"
# General-purpose scripting language # General-purpose scripting language
brew "php" brew "php"
# General-purpose scripting language
brew "php@8.2"
# Manage compile and link flags for libraries # Manage compile and link flags for libraries
brew "pkg-config" brew "pkg-config"
# Send macOS User Notifications from the command-line # Send macOS User Notifications from the command-line
@@ -204,6 +208,8 @@ cask "font-open-sans"
cask "font-roboto" cask "font-roboto"
cask "font-source-code-pro" cask "font-source-code-pro"
cask "font-source-code-pro-for-powerline" cask "font-source-code-pro-for-powerline"
cask "font-source-sans-pro"
cask "font-source-serif-pro"
# GIT client # GIT client
cask "fork" cask "fork"
# HTTP and GraphQL Client # HTTP and GraphQL Client

View File

@@ -15,3 +15,6 @@ trim_trailing_whitespace = true
[*.md] [*.md]
max_line_length = off max_line_length = off
trim_trailing_whitespace = false trim_trailing_whitespace = false
[*.json]
max_line_length = off

View File

@@ -51,4 +51,21 @@ autocmd('FileType', {
callback = function(event) vim.bo[event.buf].buflisted = false end, callback = function(event) vim.bo[event.buf].buflisted = false end,
}) })
-- ── wrap and check for spell in text filetypes ──────────────────────
vim.api.nvim_create_autocmd('FileType', {
group = augroup('wrap_spell', { clear = true }),
pattern = { 'text', 'plaintex', 'typst', 'gitcommit', 'markdown' },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- ── Fix conceallevel for json files ─────────────────────────────────
vim.api.nvim_create_autocmd({ 'FileType' }, {
group = augroup('json_conceal', { clear = true }),
pattern = { 'json', 'jsonc', 'json5' },
callback = function() vim.opt_local.conceallevel = 0 end,
})
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et

View File

@@ -19,6 +19,9 @@ vim.g.colors_variant_dark = 'tokyonight-storm'
-- Make sure editorconfig support is enabled -- Make sure editorconfig support is enabled
vim.g.editorconfig = true vim.g.editorconfig = true
-- Enable the colorcolumn
vim.api.nvim_set_option_value('colorcolumn', '+1', { scope = 'global' })
-- Enable line numbers and relative line numbers -- Enable line numbers and relative line numbers
vim.opt.number = true vim.opt.number = true
vim.opt.relativenumber = true vim.opt.relativenumber = true

View File

@@ -1,49 +1,45 @@
-- ── Formatting ────────────────────────────────────────────────────── -- ── Formatting ──────────────────────────────────────────────────────
-- Lightweight yet powerful formatter plugin for Neovim -- Lightweight yet powerful formatter plugin for Neovim
-- https://github.com/stevearc/conform.nvim -- https://github.com/stevearc/conform.nvim
return {
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
config = function()
-- Select first conform formatter that is available
---@param bufnr integer
---@param ... string
---@return string
local function first(bufnr, ...)
local conform = require 'conform'
for i = 1, select('#', ...) do
local formatter = select(i, ...)
if conform.get_formatter_info(formatter, bufnr).available then
return formatter
end
end
return select(1, ...)
end
require('conform').setup { return {
{
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
opts = {
-- Enable or disable logging -- Enable or disable logging
notify_on_error = true, notify_on_error = false,
-- Set the default formatter for all filetypes -- Set the default formatter for all filetypes
default_formatter = 'injected', default_formatter = 'injected',
-- Set the default formatter for all filetypes -- Set the default formatter for all filetypes
default_formatter_opts = { default_formatter_opts = {
lsp_format = 'fallback', lsp_format = 'fallback',
-- Set the default formatter for all filetypes -- Set the default formatter for all filetypes
-- formatter = 'injected', formatter = 'injected',
-- Set the default formatter for all filetypes -- Set the default formatter for all filetypes
-- formatter_opts = {}, -- formatter_opts = {},
}, },
-- The options you set here will be merged with the builtin formatters.
-- You can also define any custom formatters here.
formatters = {
injected = { options = { ignore_errors = true } },
-- # Example of using dprint only when a dprint.json file is present
-- dprint = {
-- condition = function(ctx)
-- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1]
-- end,
-- },
--
-- # Example of using shfmt with extra args
-- shfmt = {
-- prepend_args = { "-i", "2", "-ci" },
-- },
},
formatters_by_ft = { formatters_by_ft = {
markdown = function(bufnr)
return { first(bufnr, 'prettierd', 'prettier'), 'injected' }
end,
javascript = function(bufnr)
return { first(bufnr, 'prettier', 'eslint'), 'injected' }
end,
lua = { 'stylua' }, lua = { 'stylua' },
-- Conform will run multiple formatters sequentially -- Conform will run multiple formatters sequentially
-- python = { 'isort', 'black', lsp_format = 'fallback' }, go = { 'goimports', 'gofmt' },
-- You can customize some of the format options for the filetype (:help conform.format) -- You can customize some of the format options for the filetype (:help conform.format)
-- rust = { 'rustfmt', lsp_format = 'fallback' }, -- rust = { 'rustfmt', lsp_format = 'fallback' },
}, },
@@ -59,9 +55,7 @@ return {
return return
end end
-- Disable with a global or buffer-local variable -- Disable with a global or buffer-local variable
if if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat
then
return return
end end
-- Disable autoformat for files in a certain path -- Disable autoformat for files in a certain path
@@ -73,12 +67,20 @@ return {
return { timeout_ms = 500, lsp_format = 'fallback' } return { timeout_ms = 500, lsp_format = 'fallback' }
end, end,
} },
end, init = function()
init = function() -- If you want the formatexpr, here is the place to set it
-- If you want the formatexpr, here is the place to set it vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" end,
end, },
-- Automatically install formatters registered with conform.nvim via mason.nvim
-- https://github.com/zapling/mason-conform.nvim
{
'zapling/mason-conform.nvim',
depends = {
'stevearc/conform.nvim',
'williamboman/mason.nvim',
},
opts = {},
},
} }

View File

@@ -19,7 +19,8 @@ return {
hide_preview = false, hide_preview = false,
}, },
}, },
-- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. -- These two configs can also be passed down to the goto-preview definition
-- and implementation calls for one off "peak" functionality.
focus_on_open = true, -- Focus the floating window when opening it. focus_on_open = true, -- Focus the floating window when opening it.
dismiss_on_move = false, -- Dismiss the floating window when moving the cursor. dismiss_on_move = false, -- Dismiss the floating window when moving the cursor.
force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close

View File

@@ -16,6 +16,28 @@ return {
local builtin = require 'statuscol.builtin' local builtin = require 'statuscol.builtin'
require('statuscol').setup { require('statuscol').setup {
relculright = true, relculright = true,
ft_ignore = {
'dashboard',
'NvimTree',
'help',
'vim',
'alpha',
'dashboard',
'neo-tree',
'Trouble',
'lazy',
'toggleterm',
},
bt_ignore = {
'help',
'vim',
'alpha',
'dashboard',
'neo-tree',
'Trouble',
'lazy',
'toggleterm',
},
segments = { segments = {
{ {
text = { builtin.foldfunc }, text = { builtin.foldfunc },
@@ -41,7 +63,7 @@ return {
config = function() config = function()
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = { capabilities.textDocument.foldingRange = {
dynamicRegistration = false, dynamicRegistration = true,
lineFoldingOnly = true, lineFoldingOnly = true,
} }
local language_servers = require('lspconfig').util.available_servers() -- or list servers manually like {'gopls', 'clangd'} local language_servers = require('lspconfig').util.available_servers() -- or list servers manually like {'gopls', 'clangd'}
@@ -84,7 +106,13 @@ return {
---@param width number The width of the window. ---@param width number The width of the window.
---@param truncate function Truncate function ---@param truncate function Truncate function
---@return table ---@return table
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate) fold_virt_text_handler = function(
virtText,
lnum,
endLnum,
width,
truncate
)
local newVirtText = {} local newVirtText = {}
local suffix = (' 󰁂 %d '):format(endLnum - lnum) local suffix = (' 󰁂 %d '):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix) local sufWidth = vim.fn.strdisplaywidth(suffix)

View File

@@ -27,9 +27,9 @@ return {
}, },
}, },
-- Extensible Neovim Scrollbar -- A neovim plugin that shows colorcolumn dynamically
-- https://github.com/petertriho/nvim-scrollbar -- https://github.com/Bekaboo/deadcolumn.nvim
{ 'petertriho/nvim-scrollbar', opts = {} }, { 'Bekaboo/deadcolumn.nvim' },
-- vim dashboard -- vim dashboard
-- https://github.com/nvimdev/dashboard-nvim -- https://github.com/nvimdev/dashboard-nvim
@@ -110,25 +110,64 @@ return {
{ {
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
main = 'ibl', main = 'ibl',
config = function() opts = {
require('ibl').setup { scope = { show_start = false, show_end = false },
indent = { indent = {
char = '', char = '',
tab_char = '',
},
exclude = {
filetypes = {
'Trouble',
'alpha',
'dashboard',
'help',
'lazy',
'lazyterm',
'mason',
'neo-tree',
'notify',
'terminal',
'toggleterm',
'trouble',
}, },
exclude = { buftypes = { 'dashboard' },
filetypes = { 'terminal', 'dashboard' }, },
buftypes = { 'dashboard' }, },
}, },
}
-- Display a character as the colorcolumn
-- https://github.com/lukas-reineke/virt-column.nvim
{ 'lukas-reineke/virt-column.nvim', opts = {} },
-- icons
{
'echasnovski/mini.icons',
opts = {
file = {
['.keep'] = { glyph = '󰊢', hl = 'MiniIconsGrey' },
['devcontainer.json'] = { glyph = '', hl = 'MiniIconsAzure' },
},
filetype = {
dotenv = { glyph = '', hl = 'MiniIconsYellow' },
},
},
init = function()
package.preload['nvim-web-devicons'] = function()
require('mini.icons').mock_nvim_web_devicons()
return package.loaded['nvim-web-devicons']
end
end, end,
}, },
-- ui components
{ 'MunifTanjim/nui.nvim', lazy = true },
-- Git integration for buffers -- Git integration for buffers
-- https://github.com/lewis6991/gitsigns.nvim -- https://github.com/lewis6991/gitsigns.nvim
{ {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
version = false, version = false,
lazy = false,
opts = { opts = {
signs = { signs = {
add = { text = '+' }, add = { text = '+' },
@@ -174,6 +213,7 @@ return {
'TmuxNavigateRight', 'TmuxNavigateRight',
'TmuxNavigatePrevious', 'TmuxNavigatePrevious',
}, },
opts = {},
}, },
-- Cloak allows you to overlay *'s over defined patterns in defined files. -- Cloak allows you to overlay *'s over defined patterns in defined files.

View File

@@ -141,8 +141,8 @@ return {
{ {
'<leader>cf', '<leader>cf',
'<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>', '<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>',
mode = { 'n', 'v' }, mode = {},
desc = 'Format buffer', desc = 'Format buffer with Conform',
}, },
{ {
'<leader>ci', '<leader>ci',
@@ -509,7 +509,7 @@ return {
}, },
-- ── Old habits ────────────────────────────────────────────────────── -- ── Old habits ──────────────────────────────────────────────────────
{ '<C-s>', '<cmd>w<CR>', desc = 'Save file' }, { '<C-s>', '<cmd>w!<CR>', desc = 'Save file' },
-- ── Text manipulation in visual mode ──────────────────────────────── -- ── Text manipulation in visual mode ────────────────────────────────
{ {

View File

@@ -1,121 +1,116 @@
"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json" "$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
final_space = true console_title_template = '{{.UserName}}@{{.HostName}} {{.Shell}} in {{.PWD}}'
console_title_template = "{{.UserName}}@{{.HostName}} {{.Shell}} in {{.PWD}}" version = 3
version = 2
auto_upgrade = true auto_upgrade = true
final_space = true
[[blocks]]
alignment = "left"
type = "prompt"
[[blocks.segments]]
foreground = "cyan"
style = "powerline"
template = "{{ .Icon }}"
type = "os"
[[blocks.segments]]
type = "session"
style = "plain"
template = " {{ if .SSHSession }} {{ .UserName }}@{{ end }}{{ .HostName }}"
[[blocks.segments]]
foreground = "cyan"
style = "plain"
template = " {{ .Path }} "
type = "path"
[blocks.segments.properties]
style = "mixed"
[blocks.segments.mapped_locations]
"~/Code/*" = ""
"~/Code/ivuorinen/" = ""
[[blocks.segments]]
type = "git"
style = "plain"
foreground = "lightGreen"
template = "{{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }}  {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }}"
[blocks.segments.properties]
fetch_status = true
fetch_upstream_icon = true
[blocks.segments.properties.untracked_modes]
"~/Code/oh-my-posh/" = "no"
[[blocks.segments]]
type = "terraform"
style = "plain"
foreground = "#000000"
background = "#ebcc34"
template = "{{.WorkspaceName}}"
[[blocks]]
alignment = "left"
type = "prompt"
[[blocks.segments]]
foreground = "#68a063"
style = "plain"
template = " {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}"
type = "node"
[blocks.segments.properties]
display_mode = "files"
fetch_package_manager = true
fetch_version = true
[[blocks.segments]]
foreground = "#4063D8"
style = "plain"
template = " {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}"
type = "crystal"
[blocks.segments.properties]
display_mode = "files"
fetch_version = true
[[blocks.segments]]
foreground = "#DE3F24"
style = "plain"
template = " {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}"
type = "ruby"
[blocks.segments.properties]
display_mode = "files"
fetch_version = true
[[blocks.segments]]
foreground = "#FED142"
style = "plain"
template = " {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}"
type = "python"
[blocks.segments.properties]
display_mode = "context"
fetch_virtual_env = false
[[blocks]]
alignment = "left"
newline = true
type = "prompt"
[[blocks.segments]]
background = "transparent"
foreground = "lightGreen"
foreground_templates = [ "{{ if gt .Code 0 }}red{{ end }}" ]
style = "plain"
template = "➜"
type = "status"
[blocks.segments.properties]
always_enabled = true
[transient_prompt] [transient_prompt]
background = "transparent" template = '➜ '
foreground = "lightGreen" foreground = 'lightGreen'
foreground_templates = [ "{{ if gt .Code 0 }}red{{ end }}" ] background = 'transparent'
template = "➜ " foreground_templates = ['{{ if gt .Code 0 }}red{{ end }}']
[[blocks]]
type = 'prompt'
alignment = 'left'
[[blocks.segments]]
style = 'powerline'
template = '{{ .Icon }}'
foreground = 'cyan'
type = 'os'
[[blocks.segments]]
style = 'plain'
template = ' {{ if .SSHSession }} {{ .UserName }}@{{ end }}{{ .HostName }}'
type = 'session'
[[blocks.segments]]
style = 'plain'
template = ' {{ .Path }} '
foreground = 'cyan'
type = 'path'
[blocks.segments.properties]
style = 'mixed'
[[blocks.segments]]
style = 'plain'
template = '{{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }}  {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }}'
foreground = 'lightGreen'
type = 'git'
[blocks.segments.properties]
fetch_status = true
fetch_upstream_icon = true
[blocks.segments.properties.untracked_modes]
'~/Code/oh-my-posh/' = 'no'
[[blocks.segments]]
style = 'plain'
template = '{{.WorkspaceName}}'
foreground = '#000000'
background = '#ebcc34'
type = 'terraform'
[[blocks]]
type = 'prompt'
alignment = 'left'
[[blocks.segments]]
style = 'plain'
template = ' {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}'
foreground = '#68a063'
type = 'node'
[blocks.segments.properties]
display_mode = 'files'
fetch_package_manager = true
fetch_version = true
[[blocks.segments]]
style = 'plain'
template = ' {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}'
foreground = '#4063D8'
type = 'crystal'
[blocks.segments.properties]
display_mode = 'files'
fetch_version = true
[[blocks.segments]]
style = 'plain'
template = ' {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}'
foreground = '#DE3F24'
type = 'ruby'
[blocks.segments.properties]
display_mode = 'files'
fetch_version = true
[[blocks.segments]]
style = 'plain'
template = ' {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}'
foreground = '#FED142'
type = 'python'
[blocks.segments.properties]
display_mode = 'context'
fetch_virtual_env = false
[[blocks]]
type = 'prompt'
alignment = 'left'
newline = true
[[blocks.segments]]
style = 'plain'
template = '➜'
foreground = 'lightGreen'
background = 'transparent'
type = 'status'
foreground_templates = ['{{ if gt .Code 0 }}red{{ end }}']
[blocks.segments.properties]
always_enabled = true

5
config/tms/config.toml Normal file
View File

@@ -0,0 +1,5 @@
default_session = "main"
[[search_dirs]]
path = "~/Code"
depth = 10

View File

@@ -147,16 +147,12 @@ set -g @tmux_window_name_max_name_len "20"
set -g @tmux_window_name_use_tilde "True" set -g @tmux_window_name_use_tilde "True"
set -g @tmux_window_name_shells "['bash', 'fish', 'sh', 'zsh', 'oh-my-posh']" set -g @tmux_window_name_shells "['bash', 'fish', 'sh', 'zsh', 'oh-my-posh']"
set -g @tmux_window_dir_programs "['nvim', 'vim', 'vi', 'git']" set -g @tmux_window_dir_programs "['nvim', 'vim', 'vi', 'git']"
set -g @tmux_window_name_ignored_programs "['sqlite3', 'x-set-php-aliases', 'oh-my-posh', 'antidot', 'direnv']" # Default is [] set -g @tmux_window_name_ignored_programs "['sqlite3', 'oh-my-posh', 'antidot', 'direnv']" # Default is []
set -g @tmux_window_name_substitute_sets "[('.+ipython2', 'ipython2'), ('.+ipython3', 'ipython3'), ('.+\.local', '.local'), ('.+asdf', 'asdf')]" set -g @tmux_window_name_substitute_sets "[('.+ipython2', 'ipython2'), ('.+ipython3', 'ipython3'), ('.+\.local', '.local'), ('.+asdf', 'asdf')]"
## https://github.com/tmux-plugins/tmux-continuum ## https://github.com/tmux-plugins/tmux-continuum
# set -g @continuum-restore 'on' # set -g @continuum-restore 'on'
## https://github.com/tmux-plugins/tmux-resurrect
# set -g @resurrect-strategy-nvim 'session'
# set -g @resurrect-dir '~/.local/state/tmux/tmux-resurrect'
## https://github.com/MunifTanjim/tmux-mode-indicator ## https://github.com/MunifTanjim/tmux-mode-indicator
set -g @mode_indicator_prefix_mode_style 'bg=default,fg=#7aa2f7' set -g @mode_indicator_prefix_mode_style 'bg=default,fg=#7aa2f7'
set -g @mode_indicator_copy_mode_style 'bg=default,fg=yellow' set -g @mode_indicator_copy_mode_style 'bg=default,fg=yellow'
@@ -169,7 +165,6 @@ set -g @mode_indicator_sync_mode_style 'bg=default,fg=red'
run-shell ~/.dotfiles/config/tmux/plugins/tmux-sensible/sensible.tmux run-shell ~/.dotfiles/config/tmux/plugins/tmux-sensible/sensible.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-window-name/tmux_window_name.tmux run-shell ~/.dotfiles/config/tmux/plugins/tmux-window-name/tmux_window_name.tmux
# run-shell ~/.dotfiles/config/tmux/plugins/tmux-resurrect/resurrect.tmux
# run-shell ~/.dotfiles/config/tmux/plugins/tmux-continuum/continuum.tmux # run-shell ~/.dotfiles/config/tmux/plugins/tmux-continuum/continuum.tmux
# run-shell ~/.dotfiles/config/tmux/plugins/tmux-sessionist/sessionist.tmux # run-shell ~/.dotfiles/config/tmux/plugins/tmux-sessionist/sessionist.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-mode-indicator/mode_indicator.tmux run-shell ~/.dotfiles/config/tmux/plugins/tmux-mode-indicator/mode_indicator.tmux

View File

@@ -1,9 +1,14 @@
local wezterm = require("wezterm") local wezterm = require 'wezterm'
local config = wezterm.config_builder() local config = wezterm.config_builder()
-- Font and font size -- Font and font size
config.font_size = 14.0 config.font_size = 14.0
config.font = wezterm.font("JetBrainsMonoNL Nerd Font Mono") config.font = wezterm.font_with_fallback {
'JetBrainsMonoNL Nerd Font Mono',
'JetBrains Mono',
'Noto Color Emoji',
'Symbols Nerd Font Mono',
}
-- Make the window a bit transparent -- Make the window a bit transparent
config.window_background_opacity = 0.97 config.window_background_opacity = 0.97
@@ -15,16 +20,16 @@ config.send_composed_key_when_left_alt_is_pressed = true
-- Function to detect the theme based on appearance -- Function to detect the theme based on appearance
function Scheme_for_appearance(appearance) function Scheme_for_appearance(appearance)
if appearance:find("Dark") then if appearance:find 'Dark' then
return "Tokyo Night Storm" return 'Tokyo Night Storm'
else else
return "Tokyo Night Day" return 'Tokyo Night Day'
end end
end end
-- Set the color scheme based on appearance -- Set the color scheme based on appearance
---@diagnostic disable-next-line: unused-local ---@diagnostic disable-next-line: unused-local
wezterm.on("window-config-reloaded", function(window, pane) wezterm.on('window-config-reloaded', function(window, pane)
local overrides = window:get_config_overrides() or {} local overrides = window:get_config_overrides() or {}
local appearance = window:get_appearance() local appearance = window:get_appearance()
local scheme = Scheme_for_appearance(appearance) local scheme = Scheme_for_appearance(appearance)

View File

@@ -0,0 +1,212 @@
#compdef oh-my-posh
compdef _oh-my-posh oh-my-posh
# zsh completion for oh-my-posh -*- shell-script -*-
__oh-my-posh_debug()
{
local file="$BASH_COMP_DEBUG_FILE"
if [[ -n ${file} ]]; then
echo "$*" >> "${file}"
fi
}
_oh-my-posh()
{
local shellCompDirectiveError=1
local shellCompDirectiveNoSpace=2
local shellCompDirectiveNoFileComp=4
local shellCompDirectiveFilterFileExt=8
local shellCompDirectiveFilterDirs=16
local shellCompDirectiveKeepOrder=32
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
local -a completions
__oh-my-posh_debug "\n========= starting completion logic =========="
__oh-my-posh_debug "CURRENT: ${CURRENT}, words[*]: ${words[*]}"
# The user could have moved the cursor backwards on the command-line.
# We need to trigger completion from the $CURRENT location, so we need
# to truncate the command-line ($words) up to the $CURRENT location.
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
words=("${=words[1,CURRENT]}")
__oh-my-posh_debug "Truncated words[*]: ${words[*]},"
lastParam=${words[-1]}
lastChar=${lastParam[-1]}
__oh-my-posh_debug "lastParam: ${lastParam}, lastChar: ${lastChar}"
# For zsh, when completing a flag with an = (e.g., oh-my-posh -n=<TAB>)
# completions must be prefixed with the flag
setopt local_options BASH_REMATCH
if [[ "${lastParam}" =~ '-.*=' ]]; then
# We are dealing with a flag with an =
flagPrefix="-P ${BASH_REMATCH}"
fi
# Prepare the command to obtain completions
requestComp="${words[1]} __complete ${words[2,-1]}"
if [ "${lastChar}" = "" ]; then
# If the last parameter is complete (there is a space following it)
# We add an extra empty parameter so we can indicate this to the go completion code.
__oh-my-posh_debug "Adding extra empty parameter"
requestComp="${requestComp} \"\""
fi
__oh-my-posh_debug "About to call: eval ${requestComp}"
# Use eval to handle any environment variables and such
out=$(eval ${requestComp} 2>/dev/null)
__oh-my-posh_debug "completion output: ${out}"
# Extract the directive integer following a : from the last line
local lastLine
while IFS='\n' read -r line; do
lastLine=${line}
done < <(printf "%s\n" "${out[@]}")
__oh-my-posh_debug "last line: ${lastLine}"
if [ "${lastLine[1]}" = : ]; then
directive=${lastLine[2,-1]}
# Remove the directive including the : and the newline
local suffix
(( suffix=${#lastLine}+2))
out=${out[1,-$suffix]}
else
# There is no directive specified. Leave $out as is.
__oh-my-posh_debug "No directive found. Setting do default"
directive=0
fi
__oh-my-posh_debug "directive: ${directive}"
__oh-my-posh_debug "completions: ${out}"
__oh-my-posh_debug "flagPrefix: ${flagPrefix}"
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
__oh-my-posh_debug "Completion received error. Ignoring completions."
return
fi
local activeHelpMarker="_activeHelp_ "
local endIndex=${#activeHelpMarker}
local startIndex=$((${#activeHelpMarker}+1))
local hasActiveHelp=0
while IFS='\n' read -r comp; do
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
if [ "${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
__oh-my-posh_debug "ActiveHelp found: $comp"
comp="${comp[$startIndex,-1]}"
if [ -n "$comp" ]; then
compadd -x "${comp}"
__oh-my-posh_debug "ActiveHelp will need delimiter"
hasActiveHelp=1
fi
continue
fi
if [ -n "$comp" ]; then
# If requested, completions are returned with a description.
# The description is preceded by a TAB character.
# For zsh's _describe, we need to use a : instead of a TAB.
# We first need to escape any : as part of the completion itself.
comp=${comp//:/\\:}
local tab="$(printf '\t')"
comp=${comp//$tab/:}
__oh-my-posh_debug "Adding completion: ${comp}"
completions+=${comp}
lastComp=$comp
fi
done < <(printf "%s\n" "${out[@]}")
# Add a delimiter after the activeHelp statements, but only if:
# - there are completions following the activeHelp statements, or
# - file completion will be performed (so there will be choices after the activeHelp)
if [ $hasActiveHelp -eq 1 ]; then
if [ ${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
__oh-my-posh_debug "Adding activeHelp delimiter"
compadd -x "--"
hasActiveHelp=0
fi
fi
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
__oh-my-posh_debug "Activating nospace."
noSpace="-S ''"
fi
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
__oh-my-posh_debug "Activating keep order."
keepOrder="-V"
fi
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
# File extension filtering
local filteringCmd
filteringCmd='_files'
for filter in ${completions[@]}; do
if [ ${filter[1]} != '*' ]; then
# zsh requires a glob pattern to do file filtering
filter="\*.$filter"
fi
filteringCmd+=" -g $filter"
done
filteringCmd+=" ${flagPrefix}"
__oh-my-posh_debug "File filtering command: $filteringCmd"
_arguments '*:filename:'"$filteringCmd"
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
# File completion for directories only
local subdir
subdir="${completions[1]}"
if [ -n "$subdir" ]; then
__oh-my-posh_debug "Listing directories in $subdir"
pushd "${subdir}" >/dev/null 2>&1
else
__oh-my-posh_debug "Listing directories in ."
fi
local result
_arguments '*:dirname:_files -/'" ${flagPrefix}"
result=$?
if [ -n "$subdir" ]; then
popd >/dev/null 2>&1
fi
return $result
else
__oh-my-posh_debug "Calling _describe"
if eval _describe $keepOrder "completions" completions $flagPrefix $noSpace; then
__oh-my-posh_debug "_describe found some completions"
# Return the success of having called _describe
return 0
else
__oh-my-posh_debug "_describe did not find completions."
__oh-my-posh_debug "Checking if we should do file completion."
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
__oh-my-posh_debug "deactivating file completion"
# We must return an error code here to let zsh know that there were no
# completions found by _describe; this is what will trigger other
# matching algorithms to attempt to find completions.
# For example zsh can match letters in the middle of words.
return 1
else
# Perform file completion
__oh-my-posh_debug "Activating file completion"
# We must return the result of this command, so it must be the
# last command, or else we must store its result to return it.
_arguments '*:filename:_files'" ${flagPrefix}"
fi
fi
fi
}
# don't run the completion function when being source-ed or eval-ed
if [ "$funcstack[1]" = "_oh-my-posh" ]; then
_oh-my-posh
fi

View File

@@ -392,18 +392,106 @@ section_brew()
! x-have brew && menu_section "$USAGE_PREFIX" "brew not available on this system" ! x-have brew && menu_section "$USAGE_PREFIX" "brew not available on this system"
} }
section_asdf()
{
USAGE_PREFIX="$SCRIPT asdf <command>"
MENU=(
"install:Install asdf"
"current:Show asdf current versions"
"global:Show asdf global versions"
"installed:Show asdf installed versions"
"local:Show asdf local versions"
"versions:Show asdf versions"
"where:Show asdf where"
"which:Show asdf which"
)
case "$1" in
install)
msg "Installing asdf..."
bash "$DOTFILES/scripts/install-asdf.sh both" \
&& msg_yay "asdf installed!"
;;
current)
asdf current
;;
global)
asdf global
;;
installed)
asdf list
;;
local)
asdf local
;;
versions)
asdf list all
;;
where)
asdf where
;;
which)
asdf which
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
section_helpers() section_helpers()
{ {
USAGE_PREFIX="$SCRIPT helpers <command>" USAGE_PREFIX="$SCRIPT helpers <command>"
MENU=( MENU=(
"aliases:<shell> (bash, zsh) Show aliases for bash or zsh"
"colors:Show colors"
"env:Show environment variables"
"functions:Show functions"
"nvim:Show nvim keybindings"
"path:Show \$PATH dir by dir" "path:Show \$PATH dir by dir"
"tmux:Show tmux keybindings"
"wezterm:Show wezterm keybindings"
) )
case "$1" in CMD="$1"
shift
SECTION="$1"
shift
case "$CMD" in
path) path)
# shellcheck disable=2001 # shellcheck disable=2001
for i in $(echo "$PATH" | sed 's/:/ /g'); do echo "$i"; done for i in $(echo "$PATH" | sed 's/:/ /g'); do echo "$i"; done
;; ;;
aliases)
case "$SECTION" in
"zsh")
zsh -ixc : 2>&1 | grep -E '> alias' | sed "s|$HOME|~|" | grep -v "(eval)"
;;
"bash")
bash -ixc : 2>&1 | grep -E '> alias' | sed "s|$HOME|~|" | grep -v "(eval)"
;;
*)
echo "$SCRIPT helpers aliases <shell> (bash, zsh)"
;;
esac
;;
"colors")
for i in {0..255}; do echo -en "\e[38;5;${i}m${i} "; done
;;
"env")
env | sort
;;
"functions")
declare -F
;;
"nvim")
cat "$DOTFILES/docs/nvim-keybindings.md"
;;
"tmux")
cat "$DOTFILES/docs/tmux-keybindings.md"
;;
"wezterm")
cat "$DOTFILES/docs/wezterm-keybindings.md"
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;; *) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
esac esac
} }
@@ -524,9 +612,16 @@ section_tests()
MENU=( MENU=(
"msg:List all log functions from shared.sh" "msg:List all log functions from shared.sh"
"params:List all parameters"
) )
case "$1" in case "$1" in
params)
echo "All parameters:"
for i in "$@"; do
echo " $i"
done
;;
msg) msg)
msg "msg" msg "msg"
msg_done "msg_done" msg_done "msg_done"
@@ -555,6 +650,8 @@ usage()
echo "" echo ""
section_install section_install
echo "" echo ""
section_asdf
echo ""
section_brew section_brew
echo "" echo ""
section_check section_check
@@ -566,14 +663,22 @@ usage()
section_helpers section_helpers
} }
# The main loop. first keyword after $0 triggers section, or help. main()
case "$1" in {
install) section_install "$2" ;; SECTION="$1"
brew) section_brew "$2" ;; shift
check) section_check "$2" ;; # The main loop. The first keyword after $0 triggers section, or help.
dotfiles) section_dotfiles "$2" ;; case "$SECTION" in
helpers) section_helpers "$2" ;; install) section_install "$@" ;;
docs) section_docs "$2" ;; asdf) section_asdf "$@" ;;
tests) section_tests "$2" ;; brew) section_brew "$@" ;;
*) usage && exit 0 ;; check) section_check "$@" ;;
esac dotfiles) section_dotfiles "$@" ;;
helpers) section_helpers "$@" ;;
docs) section_docs "$@" ;;
tests) section_tests "$@" ;;
*) usage && exit 0 ;;
esac
}
main "$@"