aboutsummaryrefslogtreecommitdiff
path: root/tools/scripts/neovide-listen
blob: 2591842dd9ad61c3fe55ae9580cf9da503d1978b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash

if [[ -z "$NVIM_SOCKET" ]]; then
  NVIM_SOCKET="/tmp/nvimsocket"
fi

args=()
MY_NEOVIM_PATH="$HOME/codes/neovim/build/bin/nvim"
if [[ -e "$MY_NEOVIM_PATH" ]]; then
  echo "Found my neovim at $MY_NEOVIM_PATH"
  export VIMRUNTIME="$HOME/codes/neovim/runtime"
  args=("${args[@]}" "--neovim-bin" "$MY_NEOVIM_PATH")
fi

listen_added=0
for arg in "$@"; do
  args=("${args[@]}" "$arg")
  if [ "$arg" = '--' ]; then
    args=("${args[@]}" "--listen" "$NVIM_SOCKET")
    listen_added=1
  fi
done

if [[ $listen_added = 0 ]]; then
  args=("${args[@]}" "--" "--listen" "$NVIM_SOCKET")
fi

NEOVIDE_BIN=neovide
MY_NEOVIDE_PATH="$HOME/codes/neovide/target/release/neovide"
if [ -e "$MY_NEOVIDE_PATH" ]; then
  echo "Found my neovide at $MY_NEOVIDE_PATH"
  NEOVIDE_BIN="$MY_NEOVIDE_PATH"
fi

if which nvr > /dev/null; then
  echo "Detected nvr, set git editor env"
  export GIT_EDITOR='nvr -cc split --remote-wait'
fi

args=("$NEOVIDE_BIN" "${args[@]}")
echo "Command is ${args[@]}"
exec "${args[@]}"