-
Notifications
You must be signed in to change notification settings - Fork 131
Bash: Add snippets for VS Code #664
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
Conversation
- the first argument is not an option - the first argument is mandatory
I guess I can do the same job for other supported editors by this extension. :) |
Thanks for the contribution!
Yes, if we move this to the server (instead of part of the vscode extension as done here), then all editors will get these snippets available. I believe that is the way to go if we support snippets. I’m curious to know how many would prefer having snippets available. I assume we need a way to disable them or potentially override them. As the server is used by a lot of people, we need to think about the reception of this feature. Example of other language servers returning snippets: https://github.com/iamcco/vim-language-server/blob/30f442dfa0ff8436eceeb2a306d1e8fd17bbdc6b/src/server/snippets.ts |
Is it possible to move snippets to server a little bit later but now accept these ones? I am not JS/TS developer that's why I am asking for it. |
That’s a nice and lean approach. Then we might get some feedback before rolling this out to all clients. Let me know once you are satisfied with these. I’m not a big snippet developer myself, so I would need to spend some time playing around with these. Maybe there are some standard bash snippets that we can get inspiration from? |
"{${1:from}..${2:to}}" | ||
] | ||
}, | ||
"echo": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how much value very basic snippets like echo
and source
provides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to save some keystrokes and quote argument automatically. :)
vscode-client/snippets/snippets.json
Outdated
"description": "[cd]", | ||
"prefix": "cd", | ||
"body": [ | ||
"cd \"${1:path/to/directory}\" || echo \"${2:error_message}\" >&2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems rather non-generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do u mean? Can you tell me what you expect to see? I've added ||
as cd
potentially can fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For snippets to be useful I believe they should be fairly generic and applicable for most users. A good example is the test
snippet that is a very generic. For cd
we assume that the user wants to handle error case like this and swallow the error (exit code would be 0 after running this).
I would like us to remove the snippet for cd
for now.
"let ${1:argument}" | ||
] | ||
}, | ||
"test": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test
seems really useful with all the different options here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=~
has been added.
- describe naming convention
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really good start! Thanks for your work. I've added a few suggestions. I believe we can release this soon. 👏
@@ -0,0 +1,16 @@ | |||
# Snippet naming convention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice with this documentation. Once the snippets are in TypeScript, then we should change this markdown file to some unit tests to ensure that this is enforced.
vscode-client/snippets/snippets.json
Outdated
"[[ ${1:argument1} ${2|-ef,-nt,-ot,==,=,!=,=~,<,>,-eq,-ne,-lt,-le,-gt,-ge|} ${3:argument2} ]]" | ||
] | ||
}, | ||
"device": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we get rid of the device
. They content here are all standard streams and not really devices, and I'm not convinced anyone would find them by typing de
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed snippet to stream
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not convinced anyone would find them by typing stream
, so I would just get rid of it. But no strong opinion here. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we don't need to type stream
we need to type dev
now as it's one of the prefixes. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah awesome! 👏
vscode-client/snippets/snippets.json
Outdated
"description": "[cd]", | ||
"prefix": "cd", | ||
"body": [ | ||
"cd \"${1:path/to/directory}\" || echo \"${2:error_message}\" >&2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For snippets to be useful I believe they should be fairly generic and applicable for most users. A good example is the test
snippet that is a very generic. For cd
we assume that the user wants to handle error case like this and swallow the error (exit code would be 0 after running this).
I would like us to remove the snippet for cd
for now.
Can I ask what best shell scripting practices to stick with to form expectations of what user might want to type? Can we assume that user don't want to include error handling for I've removed error message printing from this snippet now. |
As there isn't one standard way of doing it and the command is so trivial to type, I don't see that much value in keeping it. |
Add snippets for:
Motivation: have standardized and easy memorable snippets.