Skip to content
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

Auto-closing paired symbols #20

Open
Clashsoft opened this issue Dec 18, 2019 · 13 comments
Open

Auto-closing paired symbols #20

Clashsoft opened this issue Dec 18, 2019 · 13 comments
Milestone

Comments

@Clashsoft
Copy link

Clashsoft commented Dec 18, 2019

When typing new templates, it would be very useful if certain opening/closing constructs were autocompleted. This applies to:

  • the closing parenthesis after the argument list: foo( )
  • the template delimiters: << >>, <% %>, " "
  • placeholders < > (also for custom delimiters?)
  • ifs: <if( )> <endif>
  • anonymous templates: <foo:{ }>
  • ...?
@bjansen bjansen added this to the 0.9 milestone Jun 20, 2020
@bjansen
Copy link
Collaborator

bjansen commented Sep 14, 2020

Current status:

  • the closing parenthesis after the argument list: foo( )
  • the template delimiters: << >>, <% %>, " "
  • placeholders < >
  • (also for custom delimiters?)
  • ifs: <if( )> <endif>
  • quotes in attributes: <foo format=" ">
  • anonymous templates: <foo:{ }>

@parrt
Copy link
Member

parrt commented Sep 14, 2020

Keep up the great work, @bjansen !

@Clashsoft
Copy link
Author

Clashsoft commented Sep 14, 2020

@bjansen

I just realized that format="" is not really special, the quotes are just template syntax. If "" and anonymous templates already work, then shouldn't this be covered too?

Remembering what I originally had in mind when I wrote the issue, it's about offering the option names format, wrap, separator, etc. as an autocomplete dropdown. The same case can be made for functions like strip, reverse, trim, ….

Re. <endif>, do you have an idea at what point of typing <if(...)> the <endif> should be inserted? Because I'm not sure what's most intuitive. After <if may be a little to early, in case they want to type <iframe> or whatever. Maybe after the parenthesis?

@bjansen
Copy link
Collaborator

bjansen commented Sep 15, 2020

Remembering what I originally had in mind when I wrote the issue, it's about offering the option names format, wrap, separator, etc. as an autocomplete dropdown. The same case can be made for functions like strip, reverse, trim, ….

OK, so this is actual code completion (the other items were more "auto closing" than code completion per se).

do you have an idea at what point of typing <if(...)> the should be inserted?

To be consistent with XML/HTML files, I suppose <endif> should be inserted when you type the closing >, but at the moment it's automatically inserted.

@Clashsoft Clashsoft changed the title Autocompletion Auto-closing paired symbols Sep 15, 2020
@Clashsoft
Copy link
Author

I've created #33 to separate the autoclosing of symbol pairs and actual autocompletion for identifiers and keywords.

For <endif> I think it makes sense to be consistent with HTML. Maybe it doesn't need to be autocompleted at all, I imagine it could be annoying when encasing existing template text within an if/endif. Adding <endif> when typing the closing > could be a nice way to make it opt-in.

@bjansen
Copy link
Collaborator

bjansen commented Sep 15, 2020

If we make it opt-in, I think there's a good chance that users won't even know that the option exists, and thus it will never be used.

@bjansen
Copy link
Collaborator

bjansen commented Sep 15, 2020

when encasing existing template text within an if/endif.

This is probably an opportunity to implement "Surround With..." :)

@Clashsoft
Copy link
Author

I agree, Surround With is a good idea. A similar feature is Live Templates, which could make the endif problem obsolete. Here's how it looks in a shell script:

recording

@bjansen
Copy link
Collaborator

bjansen commented Sep 15, 2020

You can already define your own live templates, but sure it would be better to ship them in the plugin directly.

@bjansen
Copy link
Collaborator

bjansen commented Sep 15, 2020

Here's a preview of what I did so far. Most of what's listed in your request should work, except for <endif>s. I haven't figured out how to deal with that yet. Maybe "surround with" is enough?

jetbrains-plugin-st4-0.9-SNAPSHOT.zip

@Clashsoft
Copy link
Author

Thanks, I tested the snapshot and found the following:

  • foo() ::= " did not insert the closing "
  • delimiters " dito
  • myDict ::= [ " dito
  • <foo:{ did not insert }
  • when manually typing closing parentheses, it correctly replaces the automatically inserted one. This does not work for delimiters, however. I.e., if I press < and then >, it produces <>>, while I would have expected <>.

@bjansen
Copy link
Collaborator

bjansen commented Sep 16, 2020

Weird, it all works fine on my machine and in unit tests. How did you install the plugin?

@Clashsoft
Copy link
Author

I used "Install plugin from disk" and selected your zip file.

But I found the problem. I was testing at the top of an existing stg file. The templates had } and " scattered across. When testing at the bottom or in a blank file, it works indeed. My last point always happens though.

@bjansen bjansen modified the milestones: 0.9, 0.10 Oct 16, 2021
@bjansen bjansen modified the milestones: 0.10, 0.11 Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants