Run a TypeScript interpreter in an inferior process window
This repo is directly forked from js-comint to support TypeScript instead.
ts-comint depends on the following components:
- NodeJS
- TypeScript REPL
To use ts-comint these components must be installed on your system.
To install these run the following commands, or whatever equivalents your system provides:
apt-get install node
npm install -g tsun
To install it all you need to do is issue the following command:
M-x package-install<RET>ts-comint
You can also download the source and use that directly.
To do that, place the ts-comint.el
-file somewhere (say $HOME/mylisp/
)
and then insert the following code in your $HOME/.emacs.d/init.el
-file:
(add-to-list 'load-path "~/mylisp/")
(require 'ts-comint)
After installation, do M-x run-ts
to create a comint buffer with the
Typescript interpreter.
You can add the following couple of lines to your .emacs to take advantage of cool key bindings for sending things to the Typescript interpreter inside of typescript-mode.
(add-hook 'typescript-mode-hook
(lambda ()
(local-set-key (kbd "C-x C-e") 'ts-send-last-sexp)
(local-set-key (kbd "C-M-x") 'ts-send-last-sexp-and-go)
(local-set-key (kbd "C-c b") 'ts-send-buffer)
(local-set-key (kbd "C-c C-b") 'ts-send-buffer-and-go)
(local-set-key (kbd "C-c l") 'ts-load-file-and-go)))
ts-comint
is ~repl-toggle~ compatible. To configure, add run-ts
for typescript-mode
to rtog/mode-repl-alist
like so:
;; when configuring all repl toggle mapping
(setq rtog/mode-repl-alist '((typescript-mode . run-ts)))
;; or later
(push '(typescript-mode . run-ts) rtog/mode-repl-alist)