bash-lsp / bash-language-server

A language server for Bash
MIT License
2k stars 118 forks source link

Autocomplete environment variables #1169

Open Chaitanyabsprip opened 1 month ago

Chaitanyabsprip commented 1 month ago

What is the problem this feature will solve?

Currently, bash-ls provides completions only for variables that have been defined in the scope. However I wish for the server to provide completions for environment variables as well. Using environment variables are a very common occurrence when writing scripts.

What is the feature you are proposing to solve the problem?

Bash-ls should provide completions for environment variables as well. However, care should be taken that completionResolve method is not exposing the values of the environment variables. Priority should be given to variables in scope, environment variables should be trailing.

What alternatives have you considered?

currently, as a workaround I dump the envvars at the top of my file until I'm writing the script and then delete it when I'm done.

Chaitanyabsprip commented 1 month ago

I've worked on this and I'm using my version locally. I raised this issue primarily to discuss whether there is scope for this feature in this tool as well. If so, I'll quickly raise a PR.