Got basic completions working, need to ignore
cases like 'kill name<tab>' which should replace the wordno-server
parent
1e6e900abf
commit
c6c97ab7bd
@ -1,25 +1,36 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# Helper script for debugging the completion server
|
|
||||||
zmodload zsh/net/socket
|
zmodload zsh/net/socket
|
||||||
setopt no_hup
|
|
||||||
AUTOSUGGEST_SERVER_SCRIPT="${0:a:h}/completion-server.zsh"
|
AUTOSUGGEST_SERVER_SCRIPT="${0:a:h}/completion-server.zsh"
|
||||||
|
|
||||||
server_dir="/tmp/zsh-autosuggest-$USER"
|
autosuggest-ensure-server() {
|
||||||
pid_file="$server_dir/pid"
|
setopt local_options no_hup
|
||||||
socket_path="$server_dir/socket"
|
local server_dir="/tmp/zsh-autosuggest-$USER"
|
||||||
|
local pid_file="$server_dir/pid"
|
||||||
|
local socket_path="$server_dir/socket"
|
||||||
|
|
||||||
|
[[ -S $socket_path && -r $pid_file ]] && \
|
||||||
|
kill -0 $(<$pid_file) &> /dev/null || \
|
||||||
|
zsh $AUTOSUGGEST_SERVER_SCRIPT $server_dir $pid_file $socket_path &!
|
||||||
|
|
||||||
[[ -S $socket_path && -r $pid_file ]] && kill -0 $(<$pid_file) &> /dev/null ||\
|
integer remaining_tries=10
|
||||||
zsh $AUTOSUGGEST_SERVER_SCRIPT $server_dir $pid_file $socket_path &!
|
# wait until the process is listening
|
||||||
|
while ! [[ -d $server_dir && -r $pid_file ]] ||\
|
||||||
|
! kill -0 $(<$pid_file) &> /dev/null && (( --remaining_tries )); do
|
||||||
|
sleep 0.3
|
||||||
|
done
|
||||||
|
ZLE_AUTOSUGGEST_SOCKET=$socket_path
|
||||||
|
}
|
||||||
|
|
||||||
# wait until the process is listening
|
|
||||||
while ! [[ -d $server_dir && -r $pid_file ]] || ! kill -0 $(<$pid_file) &> /dev/null; do
|
|
||||||
sleep 0.3
|
|
||||||
done
|
|
||||||
|
|
||||||
zsocket $socket_path
|
autosuggest-first-completion() {
|
||||||
connection=$REPLY
|
zsocket $ZLE_AUTOSUGGEST_SOCKET &>/dev/null || return 1
|
||||||
print -u $connection vi
|
local connection=$REPLY
|
||||||
while read -u $connection completion; do
|
local completion
|
||||||
print $completion
|
print -u $connection $1
|
||||||
done
|
while read -u $connection completion; do
|
||||||
exec {connection}>&-
|
print ${completion}
|
||||||
|
done
|
||||||
|
# close fd
|
||||||
|
exec {connection}>&-
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue