Permalink
408 lines (336 sloc) 13.3 KB
*tsuquyomi* is a Vim plugin for TypeScript.
Version: 0.6.0
Author : Quramy <yosuke.kurami@gmail.com>
License: MIT license {{{
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}}
CONTENTS *tsuquyomi-contents*
Introduction |tsuquyomi-introduction|
Install |tsuquyomi-install|
Interface |tsuquyomi-interface|
Commands |tsuquyomi-commands|
Variables |tsuquyomi-variables|
Key Mappings |tsuquyomi-key-mappings|
Functions |tsuquyomi-functions|
Examples |tsuquyomi-examples|
==============================================================================
INTRODUCTION *tsuquyomi-introduction*
Tsuquyomi works as a client for TSServer(which is an editor service bundled into TypeScript).
This plugin provides the following functions:
+ Functions to fetch information of your source codes from TSServer.
(compeletions, locations of definition or references, error, etc...)
+ Functions to start or stop the TSServer process.
==============================================================================
INSTALL *tsuquyomi-install*
Tsuquyomi requires the following:
* Vim (v.7.4.0 or later)
* Shougo/vimproc.vim (https://github.com/Shougo/vimproc.vim)
* Node.js and TypeScript (v.1.5.0 or later)
In the first, If you haven't installed |vimproc|, please install this.
(Please see https://github.com/Shougo/vimproc.vim)
Second, install the latest version TypeScript.
Prompt:
>
$ npm -g install typescript
<
Third, locate Tsuquyomi to your Vim plugin directory.
If you use |NeoBundle| for plugin management, append the following to `.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 execute the Ex command |:NeoBundleInstall| .
Also, Tsuquyomi is an extension of |unite-outline|.
If you have installed |unite| and |unite-outline| , you can get the outline of
the current buffer calling ':Unite outline'.
==============================================================================
INTERFACE *tsuquyomi-interface*
------------------------------------------------------------------------------
COMMANDS *tsuquyomi-commands*
*:TsuquyomiStartServer*
*:TsuStartServer*
:TsuquyomiStartServer
Start TSServer process using |vimproc|.
If already the process is running, this command does not
anything.
*:TsuquyomiStopServer*
*:TsuStopServer*
:TsuquyomiStopServer
Stop TSServer process if it exists.
*:TsuquyomiStatusServer*
*:TsuStatusServer*
:TsuquyomiStatusServer
Show TSServer status.
When TSServer is running, the message 'reading' will be
displayed.
*:TsuquyomiOpen*
*:TsuOpen*
:TsuquyomiOpen [{file} ...]
Let TSServer open {file}s.
Once TSServer opens files, you can start a variety of
operations on them.
If you omit the argument {file}, TSServer opens the current
buffer.
By the default, |g:tsuquyomi_auto_open| is enable.
So, usually user don't need to exec this command manually.
*:TsuquyomiClose*
*:TsuClose*
:TsuquyomiClose [{file} ...]
Let TSServer release opened {file}s.
If you omit the argument {file}, TSServer closes the file
related to the current buffer.
*:TsuquyomiReload*
*:TsuReload*
:TsuquyomiReload [{file} ...]
Let TSServer reload files.
If you omit the argument {file}, TSServer reloads the current
buffer.
*:TsuquyomiDump*
*:TsuDump*
:TsuquyomiDump [{file} ...]
Save TSServer's buffer to files.
This command can be execute for only debug purpose.
If you omit the argument {file}, TSServer saves the file
related to the current buffer.
Note: Dumped filename is `originalFileName` + `'.dump'` .
*:TsuquyomiDefinition*
*:TsuDefinition*
:TsuquyomiDefinition
Navigate to the location where the symbol is defined.
*:TsuquyomiGoBack*
*:TsuGoBack*
:TsuquyomiGoBack
Move the cursor position to the location where
the last |:TsuquyomiDefinition| was called.
*:TsuquyomiReferences*
*:TsuReferences*
:TsuquyomiReferences
Navigate to the locations where the symbol is referenced.
The result is shown to |location-list| .
*:TsuquyomiRenameSymbol*
*:TsuRenameSymbol*
:TsuquyomiRenameSymbol
Rename the identifier under the cursor to a new name.
If the identifier is referenced by other .ts files,
you should open them before executing this command.
*:TsuquyomiRenameSymbolC*
*:TsuRenameSymbolC*
:TsuquyomiRenameSymbolC
Rename the identifier under the cursor to a new name.
This command renames the identifiers including comments.
*:TsuquyomiReloadProject*
*:TsuReloadProject*
:TsuquyomiReloadProject
Let close and re-open all files opened by |:TsuquyomiOpen|.
When you change `tsconfig.json` after open some `*.ts` files,
you should execute this command.
So, the changes of `tsconfig.json` are reflected in the
TSServer
*:TsuquyomiGeterr*
*:TsuGeterr*
:TsuquyomiGeterr
Show compilation errors of current buffer in QuickFix window.
*:TsuquyomiGeterrProject*
*:TsuGeterrProject*
:TsuquyomiGeterrProject
Show all compilation errors of your project in QuickFix window.
This command requires TypeScript@v1.6.0 or later.
*:TsuquyomiSeaarch*
*:TsuSearch*
:TsuquyomiSearch {keyword}
Search locations which containts {keyword} from ptoject.
Todo
------------------------------------------------------------------------------
VARIABLES *tsuquyomi-variables*
*g:tsuquyomi_auto_open*
g:tsuquyomi_auto_open (default 1)
Whether automatically TSServer opens the file of the current
buffer, when the buffer is opened in Vim
If you set this option to 0, you should manually exec the
|:TsuquyomiOpen| command after opening buffers.
*g:tsuquyomi_use_local_typescript*
g:tsuquyomi_use_local_typescript (default 1)
Whether to use `tsserver.js`that was installed for project
locally.
* 0: Tsuquyomi does not search `tsserver.js`.
* 1: Tsuquyomi searches the root directory(which has
`package.json`) of the project from the current directory.
Then, it searches
`node_modules/typescript/bin/tsserver.js` from the
project root.
If not hit, Tsuquyomi determines `tsserver.js` path from
|g:tsuquyomi_use_dev_node_module| option.
*g:tsuquyomi_use_dev_node_module*
g:tsuquyomi_use_dev_node_module (default 0)
Whether to use `tsserver.js` that was installed manually.
* 0: Tsuquyomi uses global installed `tsserver` command(default).
* 1: Tsuquyomi uses
`tsuquyomi/node_modules/typescript/bin/tsserver.js` .
If you use this mode, exec the following:
>
:cd ~/.vim/bundle/tsuquyomi
:!npm install
<
* 2: Tsuquyomi uses `tsserver.js` whose path is
|g:tsuquyomi_tsserver_path| .
*g:tsuquyomi_tsserver_path*
g:tsuquyomi_tsserver_path (default `''`)
If |g:tsuquyomi_use_dev_node_module| equals `2`,
user should set path of `tsserver.js` to this variable.
For example,
>
let g:tsuquyomi_use_dev_node_module = 2
let g:tsuquyomi_tsserver_path =
\ '~/typescript/built/local/tsserver.js'
<
*g:tsuquyomi_nodejs_path*
g:tsuquyomi_nodejs_path (default 'node')
A path to Node.js.
*g:tsuquyomi_definition_split*
g:tsuquyomi_definition_split (default 0)
A way to open a target file when |:TsuquyomiDefinition|.
* 0: |:edit|
* 1: |:split|
* 2: |:vplit|
* 3: |:tabedit|
*g:tsuquyomi_completion_detail*
g:tsuquyomi_completion_detail (default 0)
Whether to show details of complete menu when |tsuquyomi#complete|.
This options makes sence when |completeopt| includes "menu".
NOTE: If it's set, completions gets slow.
*g:tsuquyomi_completion_case_sensitive*
g:tsuquyomi_completion_case_sensitive (default 0)
Whether to search completion case-sensitively when
|tsuquyomi#complete|.
*g:tsuquyomi_completion_preview*
g:tsuquyomi_completion_preview (default 0)
Whether to show sigunature in preview when |tsuquyomi#complete|.
This options makes sence when |completeopt| includes "menu"
and "preview".
NOTE: If it's set, completions gets a little slow.
*g:tsuquyomi_disable_default_mappings*
g:tsuquyomi_disable_default_mappings (default 0)
If set no keys are mapped.
*g:tsuquyomi_disable_quickfix*
g:tsuquyomi_disable_quickfix (default 0)
If set, |:TsuquyomiGeterr| isn't called when you save buffers.
*g:tsuquyomi_save_onrename*
g:tsuquyomi_save_onrename (default 0)
If set, Tsuquyomi saves arbitrarily the files which have the
replaced symbols by |:TsuquyomiRenameSymbol| .
If not set, Tsuquyomi shows replaced files with |:split|.
You can save them with |:wa| after your review changes.
*g:tsuquyomi_single_quote_import*
g:tsuquyomi_single_quote_import (default 0)
If set, Tsuquyomi generates import block using single quotes
instead of double quotes when |:TsuquyomiImport|.
*g:tsuquyomi_javascript_support*
g:tsuquyomi_javascript_support (default 0)
If set, Tsuquyomi will also be enabled for JavaScript files.
You can further configure tsserver's behavior using
tsconfig.json or jsconfig.json in your project.
*g:tsuquyomi_ignore_missing_modules*
g:tsuquyomi_ignore_missing_modules (default 0)
If set, Tsuquyomi will ignore any error that starts with
"Cannot find module". Useful when you don't have type
definitions for all of your imports.
------------------------------------------------------------------------------
KEY MAPPINGS *tsuquyomi-key-mappings*
Normal mode key mappings.
*<Plug>(TsuquyomiDefinition)*
<Plug>(TsuquyomiDefinition)
Navigate to the location where the symbol on the cursor is
defined. See |:TsuquyomiDefinition|.
<Plug>(TsuquyomiGoBack) *<Plug>(TsuquyomiGoBack)*
See |:TsuquyomiGoBack|.
*<Plug>(TsuquyomiReferences)*
<Plug>(TsuquyomiReferences)
Show a list of locations where the symbol on the cursor is
referenced. See |:TsuquyomiReferences|.
*<Plug>(TsuquyomiRenameSymbol)*
<Plug>(TsuquyomiRenameSymbol)
Rename the identifier under the cursor to a new name.
Please see |:TsuquyomiRenameSymbol|.
*<Plug>(TsuquyomiRenameSymbolC)*
<Plug>(TsuquyomiRenameSymbolC)
Rename the identifier under the cursor to a new name.
Please see |:TsuquyomiRenameSymbolC|.
*<Plug>(TsuquyomiImport)*
<Plug>(TsuquyomiImport)
Generate ES6 import declaration whose alias is under
the cursor. See |:TsuquyomiImport|.
Following keymappings are default keymappings.
Normal mode default mappings.
{lhs} {rhs}
-------- -----------------------------
<C-]> <Plug>(TsuquyomiDefinition)
<C-t> <Plug>(TsuquyomiGoBack)
<C-^> <Plug>(TsuquyomiReferences)
------------------------------------------------------------------------------
FUNCTIONS *tsuquyomi-functions*
tsuquyomi#complete *tsuquyomi#complete*
It's applicable for the |completefunc| or |omnifunc| option.
By the default, Tsuquyomi set this function to the |omnifunc|
option.
If you want to customize completions, see
|tsuquyomi-example-complete|.
tsuquyomi#balloonexpr *tsuquyomi#balloonexpr*
Returns information about symbol under then mouse cursor for
tooltip popover window.
This is used as the rhs for |balloon-expr|.
For example,
>
set ballooneval
autocmd BufNewFile,BufRead *.ts
\ setlocal ballonexpr=tsuquyomi#balloonexpr()
<
Note: This function works only if your Vim is compiled with
|+balloon_eval|.
tsuquyomi#hint *tsuquyomi#hint*
Returns information about symbol under the corsor. This
function is so similar to |tsuquyomi#ballonexpr|, but
This function works in not only GVim but also terminal Vim.
For example,
>
autocmd FileType typescript nmap <buffer> <Leader>t :
\ <C-u>echo tsuquyomi#hint()<CR>
<
Todo
==============================================================================
EXAMPLES *tsuquyomi-examples*
*tsuquyomi-examples-complete*
You can configure tsuquyomi completion, using |completeopt| .
When completion in call of some method, show the method signature to
the preview window.
>
autocmd FileType typescript setlocal completeopt+=preview
<
When completion, don't show the popup menu of completions.
>
autocmd FileType typescript setlocal completeopt-=menu
<
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen: