Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template include should be able to process recursive templates #406

Closed
xenoterracide opened this issue Feb 24, 2022 · 2 comments
Closed

Comments

@xenoterracide
Copy link

template included in template doesn't process

❯ cat alt/.zshrc\#\#template,e.zsh | clip
❯ cat extra/vim\#\#template,e.zsh | clip
❯ cat ~/.zshrc| clip
{% include "../extra/zshrc.os.{{ yadm.os }},e.zsh" %}
zi load z-shell/z-a-meta-plugins

zi for z-shell/history-search-multi-word z-shell/zconvey
zi snippet OMZL::history.zsh

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
zi load romkatv/powerlevel10k

zi wait for \
  OMZL::theme-and-appearance.zsh atload"unalias ls" \
  OMZP::colored-man-pages \
  OMZP::systemd \
  OMZP::direnv \
  OMZP::gitignore

zi ice wait as"program" has"perl" mv"cpanmin.us* -> cpanm" pick"cpanm"
zi snippet https://cpanmin.us

{% include "../extra/rc.sh" %}
{% include "../extra/alias.zsh" %}
{% include "../extra/vim##template,e.zsh" %}

zstyle :plugin:history-search-multi-word reset-prompt-protect 1


schedprompt() {
  zle && zle reset-prompt
  sched +1 schedprompt
}

zmodload -i zsh/sched
schedprompt

zi wait for \
  atinit"zicompinit; zicdreplay" \
      z-shell/fast-syntax-highlighting \
  atload"_zsh_autosuggest_start" \
      zsh-users/zsh-autosuggestions \
  blockf atpull'zi creinstall -q .' \
      zsh-users/zsh-completions

zi wait atload"zicompinit" for zsh-users+fast
set -o emacs
bindkey "^R" history-search-multi-word
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
function vim_setup() {
  local VIMDIR="$HOME/.vim"
  local VIM_COLOR="$VIMDIR/colors"
  local VIM_PACK="$VIMDIR/pack"
  local VIM_FTPLUGIN="$VIMDIR/ftplugin"
  local VIM_FTDETECT="$VIMDIR/ftdetect"
  local VIM_AFTER_SYNTAX="$VIMDIR/after/syntax"

  zi ice lucid wait cloneonly nocompile notify \
    atclone"install --compare -D colors/desertink.vim $VIM_COLOR/desertink.vim" \
    atpull"%atclone"
  zi light toupeira/vim-desertink

  zi ice lucid wait cloneonly nocompile \
    atclone"install -D after/syntax/zsh.vim $VIM_AFTER_SYNTAX/zsh.vim" \
    atpull"%atclone"
  zi light z-shell/zinit-vim-syntax

  zi ice lucid wait cloneonly nocompile \
    atclone"install -D syntax/systemd.vim $VIM_AFTER_SYNTAX/systemd.vim; install -D ftplugin/systemd.vim $VIM_FTPLUGIN/systemd.vim; install -D ftdetect/systemd.vim $VIM_FTDETECT/systemd.vim" \
    atpull"%atclone"
  zi light wgwoods/vim-systemd-syntax

{% if yadm.class == "cof" %}
{% else %}
  zi ice lucid wait cloneonly nocompile \
    atclone"rsync --mkpath --exclude '.*' --archive . $VIM_PACK/local/start/editorconfig" \
    atpull"%atclone"
  zi light editorconfig/editorconfig-vim
{% endif %}
}
vim_setup
unfunction vim_setup
######

yadm alt
outputs

zi wait atload=". /opt/asdf-vm/asdf.sh" for z-shell/null
zi load z-shell/z-a-meta-plugins

zi for z-shell/history-search-multi-word z-shell/zconvey
zi snippet OMZL::history.zsh

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
zi load romkatv/powerlevel10k

zi wait for \
  OMZL::theme-and-appearance.zsh atload"unalias ls" \
  OMZP::colored-man-pages \
  OMZP::systemd \
  OMZP::direnv \
  OMZP::gitignore

zi ice wait as"program" has"perl" mv"cpanmin.us* -> cpanm" pick"cpanm"
zi snippet https://cpanmin.us

if [ "$DESKTOP_SESSION" = "gnome" ]; then
  eval $(gnome-keyring-daemon --start)
  if command -v seahorse > /dev/null 2>&1; then
    export SSH_ASKPASS=$(which seahorse)
    export SUDO_ASKPASS=$(which seahorse)
  fi
fi

if command -v perl >/dev/null 2>&1; then
  if perl -Mlocal::lib -e 1 >/dev/null 2>&1; then
    eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
  fi
fi

if command -v kubectl >/dev/null 2>&1; then
  source <(kubectl completion zsh)
fi

if command -v cargo >/dev/null 2>&1; then
  export PATH="$PATH:$HOME/.cargo/bin"
fi
alias vi="vim"
alias vim="\vim -Xp"
alias bfg="java -jar ~/.local/share/bfg.jar"
alias logs="journalctl --output cat --boot 0 --full"
alias dmesg="dmesg --color=always | less"
alias lsblk="lsblk -o name,label,fstype,uuid"

zi wait has"xclip" atload'alias xclip -selection clipboard -in' for z-shell/null
zi wait has"bat" atload'alias cat="bat --paging=never --plain"' for z-shell/null
zi wait has"exa" atload'alias ls="exa"' for z-shell/null
zi wait has"plocate" atload'alias locate="plocate"' for z-shell/null
zi wait has"dust" atload'alias dust="du"' for z-shell/null
zi wait has"kalker" atload'alias bc="kalker"' for z-shell/null
zi wait has"procs" atload'alias ps="procs"' for z-shell/null
zi wait has"tokei" atload'alias cloc="tokei"' for z-shell/null
zi wait has"zoxide" atinit'eval "$(zoxide init zsh --hook pwd --cmd cd)"' for z-shell/null
function vim_setup() {
  local VIMDIR="$HOME/.vim"
  local VIM_COLOR="$VIMDIR/colors"
  local VIM_PACK="$VIMDIR/pack"
  local VIM_FTPLUGIN="$VIMDIR/ftplugin"
  local VIM_FTDETECT="$VIMDIR/ftdetect"
  local VIM_AFTER_SYNTAX="$VIMDIR/after/syntax"

  zi ice lucid wait cloneonly nocompile notify \
    atclone"install --compare -D colors/desertink.vim $VIM_COLOR/desertink.vim" \
    atpull"%atclone"
  zi light toupeira/vim-desertink

  zi ice lucid wait cloneonly nocompile \
    atclone"install -D after/syntax/zsh.vim $VIM_AFTER_SYNTAX/zsh.vim" \
    atpull"%atclone"
  zi light z-shell/zinit-vim-syntax

  zi ice lucid wait cloneonly nocompile \
    atclone"install -D syntax/systemd.vim $VIM_AFTER_SYNTAX/systemd.vim; install -D ftplugin/systemd.vim $VIM_FTPLUGIN/systemd.vim; install -D ftdetect/systemd.vim $VIM_FTDETECT/systemd.vim" \
    atpull"%atclone"
  zi light wgwoods/vim-systemd-syntax

{% if yadm.class == "cof" %}
{% else %}
  zi ice lucid wait cloneonly nocompile \
    atclone"rsync --mkpath --exclude '.*' --archive . $VIM_PACK/local/start/editorconfig" \
    atpull"%atclone"
  zi light editorconfig/editorconfig-vim
{% endif %}
}
vim_setup
unfunction vim_setup
######

zstyle :plugin:history-search-multi-word reset-prompt-protect 1


schedprompt() {
  zle && zle reset-prompt
  sched +1 schedprompt
}

zmodload -i zsh/sched
schedprompt

zi wait for \
  atinit"zicompinit; zicdreplay" \
      z-shell/fast-syntax-highlighting \
  atload"_zsh_autosuggest_start" \
      zsh-users/zsh-autosuggestions \
  blockf atpull'zi creinstall -q .' \
      zsh-users/zsh-completions

zi wait atload"zicompinit" for zsh-users+fast
set -o emacs
bindkey "^R" history-search-multi-word
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
@github-actions
Copy link

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Apr 26, 2022
@github-actions
Copy link

github-actions bot commented May 3, 2022

This issue was closed because it has been labeled as stale for 7 days with no activity.

@github-actions github-actions bot closed this as completed May 3, 2022
erijo added a commit to erijo/yadm that referenced this issue Oct 27, 2024
The awk script now performs all processing in the BEGIN block using an
implementation that is capable of handling nested if statements. This fixes
issue yadm-dev#436. Includes are now handled in the same way as the main file which
means that recursive includes and if statements in includes works as
expected. This fixes yadm-dev#406.

All variables are handled in the same way now so it's now possible to use env
variables in if statements. This fixes yadm-dev#488.

Also add support for != in addition to == (fixes yadm-dev#358). Thus it's now
e.g. possible to check if a variable is set (yadm-dev#477) by doing:

{% if yadm.class != ""%}
Class is set to {{ yadm.class }}
{% endif %}

Possible breaking change: An error will be issued if a non-existent yadm or env
variable is referenced in an if statement or in a variable substitution.
erijo added a commit to erijo/yadm that referenced this issue Oct 27, 2024
The awk script now performs all processing in the BEGIN block using an
implementation that is capable of handling if statements which contain nested
if statments (fixes yadm-dev#436). To make nested ifs look better, if, else and endif
lines can now have optional whitespace before {%.

Includes are now handled in the same way as the main file which means that
included files can both include other files and have if statements in addition
to variables (fixes yadm-dev#406). Include lines can now also have optional whitespace
before {%.

All variables are handled in the same way now so it's now possible to use env
variables in if statements (fixes yadm-dev#488).

Also add support for != in addition to == (fixes yadm-dev#358). Thus it's now
e.g. possible to check if a variable is set (yadm-dev#477) by doing:

{% if yadm.class != ""%}
Class is set to {{ yadm.class }}
{% endif %}

Possible breaking change: An error will be issued if a non-existent yadm or env
variable is referenced in an if statement or in a variable substitution.
@erijo erijo added 2 and removed stale labels Nov 6, 2024
@erijo erijo reopened this Nov 6, 2024
erijo added a commit that referenced this issue Nov 6, 2024
* Support nested ifs in default template (#436)
* Support include and ifs in default template includes (#406)
* Support environment variables in ifs in default template (#488)
* Support != in default template (#358, #477)
erijo added a commit that referenced this issue Nov 8, 2024
 * Support nested ifs in default template (#436)
 * Support include and ifs in default template includes (#406)
 * Support environment variables in ifs in default template (#488)
 * Support != in default template (#358, #477)
 * Fix multiple classes in default template on macOS (#437)
@erijo erijo closed this as completed in 8ba9823 Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants