Skip to content

add fish snippets from bmalehorn/vscode-fish #513

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,4 +131,5 @@ A good portion of the snippets have been forked from the following repositories:
- [vscode-react-javascript-snippets](https://.com/dsznajder/vscode-react-javascript-snippets)
- [honza/vim-snippets - Verilog](https://.com/honza/vim-snippets/blob/master/snippets/verilog.snippets)
- [vscode-relm4-snippets](https://.com/Relm4/vscode-relm4-snippets)
- [bmalehorn/vscode-fish/](https://.com/bmalehorn/vscode-fish/)
- And more...
4 changes: 4 additions & 0 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,10 @@
"language": ["eelixir", "heex"],
"path": "./snippets/eelixir.json"
},
{
"language": "fish",
"path": "./snippets/fish.json"
},
{
"language": "fortran",
"path": "./snippets/fortran.json"
Expand Down
137 changes: 137 additions & 0 deletions snippets/fish.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
{
"shebang": {
"prefix": "shebang",
"description": "shebang",
"body": "#!/usr/bin/env fish"
},
"if operator": {
"prefix": "if",
"description": "if operator",
"body": [
"if ${1:condition}",
"\t$0",
"end"
]
},
"if else operator": {
"prefix": "if-else",
"description": "if operator",
"body": [
"if ${1:condition}",
"\t${2:echo}",
"else",
"\t$0",
"end"
]
},
"else operator": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else snippet can probably be omitted since the if and if else are already defined here

"prefix": "else",
"description": "else operator",
"body": [
"else",
"\t$0"
]
},
"if compare with comparison operator": {
"prefix": "if-compare",
"description": "if operator",
"body": [
"if test ${1:first} ${2|=,!=,-eq,-ne,-gt,-ge,-lt,-le,-nt,-ot,-ef|} ${3:second}",
"\t$0",
"end"
]
},
"if else with comparison operator": {
"prefix": "if-compare-else",
"description": "if else operator",
"body": [
"if test ${1:first} ${2|=,!=,-eq,-ne,-gt,-ge,-lt,-le,-nt,-ot,-ef|} ${3:second}",
"\t${4:echo}",
"else",
"\t$0",
"end"
]
},
"while operator": {
"prefix": "while",
"description": "while operator",
"body": [
"while ${1:condition}",
"\t$0",
"end"
]
},
"while with comparison operator": {
"prefix": "while-compare",
"description": "while operator",
"body": [
"while test ${1:first} ${2|=,!=,-eq,-ne,-gt,-ge,-lt,-le,-nt,-ot,-ef|} ${3:second}",
"\t$0",
"end"
]
},
"for operator": {
"prefix": "for",
"description": "for operator",
"body": [
"for ${1:item} in ${2:collection}",
"\t$0",
"end"
]
},
"switch operator": {
"prefix": "switch",
"description": "switch operator",
"body": [
"switch ${1:variable}",
"\tcase ${2:glob}",
"\t\t${3:echo}",
"\tcase \"*\"",
"\t\t$0",
"end"
]
},
"case operator": {
"prefix": "case",
"description": "case operator",
"body": [
"case ${1:glob}",
"\t$0"
]
},
"function definition": {
"prefix": "function",
"description": "function definition",
"body": [
"function ${1:name}",
"\t$0",
"end"
]
},
"function with arguments definition": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these snippets should also be removed in favor of just having someone leverage the first function snippet.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take this comment to apply to the if and while snippet variants too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note sure what you mean here (not very familiar with snippet development). How to leverage the multiple possibility with only one snippet ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @remche, sorry for the delay.

What I had meant earlier, was someone can just use the function definition for all of these cases (no arguments, arguments, etc) if we modify the body like so:

    "body": [
      "function ${1:name} $0",
      "end"
    ]
  }

Then we don't clutter the snippets and the user's cursor will end on the first line allowing for them to specify arguments OR enter and tab to define the function body.

This same approach can be done for the if, else snippets added above too.

"prefix": "function-arguments",
"description": "function definition",
"body": [
"function ${1:name} ${2|--arguments,-a|} ${3:arguments}",
"\t$0",
"end"
]
},
"function with documentation definition": {
"prefix": "function-description",
"description": "function description",
"body": [
"function ${1:name} ${2|--description,-d|} ${3:description}",
"\t$0",
"end"
]
},
"begin end block": {
"prefix": "begin",
"description": "begin end block",
"body": [
"begin",
"\t$0",
"end"
]
}