Skip to content

zig: add snippets #563

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

zig: add snippets #563

wants to merge 7 commits into from

Conversation

ddogfoodd
Copy link
Contributor

@ddogfoodd ddogfoodd commented Mar 20, 2025

add snippets for:

  • if/else statement
  • if statement error handling
  • while loop
  • while loop with continue expression
  • for loop
  • for loop with index
  • function
  • error
  • switch
  • enum
  • enum with type specification
  • struct
  • struct with defaults
  • union
  • tagged union
  • page allocator
  • fixed buffer allocator
  • debug allocator

add snippets for:
if statement error handling
while loop
while loop with continue expression
for loop
for loop with index
function
switch
enum
enum with type specification
struct
struct with defaults
add:
- page allocator
- fixed buffer allocator
- debug allocator
@ddogfoodd ddogfoodd changed the title zig: add basic snippets zig: add snippets Mar 30, 2025
Comment on lines 123 to 136
"struct": {
"prefix": "struct",
"body": [
"const ${1:Name} = struct { ${2:named_field}: ${3:field_type} };"
],
"description": "struct"
},
"struct w/ defaults": {
"prefix": "structd",
"body": [
"const ${1:Name} = struct { ${2:named_field}: ${3:field_type} = ${4:default_value} };"
],
"description": "struct with defaults"
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two snippets can be a single snippet by making the body have the final cursor move end here:

"const ${1:Name} = struct { ${2:named_field}: ${3:field_type} ${0:default_or_end}};"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't that leave the last = missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe = could be incorporated like ${0: = default_or_end}? What do you think @OkelleyDevelopment ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants