New snippet syntax #407
Replies: 8 comments 13 replies
-
The nightly build has failed, so this feature is not yet available. I hope to have it up later today. I'll update this discussion when it is. |
Beta Was this translation helpful? Give feedback.
-
Could you consider a simpler way of binding Lua snippets. I mean, currently
in this line, I have other functions in my Just another example, which might be more difficult...
IMHO, we loose this extremely nice integration of snippets with the "rest of" textadept |
Beta Was this translation helpful? Give feedback.
-
Yes, that is a good idea. I was thinking to experiment with a '```'
syntax extension for Lua code instead of Shell code, but forgot about
it. Thanks for the reminder.
|
Beta Was this translation helpful? Give feedback.
-
Lua code is supported in snippets using ```Lua code``` syntax:
846de7b
|
Beta Was this translation helpful? Give feedback.
-
Good to hear :-) I'll test and report back. I was thinking of
$`lua_code()`
because it would look more uniform. I'll try out
Thanks, /PA
…On Mon, 12 Jun 2023 at 18:08, orbitalquark ***@***.***> wrote:
Lua code is supported in snippets using ```Lua code``` syntax:
846de7b
—
Reply to this email directly, view it on GitHub
<#407 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZKU4G3TFSNHMP44C7Z53LXK45JJANCNFSM6AAAAAAZBXT7KA>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler
Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet
|
Beta Was this translation helpful? Give feedback.
-
I tried out and can do most. There is however a case which I can't cover with transforms or the current Lua proposal.
which expands to "insert '% ' if the capture 5 is empty, else insert an empty string". That would be
or
I can't find an easy way to implement this in the new syntax. Yasnippets in emacs would do this as
because they pass the text of the caption internally. But something like that or
would be helpful |
Beta Was this translation helpful? Give feedback.
-
Right, apologies, but wrapping up before the summer is being sort of a strain... Anyhow, let's see if I can make my case for Lua code referencing captures in snippets: Imagine I have my
Then, my proposed snippet syntax:
would allow to insert I need this kind of programmatic text transforms and I really don't know how to write them with the new syntax. With the years of using Textadept, I have a collected a lot of these things that make my life really easy. It would be (a bit more than just) a pity to loose them. |
Beta Was this translation helpful? Give feedback.
-
I believe this might work:
The $6 transform tries to match "volume" (the default) and captures the result to register 1. If that fails ("volume" does not match), the transform matches everything (".*") and stores that to register 0. In the replacement, the transform looks in register 1 for a non-empty value ("volume"). If that value exists, nothing is given as a replacement. Otherwise, replace with "OPT". The contents of register 0 (any typed text) is discarded. This should satisfy the "if and only if" criteria.
My goal is to help find a 1-to-1 translation of existing legacy snippets to the new format. I wouldn't want you to lose them either. |
Beta Was this translation helpful? Give feedback.
-
The next nightly build of Textadept will support TextMate- and LSP-style snippets (
${1:default}
,${2/.+/${0:/upcase}/}
, etc.) as described here. The legacy snippet format (%1(default)
,%2<lua transform code>
, etc.) is deprecated, but still supported. There is a migration guide for migrating legacy snippets. Legacy support will be sometime removed after Textadept 12.0 is released, so please consider migrating earlier rather than later.As a side effect, the LSP module now supports snippet completions.
Beta Was this translation helpful? Give feedback.
All reactions