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
fast-syntax-highlighting highlighting of abbreviations [progress: single-word abbreviations is solved; multi-word abbreviations isn't] #24
Comments
As a workaround solution, I use this code snippet at the end of chroma_single_word() {
(( next_word = 2 | 8192 ))
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __style
(( __first_call )) && { __style=${FAST_THEME_NAME}command }
[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
(( this_word = next_word ))
_start_pos=$_end_pos
return 0
}
# register single word command execpt for the followings:
# - already in PATH
# - already in fast-syntax-highlighting chroma map
register_single_word_chroma() {
local word=$1
if [[ -x $(command -v $word) ]] || [[ -n $FAST_HIGHLIGHT["chroma-$word"] ]]; then
return 1
fi
FAST_HIGHLIGHT+=( "chroma-$word" chroma_single_word )
return 0
}
if [[ -n $FAST_HIGHLIGHT ]]; then
for abbr in ${(f)"$(abbr list-abbreviations)"}; do
if [[ $abbr != *' '* ]]; then
register_single_word_chroma ${(Q)abbr}
fi
done
fi
|
@tomoesaturn what an exciting notification to receive! Thanks for sharing. Looks like it works. My intuition would be to use How hard do you think it would be to support multi-word abbreviations? Is that possible with F-Sy-H? |
Oops, I didn't care about highlight color. I agree with you to use
In my opinion, it would be slightly difficult because F-Sy-H chroma function seems to be triggered by a single word. I think therefore that it can be implemented roughly in the following flow.
|
Sounds tricky enough that it's not worth letting multi-word highlighting be a blocker for documenting single-word highlighting. For now, let's put single-word out into the world. If you're interested in contributing to the documentation, please open a PR for https://zsh-abbr.olets.dev/advanced.html#syntax-highlighting. To speed up any PR back-and-forth, I'm picturing something like #### fast-syntax-highlighting
[fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting) users…
…
Want highlighting for multi-word aliases? See [zsh-abbr#24](https://github.com/olets/zsh-abbr/issues/24).
#### zsh-syntax-highlighting
<existing zsh-syntax-highlighting docs> If you're not interested in making the change, lmk and I'll make an update! |
@olets Thanks! I'll try to contribute to the documentation! |
Would be nice to support fast-syntax-highlighting.
Its chroma docs are here.
The text was updated successfully, but these errors were encountered: