10

So Microsoft offers syntax highlighting for ST2, but not much else.

How hard would it be to build a plugin that can replicate a lot of the IDE features. I figure if they can replicate it in JS (in the playground) it shouldn't be -THAT- hard to as a ST2 plugin. I'm just not sure where to start... I know how to build a ST2 plugin... but I know nothing about compilers, parsers, etc...

2
  • So? Are you intending to create a TypeScript plugin for Sublime? Is there already a Github repo? As I mentionend: I am willing to help :) Commented Oct 19, 2012 at 12:29
  • @CodeSalad I do not think I am qualified for that :( However I will greatly help anyone who is! FunkMonkey said he might start one: github.com/SublimeLinter/SublimeLinter/pull/… Commented Oct 22, 2012 at 18:45

6 Answers 6

12

[edit] Here's a list of started TS plugins, that I'll try to keep up-to-date:

[/edit]

We already added basic TypeScript support for SublimeLinter, see this pull request. This will at least show you TypeScript errors in Sublime. It works, but will be slow for big projects as all referenced files will be parsed on every lint. This needs to be fixed in the future.

As TypeScript and its services are written in TypeScript itself, they convert to JS and thus can be used from nodejs and in consequence from Sublime (as Christopher Pappas suggested). This is exactly how the TypeScript support in SublimeLinter works.

If you want to create a full-featured Sublime plugin, I advice you to take a look at the TypeScript services which provide all the necessary functions for auto-completion and such. languageService.ts should be what you are looking for. Also, you should take a look at the source-code of the TypeScript Playground, as they provide auto-completion through JS on the web. Unfortunately you have to un-minify the source yourself, as there is no offical source-code for playground.

In any case, I would be gladly willing to help if you are really interested in creating a Sublime TypeScript plugin!

[edit]

You should also look at the Sublime documentation for information about adding completions.

Sign up to request clarification or add additional context in comments.

3 Comments

Do you know if anything has changed? Seems like both of those plugins have stagnated a bit. Any of them work with ST3?
I tried sublime-typescript a couple of weeks ago, but ran into problems. they seem to have updated it 5 days ago, though.
sublime-typescript is not maintained anymore
7

There is new TypeScript Plugin for Sublime Text from Microsoft: https://github.com/Microsoft/TypeScript-Sublime-Plugin

3 Comments

This is great to know. I followed all the steps yet it's not working...I'm not getting any intellisense, syntax recognition, or anything. Basically Sublime still doesn't know what typescript is. I'm on the free Sublime Text version, do you know if you need the paid-for licensed version for it to work?
Do you have node in the PATH? Are you using version 3? I tried free version and it worked fine (syntax highlighting, intellisense, etc.) Currently I am using VS Code.
I got it to work, I think it was that I was missing the node_path variable set correctly.
2

I would have a look at these other possible solutions, particular to Node, and go from there:

Use TypeScript compiler from node

Does TypeScript provide an explicit Public API for NodeJS Module Access?

Comments

1

TypeScript Plugin for Sublime Text

  • Select

    Preferences --> Setting - User 
    
  • Add this line

    "typescript_tsdk": "<path to your folder>/node_modules/typescript/lib"
    
  • Mac And Ubuntu:

    cd ~/"Library/Application Support/Sublime Text 3/Packages"

    git clone --depth 1 https://github.com/Microsoft/TypeScript-Sublime-Plugin.git TypeScript
    
  • And on Windows:

    cd "%APPDATA%\Sublime Text 3\Packages"

    git clone --depth 1 https://github.com/Microsoft/TypeScript-Sublime-Plugin.git TypeScript
    

Comments

0

TypeScript is more than just a language and compiler. It provides with a server which can be extensible through third party plugins. We as users an design and implement our own extensions such as:

  • refactor suggestions
  • autocompletion
  • file / module custom resolution
  • compiler diagnostics
  • etc, etc

And the good part is that if you implement your solution using this infrastructure every major editor will support it out of the box :) I know that at least vscode, atom webstorm and sublime have plugins that just communicate with tsserver (TypeScript Language server) and consume all the functionality it provides.

I just entered this fantastic world, but unfortunately documentation is poor nevertheless I had some progress. If you are goind to start with this these are my recommendations:

Start here:

This is my collection of small plugins (I'm just getting started so is WIP) https://github.com/cancerberoSgx/typescript-plugins-of-mine In particular I recommend you to start with the tutorial: https://cancerberosgx.github.io/typescript-plugins-of-mine/sample-ts-plugin1/src/

Feedback is most welcome, thanks!

Comments

-3

May I suggest you have a look into Let's build a compiler or the wounderful book Language Implementation Patterns if you need a thorough reference on best practice algorithms.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.