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

Fish autocomplete on neovim (or vim) scp:// #10041

Open
AndreaHasani opened this issue Oct 1, 2023 · 3 comments
Open

Fish autocomplete on neovim (or vim) scp:// #10041

AndreaHasani opened this issue Oct 1, 2023 · 3 comments

Comments

@AndreaHasani
Copy link

Fish already has proper scp completions but they don't work on neovim scp://
I tried to implement this myself but can't figure out how to make the complete -c, work with a command argument defined. (such as neovim scp://(autocomplete).

This works with ssh (with autocomplete plugins) so I think it should be doable. Sorry for asking this here but I kinda tried to do it myself (and even get some help on chatgpt) but just can't figure out the fish syntax on the completions.

Thanks

@faho
Copy link
Member

faho commented Oct 1, 2023

even get some help on chatgpt

As a sidenote: Chatgpt (and other LLMs) are even worse than usual on a language that has as little a corpus of available code as fish script.

I heavily recommend against trying it on fish, and I have already had my time wasted by people opening PRs of LLM-generated code, and I would prefer not to have my time wasted.


Anyway, now that that's done:

This is referring to (neo)vim's "netrw" plugin/system/whatever.

It's theoretically possible to complete, but it would rely on us running ssh on the remove system to get paths, which isn't typically a neovim dependency.

Basically, what you would do is this:

complete -c nvim --condition 'string match -q "scp:*" -- (commandline -ct)' -a '(_do_scp_completion)'

If the current token starts with "scp:" make it "do" scp completions, in some form.

That function _do_scp_completion would have to:

  • Take the current token
  • Split it into protocol, user@host and file part (the syntax according to :help netrw-path is vim scp://user@host/somefile, which would be string split -m 3 /)
  • Pass the user@host and the path to ssh, like the scp completions do.

@AndreaHasani
Copy link
Author

  1. I understand the point about chatgpt, first tried to ask it to add it to the scp.fish so I could undearstand the --condition syntaax but it failed on that. After that I mostly use it to get some guides which works quite well.

Anyhow, what would be a good workflow so I can debug the complete while I work on adding it. Since I don't know the fish syntax I have to add printf statements to see what the function is getting etc.

I'm trying to do this with a nvim_scp.fish file which I store on ~/.config/fish/completions/ but after sourcing that, I need to always reboot fish for complete to get the new function (and somehow printf also does not work sometimes)

@zanchey
Copy link
Member

zanchey commented Jan 1, 2024

Probably your best option is to create ~/.config/fish/completions/nvm.fish with source /usr/share/fish/completions/nvm.fish at the top and your new completions following it.

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

No branches or pull requests

3 participants