• Stars
    star
    1,384
  • Rank 33,956 (Top 0.7 %)
  • Language
    Vim Script
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Vim plugin for TypeScript

Tsuquyomi Build Status Greenkeeper badge

Make your Vim a TypeScript IDE.

capture

Features

Tsuquyomi works as a client for TSServer (which is an editor service bundled into TypeScript). So, installing Tsuquyomi, your vim gets the following features provided by TSServer:

  • Completion (omni-completion)
  • Navigate to the location where a symbol is defined.
  • Show location(s) where a symbol is referenced.
  • Display a list of syntax and semantics errors to Vim quickfix window.
  • and so on,,,

Relevant plugins

Tsuquyomi does not provide syntax-highlight nor indentation. You can use the following Vim plugins for writing .ts:

How to install

Tsuquyomi requires the following:

Install TypeScript

npm -g install typescript

Install Tsuquyomi

Download zip.file from here, or use your favorite Vim plugin manager.

Pathogen

See https://github.com/tpope/vim-pathogen for instructions to install pathogen itself (very simple one-line install, one-line config)

# create bundle folder if it doesn't exist
mkdir -p ~/.vim/bundle

# Install and compile procvim.vim
git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim
pushd ~/.vim/bundle/vimproc.vim
make
popd

# Install tsuquyomi
git clone https://github.com/Quramy/tsuquyomi.git ~/.vim/bundle/tsuquyomi

NeoBundle

If you use NeoBundle for Vim plugin management, append the following to your .vimrc:

NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\     'windows' : 'tools\\update-dll-mingw',
\     'cygwin' : 'make -f make_cygwin.mak',
\     'mac' : 'make -f make_mac.mak',
\     'linux' : 'make',
\     'unix' : 'gmake',
\    },
\ }

NeoBundle 'Quramy/tsuquyomi'

And exec :NeoBundleInstall.

(About vimproc installation, please see the original install guide.)

How to use

Completion

Tsuquyomi supports Omni-Completion.

By the default, type <C-x> <C-o> in insert mode, Tsuquyomi shows completions.

Customize completion

You can configure completion with the completeopt option.

If you don't want the popup menu:

autocmd FileType typescript setlocal completeopt-=menu

If you want to show a method's signature in the popup menu, set g:tsuquyomi_completion_detail. Remarks: This option makes completion slow

let g:tsuquyomi_completion_detail = 1

If you want to show a method's signature in the preview window when you complete this method's arguments (default):

(The preview window isn't shown when completion properties or variables)

autocmd FileType typescript setlocal completeopt+=menu,preview

Navigations

Definition

Type <C-]> in normal mode or visual mode, Tsuquyomi navigates to the location where the symbol under the cursor is defined.

Alternatively, call the Ex command :TsuquyomiDefinition or :TsuDefinition. (All Tsuquyomi's commands have aliases with short prefix 'Tsu'.)

And type <C-t> , Tsuquyomi moves the cursor to the location where the last <C-]> was typed.

Type Definition

:TsuTypeDefinition command is similar to :TsuDefinition. :TsuTypeDefinition navigates to the location where the type of the symbol under the cursor is defined.

References

Type <C-^> in normal mode or visual mode, Tsuquyomi shows a list of location where the symbol under the cursor is referenced.

Alternatively, call the Ex command :TsuReferences.

If you want where an interface is implemented, use :TsuImplementation.

Keyword search

Call the Ex command :TsuSearch {keyword} to get the list of locations which contain the keyword. This command searches the keyword from opened or referenced files in your project.

The search term minimum length can be configured with let g:tsuquyomi_search_term_min_length = 3.

Disable default mappings

If you do not want to use the above key mappings please add let g:tsuquyomi_disable_default_mappings = 1 to your .vimrc file.

Show compile errors

When a buffer is saved, Tsuquyomi checks syntax and semantics. Alternatively call the Ex command :TsuGeterr. And if it contains errors, Tsuquyomi shows them to Vim quickfix window.

If your use TypeScript v1.6.0 or later, you can use :TsuGeterrProject command. This command shows all compilation errors contained in your project to quickfix window.

Quick fix

If the cursor is on an error and TypeScript's LanguageService has a code fix for this error, call :TsuQuickFix. The code fix will be applied.

Configure compile options

Make tsconfig.json.

For example:

{
  "compilerOptions": {
    "noImplicitAny": true,
    "target": "es5",
    "module": "commonjs"
  }
}

When you change tsconfig.json after opening *.ts files, you should exec :TsuquyomiReloadProject command. So, the changes of tsconfig.json are reflected in the TSServer.

Integrate with syntastic

If you use syntastic, you can use syntastic for displaying syntax and semantics errors instead of vim's default quickfix window. To integrate syntastic, write the following setting to your .vimrc.

let g:tsuquyomi_disable_quickfix = 1
let g:syntastic_typescript_checkers = ['tsuquyomi'] " You shouldn't use 'tsc' checker.

syntastic has default TypeScript checker whose name is 'tsc'. You shouldn't use it with running Tusuquyomi because they don't share compile options. Tusuquyomi's checker whose name is 'tsuquyomi' uses tsserver and your tsconfig.json.

Refactor

Rename symbols

Using the command :TsuRenameSymbol, you can rename the identifier under the cursor to a new name.

If you want to rename identifiers including in comments, you can use :TsuRenameSymbolC command. For example, this command is useful when you want rename opt in the following code:

/**
*
* @param opt
*
**/
var someFunc = (opt: any) => {...};

This feature does not have the default key mapping. If you need, configure your .vimrc . For example:

autocmd FileType typescript nmap <buffer> <Leader>e <Plug>(TsuquyomiRenameSymbol)
autocmd FileType typescript nmap <buffer> <Leader>E <Plug>(TsuquyomiRenameSymbolC)

Tooltip

Tsuquyomi can display tooltip window about symbol under the mouse cursor. If you want to use this feature, configure .vimrc as follows:

set ballooneval
autocmd FileType typescript setlocal balloonexpr=tsuquyomi#balloonexpr()

The ballonexpr option is not available in terminal Vim. So, Tsuquyomi also provides a tooltip function tsuquyomi#hint().

For example:

autocmd FileType typescript nmap <buffer> <Leader>t : <C-u>echo tsuquyomi#hint()<CR>

The above example works in terminal Vim.

Unite sources

Tsuquyomi provides some unite sources.

Show project information(a source of unite)

Execute the following command, your project information is displayed.

:Unite tsproject

The project information contains:

  • tsconfig.json which the current buffer use.
  • .ts(or .tsx) source files which TypeScript compiles. These files are determined by tsconfig.json

This feature requires [email protected] or later.

Show outline(an extension of unite-outline)

This feature requires Vim plugins:

If you have installed these plugins, calling the following Ex command, the outline of the current buffer is displayed.

:Unite outline

Use TypeScript installed locally

By the default, Tsuquyomi searches locally installed TypeScript. If not hit, Tsuquyomi uses TypeScript installed globally.

And execute the following command, you can confirm the path of tsserver:

:echo tsuquyomi#config#tsscmd()

Create es6 import declaration

It's highly experimental

For example, if your buffer is the following state:

readFile('hoge', 'utf-8', (err, content) => {
  if(!err) console.log(content);
});

Move cursor onto readFile and call :TsuImport, so Tsuquyomi appends the import declaration.

import { readFile } from 'fs';
readFile('hoge', 'utf-8', (err, content) => {
  if(!err) console.log(content);
});

To allow Tsuquyomi to import the shortest path instead of the complete one (where the initial module declaration is) one, put this in your .vimrc:

let g:tsuquyomi_shortest_import_path = 1

For example, if your project has the following 2 files, the plugin will use: import { foo } from './lib'; instead of: import { foo } from './lib/foo';.

/* lib/index.ts */
export * from './foo';
/* lib/foo.ts */
export const foo = 'FOO'

More details

If you want more details, please see doc.

Contribute

How to test

Prepare test

cd test/
yarn install
cd ..

Run test cases

# Run all test cases with all supported TypeScript version
./runtest-all-ts.sh

# Run all test cases with the latest TypeScript version
./runtest.sh

# Run all test cases with the specified TypeScript version
VERSION=2.3 ./runtest.sh

# Run a test file
./run-one-test.sh test/path/to/test.spec.vim

# Run a test file with the specified TypeScript version
VERSION=2.3 ./run-one-test.sh

License

MIT

More Repositories

1

typed-css-modules

Creates .d.ts files from CSS Modules .css files
TypeScript
918
star
2

lerna-yarn-workspaces-example

How to build TypeScript mono-repo project with yarn and lerna
TypeScript
893
star
3

ts-graphql-plugin

TypeScript Language Service Plugin for GraphQL developers
TypeScript
674
star
4

electron-connect

Livereload tool for Electron
JavaScript
339
star
5

npm-ts-workspaces-example

Monorepos example project using npm workspaces and TypeScript project references
TypeScript
315
star
6

jest-prisma

Jest environment for integrated testing with Prisma client
TypeScript
269
star
7

typescript-eslint-language-service

TypeScript language service plugin for ESLint
TypeScript
252
star
8

prisma-fabbrica

Prisma generator to define model factory
TypeScript
248
star
9

eslint-plugin-tutorial

A tutorial/template repository to explain how to create your eslint plugins
TypeScript
196
star
10

gql-study-workshop

TypeScript
146
star
11

vim-js-pretty-template

highlights JavaScript's Template Strings in other FileType syntax rule
Vim Script
143
star
12

electron-jsx-babel-boilerplate

Electron boilerplate with React.js and babel
JavaScript
118
star
13

vison

A Vim plugin for writing JSON with JSON Schema
Vim Script
96
star
14

zisui

Yet another CLI to screenshot your Storybook
TypeScript
72
star
15

angular-puppeteer-demo

A demonstration repository explains how to using Puppeteer in unit testing
TypeScript
58
star
16

pico-ml

A toy programming language which is a subset of OCaml.
TypeScript
50
star
17

x-img-diff

Detect structural difference information of 2 images considering into translation
C++
47
star
18

graphql-decorator

TypeScript
43
star
19

apollo-link-fragment-argument

An Apollo Link to enable to parameterize fragments
TypeScript
41
star
20

better-name

CLI tool to move JavaScript(ES2015) or TypeScript module files
TypeScript
35
star
21

type-dungeon

TypeScript code exercise
TypeScript
31
star
22

talt

Template functions to generate TypeScript AST node object
TypeScript
30
star
23

ngx-typed-forms

Extends Angular reactive forms strongly typed
TypeScript
27
star
24

loadable-ts-transformer

TypeScript custom transformer for loadable-components SSR
TypeScript
26
star
25

typescript-css-modules-demo

A working demo of CSS Modules, using TypeScript, css-modulesify and typed-css-modules
TypeScript
25
star
26

angular2-load-children-loader

A webpack loader for ng2 lazy loading
JavaScript
23
star
27

electron-disclosure

Sample electron app
JavaScript
22
star
28

ng2-lazy-load-demo

A sample repository for Angular2 lazy module loading
TypeScript
22
star
29

opencv-wasm-knnmatch-demo

Web Assembly OpenCV Feature Matching Demonstration
JavaScript
21
star
30

ionic-apollo-simple-app

Explains how to develop Ionic application with Apollo GraphQL client
TypeScript
19
star
31

ngx-zombie-compiler

Fast JiT compiler for Angular testing
TypeScript
15
star
32

decode-tiff

⚡ A lightweight JavaScript TIFF decoder 🎨
JavaScript
15
star
33

ts-server-side-anatomy

Explain what TypeScript server(tsserver) does under your editors
TypeScript
15
star
34

tsuquyomi-vue

vim plugin for TypeScript and Vue.js
Vim Script
15
star
35

generator-ngdoc

Yeoman generator for AngularJS's module documentation
JavaScript
14
star
36

prisma-yoga-example

GraphQL server example using Prisma and graphql-yoga
TypeScript
14
star
37

ts-playground-plugin-vim

TypeScript Playground plugin for Vim keybindings
TypeScript
11
star
38

tsc-react-example

Example to compile React JSX with TypeScript
JavaScript
10
star
39

puppeteer-example

JavaScript
10
star
40

angular-recursive

AngularJS directives for recursive data.
JavaScript
9
star
41

nirvana-js

⚡ JavaScript file runner using Electron
TypeScript
9
star
42

server-components-with-container-presentation

TypeScript
8
star
43

zakki

7
star
44

dgeni-ngdocs-example

JavaScript
7
star
45

rxdb-simple-chat-app

simple chat application using RxDB
JavaScript
7
star
46

falcor-firebase

It provides a Falcor datasource from your Firebase database
JavaScript
7
star
47

swagger-codegen-customize-sample

A sample repository for customize swagger-codegen
HTML
6
star
48

falcor-lambda

creates AWS Lambda handler from Falcor's data source
JavaScript
6
star
49

angular-karma-chrome-headless-demo

TypeScript
6
star
50

storycov

TypeScript
5
star
51

prisma2-nexus-example

TypeScript
5
star
52

screenshot-testing-demo-ngjp18

Demonstration repository "Screenshot test with Angular" session ng-japan18
TypeScript
5
star
53

apollo-angular-example

An example repository to explain how to integrate Apollo and Angular
TypeScript
5
star
54

serverless-falcor-starter

A Serverless project including Falcor routing.
JavaScript
5
star
55

vim-dtsm

A Vim plugin to execute TypeScript dtsm command
Vim Script
4
star
56

dotfiles

settings
Vim Script
4
star
57

arlecchino

TypeScript
4
star
58

angular-sss-demo

Storybook, Screenshot, and Snapshot testing for Angular
TypeScript
4
star
59

next-js-msw-study

TypeScript
3
star
60

graphql-script-sample

Shell script GraphQL client for GitHub v4 API sample
Shell
3
star
61

storybook-angular-cli-helper

TypeScript
3
star
62

storyshots-with-portal-repro

JavaScript
3
star
63

simple-coverage-diff-action

TypeScript
3
star
64

fretted-strings

Mark on your strings and get it's position
TypeScript
3
star
65

face_of_the_year

Python
3
star
66

vim-json-schema-nav

Vim Script
3
star
67

apollo-sandbox

TypeScript
2
star
68

ts-react-css-modules-example

A sample repository for React JSX with CSS Modules for TypeScript
TypeScript
2
star
69

graphql-streaming-example

GraphQL @defer/@stream example
TypeScript
2
star
70

tsjp-resources

TypeScript
2
star
71

react-apollo-ssr-demo

TypeScript
2
star
72

eslint-plugin-unlearned-kanji

TypeScript
2
star
73

react-css-note

HTML
2
star
74

inspectorium

Inspect your GitHub source code
TypeScript
2
star
75

example-of-generator-ngdoc

An example repository of generator-ngdoc(an Yeoman generator)
JavaScript
2
star
76

test-with-aot-summary

Explains how to Angular's AOT result in unit testing
TypeScript
2
star
77

copl-ts

CoPL本のTypeScript実装
TypeScript
2
star
78

astsx

TypeScript
2
star
79

prignore

Chrome-extension for GitHub PR
JavaScript
2
star
80

karma-nightmare-angular-demo

A working demonstration for visual regression testing of Angular application.
TypeScript
2
star
81

abacus-ts

Calculator implemented by only TypeScript type operation
TypeScript
1
star
82

puppeteer-coverage-study

TypeScript
1
star
83

pkg-study

JavaScript
1
star
84

sewordle

A chrome extension which generates tag cloud using user query keywords inputed at search-engine.
JavaScript
1
star
85

react-falcor-demo

Demonstration of Falcor and React
TypeScript
1
star
86

nopmdcheck

A jenkins plugin to check "NOPMD" comments in workspace.
JavaScript
1
star
87

type-apollo-local-state

TypeScript
1
star
88

fuse-postcss-example

A Fuse-Box with PostCSS example repository.
CSS
1
star
89

ts-api-study

TypeScript
1
star
90

dotson

TypeScript
1
star
91

prisma-dmmf-viewer

Display Prisma DMMF(Data Model Meta Format)
JavaScript
1
star
92

typescript-api-tutrial

1
star
93

apollo-client-37-study

TypeScript
1
star
94

ccvsample

JavaScript
1
star
95

ossc-hackathon-ardrone-14

JavaScript
1
star
96

Quramy

1
star
97

crudsample

this is a sample application on node (express + mongoose).
JavaScript
1
star
98

reproduce-apollo-react-memleak

To reproduce react-apollo memory leak
TypeScript
1
star
99

groovy-labo

Groovy
1
star
100

es7study

JavaScript
1
star