TextMate/TypeScript: code templates don't work
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 13, 14 RC1
### What happened
I created a code template (a.k.a. snippet or live template) to be used in TypeScript source files, but it didn't take effect.
### How to reproduce
Go to *Tools → Options → Editor → Code templates*. There, choose *TextMate languages* in the list of languages. Then, click on *New*. Type `test` in the dialog window that asks for an abbreviation, and then, in *Expanded text*, type this:
```typescript
This is just a sample test.
```
In the field called *Expand template on*, choose *Tab*.
Now open a TypeScript file, type `test` and push `[Tab]`. This should be expanded to `This is just a sample test.` but it isn't.
I've tried this in both NetBeans IDE versions, 13 and 14 RC1. I've tried it with the TypeScript plug-in that is bundled with NetBeans, and also using an external LSP server.
I've changed the key used to expand the abbreviation, but there hasn't been any luck either.
### Did this work correctly in an earlier version?
No
### Operating System
Debian GNU/Linux 11.3 (Bullseye)
### JDK
OpenJDK Runtime Environment (build 17.0.2+8-Debian-1deb11u1)
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
I've read that other IDEs, such as Eclipse and its Wild Web Developers plug-in, prefer to delegate this type of feature to the language servers (see [Custom snippets/templates](https://github.com/eclipse/wildwebdeveloper/issues/140)). Although I understand their position (human resources are limited), Wouldn't this create a very heterogeneous and confusing experience when you use multiple language servers in the same IDE? Because code templates / snippets can be implemented in very different ways: some allow to use abbreviations (NetBeans IDE), whereas others only let you choose from a list (KDE's Kate).
**Update no. 1:** I've taken a look to [LSP Specification / Snippet Syntax ](https://microsoft.github.io/language-server-protocol/specification#snippet_syntax) and I've seen that the syntax is standardized at the protocol level. So my concern about each server using its own syntax is wrong. Indeed, the syntax used by LSP looks like powerful: it allows to set a series of predefined values (choices) and even transforms based on regular expressions.
I wonder how this could fit in the NetBeans configuration, since the syntax has some differences from the one used for Java code.
**Update no 2:** I've read this: [Support for snippetSyntax](https://github.com/eclipse/lsp4j/issues/149). Unfortunately, LSP4J seems not to have implemented this feature. And NetBeans uses this library, Right? LSP4E (the own Eclipse IDE's LSP client) uses a very basic implementation for its own consumption.
### Are you willing to submit a pull request?
No
### Code of Conduct
Yes
Contributor guide
Research direction
Reproduce the issue through Tools → Options → Editor → Code templates using a TextMate language, then expand the same template in a TypeScript file with Tab and with the alternate key. Trace the TextMate code-template handling and compare it with the bundled TypeScript plug-in and an external LSP server; done means the configured text expands reliably in TypeScript files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100