bmalehorn / vscode-fish

Fish syntax highlighting and formatting
MIT License
65 stars 7 forks source link

Basic VS Code autosuggestions don't work #45

Open EmilyGraceSeville7cf opened 8 months ago

EmilyGraceSeville7cf commented 8 months ago

I mean them:

image

Now just builtins and keywords are suggested.

EmilyGraceSeville7cf commented 8 months ago

I assume my last PR broke this basic builtin VS Code completion.

bmalehorn commented 8 months ago

@EmilyGraceSeville7cf Ah thanks for noticing & filing the ticket.

There seems to be a way to still provide word-based completion in addition to the new suggestions. This is what the shellscript language combined with the Bash IDE extension does: image

image

So it might be worth checking out what Bash IDE does, though I'm not sure it can be replicated here without spinning it out into a separate extension: https://github.com/bash-lsp/bash-language-server/blob/7fffe661caad70fc2fc023ff8c35007047a6a76d/vscode-client/src/extension.ts

If that doesn't work, we might be able to fix this by just... implementing function-based suggestions. We get passed in a document object which we can get the whole file contents from:

https://github.com/bmalehorn/vscode-fish/blob/b7f550d6c5f76f552580d599657bed49c84e9a22/src/extension.ts#L148-L153

And we can then do something like add the following suggestions based on simple regexes:

  1. function *([^\s]+) (function definition)
  2. \$([^\s]+) (using variable)
  3. set +(-\w )*([^\s]+) (setting variable)

Lastly I can still just revert the PR for now until it works with the word-based suggestions. Do those options all make sense?

If you're not feeling like jumping on a fix soon, I'll probably just revert it until we know how to add suggestions on top of the existing ones.

EmilyGraceSeville7cf commented 8 months ago

I can't fix it right now, I have no enough knowledge on this topic. Maybe just split everything into words and add them to suggestions? I thought there is something like a default completion provider to do this task, I don't know.

I also wanted to implement completion for all commands in $PATH. It really would make the extension much better. :)