-
Notifications
You must be signed in to change notification settings - Fork 132
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
Sourcing aware symbols (completion + jump to definition) #244
Conversation
@nikita-skobov let me know if you want to try this out. I would like your feedback. |
Codecov Report
@@ Coverage Diff @@
## main #244 +/- ##
==========================================
+ Coverage 75.29% 76.68% +1.39%
==========================================
Files 19 20 +1
Lines 688 755 +67
Branches 122 139 +17
==========================================
+ Hits 518 579 +61
- Misses 153 155 +2
- Partials 17 21 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I'll play around with this more tomorrow, but for now, as an overall impression I have this to say: Please note I am biased because I created and use a bash transclusion preprocessor which uses an import syntax. Now despite using a preprocessor, this extension, prior to this PR, would still show me onHover, and onCompletion for variables/functions defined in other files. This is/was very convenient to me because I can write a script like: import * from some_file.sh
some_funct And as I start typing Also, in other projects of mine, I have source statements that are dynamic based on other variables, consider: if [[ -z $SCRIPTPATH ]]; then SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" ; fi
LIBPATH="$SCRIPTPATH/../../lib/lib.sh"
if [[ -z $__COMPLETION_LIB_LOADED ]]; then source "$LIBPATH" ; fi Even though the lib.sh file is within the same repository, and contains functions that are used by many scripts in this project, this PR would prevent those functions from getting autocompletion/onhover. I realize that many people use this project, and I don't want my bias from getting in the way of a good feature being added Some ideas to consider before merging this PR:
Lastly, I just have a question: is this an optimization? Is it for performance, or user experience? In the gif posted above it seems you are showing an example where you have to scroll quite a bit until you find the variables you are looking for. Idk about others, but my experience with code completion is I usually start typing the variable/function I want to use, and if it doesnt show up right away, I type another character. Usually after 2 or 3 characters there's only one or two left in the list, and I can hit enter. (PS. How do you make gifs of code? I've done so before and It envolved |
Thank you so much for your very valuable feedback! 🙌
My primary concern with this project (and most software I write) is the user experience. :) I want the server to be as useful as possible... and I thought that completing on all symbols in the workspace to be annoying for some users. But my challenge with this project is that I only use bash for smaller scripts (so the current implementation where we return all workspace symbols works for me). You raised a lot of great points here: dynamic imports, usage of preprocessors (tbh I was not aware of these), custom import keywords.
The point was that a lot of the suggestions are irrelevant and not in scope.
licecap but there are also some alternatives |
e447dd2
to
f959c12
Compare
b22dfb4
to
7de5865
Compare
- Only variables found in the sourced files are completed on - Jump to definition works on the source file path (e.g. clicking "source my-file.sh")
This fixes a small bug in vscode where documentation that pops out to the right was not formatted using markdown.
6df1739
to
dff893f
Compare
Related #220 (not solving
local
scope).This PR supports:
. my-file.sh
orsource ~/something
). This is done with a regular expression for now until the grammar supports this nativelyincludeAllWorkspaceSymbols
configuration option.Before
After
Update November, 2022
This seems like a nice improvement, and the solution from 2020 has been improved to resolve paths based on the workspace folder and the sourcing file. We also dynamically load files that are sourced so the background analysis is not really needed.