feat: Add wrapper script to automatically start neovim if no instance is
running
This commit is contained in:
@@ -15,7 +15,23 @@
|
|||||||
|
|
||||||
activation.configureGodot = let
|
activation.configureGodot = let
|
||||||
configDir = "${config.xdg.configHome}/godot";
|
configDir = "${config.xdg.configHome}/godot";
|
||||||
execFlags = pkgs.lib.escapeShellArg ''"--server ./.godothost --remote-send \":e {file} | call cursor({line},{col})<CR>\""'';
|
# This script requires $TERMINAL to be set to your default terminal
|
||||||
|
godotNvimWrapper =
|
||||||
|
pkgs.writeShellScript "godot-nvim-wrapper"
|
||||||
|
# bash
|
||||||
|
''
|
||||||
|
FILE="$1"
|
||||||
|
LINE="$2"
|
||||||
|
COL="$3"
|
||||||
|
SERVER="./.godothost"
|
||||||
|
|
||||||
|
if [ -S "$SERVER" ]; then
|
||||||
|
$(which nvim) --server "$SERVER" --remote-send ":e $FILE | call cursor($LINE,$COL)<CR>"
|
||||||
|
else
|
||||||
|
nohup "$(which $TERMINAL)" -e $(which nvim) --listen "$SERVER" "$FILE" "+call cursor($LINE,$COL)" >/dev/null 2>&1 &
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
lib.hm.dag.entryAfter ["writeBoundary"]
|
lib.hm.dag.entryAfter ["writeBoundary"]
|
||||||
# bash
|
# bash
|
||||||
@@ -36,11 +52,11 @@
|
|||||||
local key="$1"
|
local key="$1"
|
||||||
local value="$2"
|
local value="$2"
|
||||||
|
|
||||||
local sed_value="''${value//\\/\\\\}"
|
# local sed_value="''${value//\\/\\\\}"
|
||||||
sed_value="''${sed_value//&/\\&}"
|
# sed_value="''${sed_value//&/\\&}"
|
||||||
|
|
||||||
if grep -q "^$key =" "$SETTINGS_FILE"; then
|
if grep -q "^$key =" "$SETTINGS_FILE"; then
|
||||||
sed "s#^$key =.*#$key = $sed_value#" "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp" && mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE"
|
sed "s#^$key =.*#$key = $value#" "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp" && mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE"
|
||||||
else
|
else
|
||||||
if grep -q '\[resource\]' "$SETTINGS_FILE"; then
|
if grep -q '\[resource\]' "$SETTINGS_FILE"; then
|
||||||
echo "$key = $value" >> "$SETTINGS_FILE"
|
echo "$key = $value" >> "$SETTINGS_FILE"
|
||||||
@@ -50,8 +66,8 @@
|
|||||||
|
|
||||||
# External editor (nvim)
|
# External editor (nvim)
|
||||||
update_setting "text_editor/external/use_external_editor" "true"
|
update_setting "text_editor/external/use_external_editor" "true"
|
||||||
update_setting "text_editor/external/exec_path" "\"${pkgs.neovim}/bin/nvim\""
|
update_setting "text_editor/external/exec_path" "\"${godotNvimWrapper}\""
|
||||||
update_setting "text_editor/external/exec_flags" ${execFlags}
|
update_setting "text_editor/external/exec_flags" "\"{file} {line} {col}\""
|
||||||
|
|
||||||
# Catppuccin Mocha interface theme
|
# Catppuccin Mocha interface theme
|
||||||
update_setting "interface/theme/preset" "\"Custom\""
|
update_setting "interface/theme/preset" "\"Custom\""
|
||||||
|
|||||||
Reference in New Issue
Block a user