summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-20 13:07:26 +0300
committerPaul Buetow <paul@buetow.org>2025-04-20 13:07:26 +0300
commit419bb214571f79b0d421bde3ed04a346e42784d0 (patch)
tree5cf604f4b44b5fa44621fec342e8b1a68fb6c0bd
parentd659ff23f6a8238d4565fc98d70f62ef775a914b (diff)
add editor
-rw-r--r--dotfiles/fish/conf.d/config.fish3
-rw-r--r--dotfiles/fish/conf.d/editor.fish46
2 files changed, 46 insertions, 3 deletions
diff --git a/dotfiles/fish/conf.d/config.fish b/dotfiles/fish/conf.d/config.fish
index 1d4f292..a33e4a3 100644
--- a/dotfiles/fish/conf.d/config.fish
+++ b/dotfiles/fish/conf.d/config.fish
@@ -1,8 +1,5 @@
fish_vi_key_bindings
-set -g EDITOR hx
-set -g VISUAL hx
-
# Add paths to PATH
set -U fish_user_paths ~/bin ~/go/bin ~/.cargo/bin $fish_user_paths
diff --git a/dotfiles/fish/conf.d/editor.fish b/dotfiles/fish/conf.d/editor.fish
new file mode 100644
index 0000000..ae3e77b
--- /dev/null
+++ b/dotfiles/fish/conf.d/editor.fish
@@ -0,0 +1,46 @@
+set -gx EDITOR hx
+set -gx VISUAL $EDITOR
+set -gx GIT_EDITOR $EDITOR
+set -gx HELIX_CONFIG_DIR $HOME/.config/helix
+set -gx COPILOT_MODEL gpt-4o
+set -gx HANDLER copilot
+
+function editor::helix::theme::get_random
+ echo not yet implemented
+end
+
+function editor::helix::theme::set
+ set -l theme $argv[1]
+ set -l config_file $HELIX_CONFIG_DIR/config.toml
+ # sed "/^theme =/ { s/.*/theme = \"$theme\"/; }" $config_file >$config_file.tmp
+ mv $config_file.tmp $config_file
+end
+
+function editor::helix::open_with_lock
+ set -l file $argv[1]
+ set -l lock "$file.lock"
+ if test -f "$lock"
+ if pgrep -f hx
+ echo "File lock $lock exists! Another instance is editing it?"
+ return 2
+ end
+ end
+ touch $lock
+ hx $file $argv[2..-1]
+ rm $lock
+end
+
+function editor::helix::edit::remote
+ set -l local_path $argv[1]
+ set -l remote_uri $argv[2]
+ scp $local_path $remote_uri; or return 1
+ echo "LOCAL_PATH=$local_path; REMOTE_URI=$remote_uri" >~/.hx.remote.source
+ hx $local_path
+end
+
+if test -f $HELIX_CONFIG_DIR/config.toml
+ # editor::helix::theme::set (editor::helix::theme::get_random)
+end
+
+abbr -a hxl 'editor::helix::open_with_lock'
+abbr -a rhx 'editor::helix::edit::remote'