elixir-editors / elixir-sublime-syntax

The most powerful Elixir for the most Sublime experience.
MIT License
46 stars 6 forks source link

Adding more snippets? #70

Closed freeform99 closed 7 months ago

freeform99 commented 7 months ago

Hi there,

would you be interested in adding more snippets?

I would love to contribute something to this extension, but I don't know Python, and I thought more snippets could be something helpful.

There is a good list here I think: https://github.com/florinpatrascu/vscode-elixir-snippets/blob/master/snippets/snippets.json

This is one that expands def; it was quite easy to do after reading ST's documentation:

<!-- def.sublime-snippet -->
<snippet>
    <content><![CDATA[
def ${1:name}(${2:params}) do
  $3
end
]]></content>
    <description>function definition</description>
    <scope>source.elixir</scope>
    <tabTrigger>def</tabTrigger>
</snippet>

def ⇥ Tab will result in this:

def name(params) do

end

Immediately upon expansion, name will be selected. After typing the function name, hitting ⇥ Tab again places the cursor on params (with it being selected, ) and then hitting it a third time places the cursor in the function body.

Let me know if something like this would be helpful

princemaple commented 7 months ago

There are more in https://github.com/elixir-editors/elixir-tmbundle/tree/master/Snippets. I recommend installing both, but using the syntax from this repo.

freeform99 commented 7 months ago

I didn't know about these! They can just be copied and used as-is!

Maybe include them in Elixir-Sublime-Syntax? I thought there were almost no snippets.