Skip to content
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

Feat: In commands such as edit_command_buffer set an environment variable to let the editor config setup custom behaviour #10497

Closed
IndianBoy42 opened this issue May 16, 2024 · 3 comments
Labels

Comments

@IndianBoy42
Copy link

IndianBoy42 commented May 16, 2024

when using edit_command_buffer to edit the command line, i'd love to set some custom keymaps in the opened neovim. Right now there is no direct way to detect whether neovim was opened as part of this edit_command_buffer.

@krobelus
Copy link
Member

perhaps

diff --git a/share/functions/__fish_anyeditor.fish b/share/functions/__fish_anyeditor.fish
index 2385d800e..0af3edbf6 100644
--- a/share/functions/__fish_anyeditor.fish
+++ b/share/functions/__fish_anyeditor.fish
@@ -1,6 +1,8 @@
 function __fish_anyeditor --description "Print a editor to use, or an error message"
     set -l editor
-    if set -q VISUAL
+    if set -q FISH_EDITOR
+        echo $FISH_EDITOR | read -at editor
+    else if set -q VISUAL
         echo $VISUAL | read -at editor
     else if set -q EDITOR
         echo $EDITOR | read -at editor
diff --git a/share/functions/funced.fish b/share/functions/funced.fish
index 5e2be69f8..cabbcba75 100644
--- a/share/functions/funced.fish
+++ b/share/functions/funced.fish
@@ -21,6 +21,8 @@ function funced --description 'Edit function definition'
         set editor fish
     else if set -q _flag_editor
         set editor $_flag_editor
+    else if set -q FISH_EDITOR
+        echo $FISH_EDITOR | read -at editor
     else if set -q VISUAL
         echo $VISUAL | read -at editor
     else if set -q EDITOR

@IndianBoy42
Copy link
Author

This would allow us use a different editor for fish editing commands. Which would allow me to pass an argument to the editor. But IMO its not as convenient as setting an environment variable before it is used which I can read in the editor config. To use FISH_EDITOR i'd have to set that in my fish config and add the specific arguments rather than having all behaviour contained inside the nvim editor config.

@krobelus
Copy link
Member

bind alt-e 'foo=bar edit_command_buffer' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants