massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-tsserver / Readme.md
1 # coc-tsserver
2
3 Tsserver language server extension for
4 [coc.nvim](https://github.com/neoclide/coc.nvim).
5
6 Tsserver is part of [TypeScript](https://github.com/microsoft/TypeScript) which
7 provide rich features for javascript and typescript.
8
9 This extension is a fork of `typescript-language-features` extension which is
10 bundled with VSCode.
11
12 **Note:** for React to work as expected, you need your JSX filetype to be
13 `javascript.jsx` or `javascriptreact` and your TSX filetype to be
14 `typescript.jsx` or `typescript.tsx` or `typescriptreact`. In coc.nvim, these
15 filetypes are mapped to `javascriptreact` and `typescriptreact` because that's
16 what tsserver uses. For filetype like `typescript.javascript`, you need
17 configure `g:coc_filetype_map` variable in vimrc.
18
19 **Note** for javascript project, configure
20 [jsconfig.json](https://code.visualstudio.com/docs/languages/jsconfig) to make
21 tsserver understand your code.
22
23 **Note:** for rename import on file rename, you have to install
24 [watchman](https://facebook.github.io/watchman/) in your \$PATH.
25
26 **Note:** for [nvm](https://github.com/creationix/nvm) users, you need configure
27 `tsserver.npm` to your global npm path or configure
28 `"tsserver.disableAutomaticTypeAcquisition": false` to disable automatic typings
29 installation.
30
31 **Note:** tsserver could be quite slow to initialize on big project, exclude
32 unneunnecessary files in your jsconfig.json/tsconfig.json.
33
34 **Note:** if you're using WSL, copy you project files from mounted dirs to linux home otherwise tsserver will not work properly.
35
36 ## Supporting
37
38 If you like my extension, consider supporting me on Patreon or PayPal:
39
40 <a href="https://www.patreon.com/chemzqm"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Patreon donate button" /> </a>
41 <a href="https://www.paypal.com/paypalme/chezqm"><img src="https://werwolv.net/assets/paypal_banner.png" alt="PayPal donate button" /> </a>
42
43 ## Install
44
45 In your vim/neovim, run command:
46
47 `:CocInstall coc-tsserver`
48
49 For yarn2 ( >= v2.0.0-rc.36) user want to use local typescript module:
50
51 - Run command `yarn dlx @yarnpkg/pnpify --sdk vim`, which will generate
52   `.vim/coc-settings.json`, with content:
53
54   ```json
55   {
56     "tsserver.tsdk": ".yarn/sdks/typescript/lib",
57     "eslint.packageManager": "yarn",
58     "eslint.nodePath": ".yarn/sdks"
59   }
60   ```
61
62 ## Features
63
64 Almost the same as VSCode.
65
66 - Supports javascript & typescript and jsx/tsx.
67 - Installs typings automatically.
68 - Commands to work with tsserver, including:
69   - `tsserver.reloadProjects`
70   - `tsserver.openTsServerLog`
71   - `tsserver.goToProjectConfig`
72   - `tsserver.restart`
73   - `tsserver.organizeImports`
74   - `tsserver.watchBuild`
75   - `tsserver.findAllFileReferences`
76 - Code completion support.
77 - Go to definition (more info in [microsoft/TypeScript#37777](https://github.com/microsoft/TypeScript/issues/37777))
78 - Code validation.
79 - Document highlight.
80 - Document symbols of current buffer.
81 - Folding and folding range of current buffer.
82 - Format current buffer, range format and format on type.
83 - Hover for documentation.
84 - Implementations codeLens and references codeLens.
85 - Organize imports command.
86 - Quickfix using code actions.
87 - Code refactor using code actions.
88 - Find references.
89 - Signature help.
90 - Rename symbols support.
91 - Rename imports on file rename, require
92   [watchman](https://facebook.github.io/watchman/) installed in your \$PATH.
93 - Search for workspace symbols.
94
95 Tsserver module first resolved from your local workspace. If it's not found, use
96 tsserver from `tsserver.tsdk` configuration or use bundled tsserver with this
97 extension.
98
99 ## Configuration options
100
101 Checkout [using the configuration
102 file](https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file)
103 for guide of coc.nvim's configuration.
104
105 - `tsserver.enable`:Enable tsserver extension, default: `true`
106 - `tsserver.locale`:Locale of tsserver, default: `""`
107 - `tsserver.typingsCacheLocation`:Folder path for cache typings, default: `""`
108 - `tsserver.formatOnType`:Run format on type special characters., default:
109   `true`
110 - `tsserver.enableJavascript`:Use tsserver for javascript files, default: `true`
111 - `tsserver.maxTsServerMemory`:Set the maximum amount of memory to allocate to
112   the TypeScript server process
113 - `tsserver.tsdk`:Directory contains tsserver.js,, default: `""`
114 - `tsserver.npm`:Executable path of npm for download typings, default: `""`
115 - `tsserver.log`:Log level of tsserver, default: `"off"`
116 - `tsserver.trace.server`:Trace level of tsserver, default: `"off"`
117 - `tsserver.pluginPaths`:Folders contains tsserver plugins, default: `[]`
118 - `tsserver.debugPort`:Debug port number of tsserver
119 - `tsserver.watchOptions`:Configure which watching strategies should be used to
120   keep track of files and directories. Requires using TypeScript 3.8+ in the
121   workspace, default: undefined.
122 - `tsserver.reportStyleChecksAsWarnings` default: `true`
123 - `tsserver.implicitProjectConfig.checkJs`:Enable checkJs for implicit project,
124   default: `false`
125 - `tsserver.implicitProjectConfig.experimentalDecorators`:Enable
126   experimentalDecorators for implicit project, default: `false`
127 - `tsserver.disableAutomaticTypeAcquisition`:Disable download of typings,
128   default: `false`
129 - `tsserver.useBatchedBufferSync`: use batched buffer synchronize support.
130 - `typescript.updateImportsOnFileMove.enable`:Enable update imports on file
131   move., default: `true`
132 - `typescript.implementationsCodeLens.enable`:Enable codeLens for
133   implementations, default: `true`
134 - `typescript.referencesCodeLens.enable`:Enable codeLens for references,
135   default: `true`
136 - `typescript.preferences.importModuleSpecifier` default: `"auto"`
137 - `typescript.preferences.importModuleSpecifierEnding` default: `"auto"`
138 - `typescript.preferences.quoteStyle` default: `"single"`
139 - `typescript.suggestionActions.enabled`:Enable/disable suggestion diagnostics
140   for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in
141   the workspace., default: `true`
142 - `typescript.validate.enable`:Enable/disable TypeScript validation., default:
143   `true`
144 - `typescript.showUnused`: show unused variable hint, default: `true`.
145 - `typescript.autoClosingTags`: Enable/disable autoClosing of JSX tags, default: `false`.
146 - `typescript.suggest.enabled` default: `true`
147 - `typescript.suggest.paths`:Enable/disable suggest paths in import statement
148   and require calls, default: `true`
149 - `typescript.suggest.autoImports`:Enable/disable auto import suggests.,
150   default: `true`
151 - `typescript.suggest.completeFunctionCalls`:Enable snippet for method
152   suggestion, default: `true`
153 - `typescript.suggest.includeCompletionsForImportStatements`: Enable/disable
154   auto-import-style completions on partially-typed import statements. Requires using
155   TypeScript 4.3+ in the workspace, default: `true`
156 - `typescript.suggest.includeCompletionsWithSnippetText`: Enable snippet completions
157   from TS Server. Requires using TypeScript 4.3+ in the workspace, default: `true`
158 - `typescript.format.enabled`:Enable/disable format of typescript files.
159 - `typescript.format.insertSpaceAfterCommaDelimiter` default: `true`
160 - `typescript.format.insertSpaceAfterConstructor` default: `false`
161 - `typescript.format.insertSpaceAfterSemicolonInForStatements` default: `true`
162 - `typescript.format.insertSpaceBeforeAndAfterBinaryOperators` default: `true`
163 - `typescript.format.insertSpaceAfterKeywordsInControlFlowStatements` default:
164   `true`
165 - `typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions`
166   default: `true`
167 - `typescript.format.insertSpaceBeforeFunctionParenthesis` default: `false`
168 - `typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets`
169   default: `false`
170 - `typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces`
171   default: `false`
172 - `typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces`
173   default: `false`
174 - `typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis`
175   default: `false`
176 - `typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces`
177   default: `false`
178 - `typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces`
179   default: `false`
180 - `typescript.format.insertSpaceAfterTypeAssertion` default: `false`
181 - `typescript.format.placeOpenBraceOnNewLineForFunctions` default: `false`
182 - `typescript.format.placeOpenBraceOnNewLineForControlBlocks` default: `false`
183 - `typescript.suggest.includeAutomaticOptionalChainCompletions`: default: `true`
184 - `javascript.format.enabled`: Enable/disable format for javascript files.
185 - `javascript.showUnused`: show unused variable hint.
186 - `javascript.autoClosingTags`: Enable/disable autoClosing of JSX tags, default: `false`.
187 - `javascript.updateImportsOnFileMove.enable` default: `true`
188 - `javascript.implementationsCodeLens.enable` default: `true`
189 - `javascript.referencesCodeLens.enable` default: `true`
190 - `javascript.preferences.importModuleSpecifier` default: `"auto"`
191 - `javascript.preferences.importModuleSpecifierEnding` default: `"auto"`
192 - `javascript.preferences.quoteStyle` default: `"single"`
193 - `javascript.validate.enable`: Enable/disable JavaScript validation., default:
194   `true`
195 - `javascript.suggestionActions.enabled`: Enable/disable suggestion diagnostics
196   for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in
197   the workspace., default: `true`
198 - `javascript.suggest.names`: default `true`
199 - `javascript.suggest.enabled`: default `true`
200 - `javascript.suggest.paths`: Enable/disable suggest paths in import statement
201   and require calls, default: `true`
202 - `javascript.suggest.autoImports`: Enable/disable auto import suggests.,
203   default: `true`
204 - `javascript.suggest.completeFunctionCalls`:Enable snippet for method
205   suggestion, default: `true`
206 - `javascript.suggest.includeCompletionsForImportStatements`: Enable/disable
207   auto-import-style completions on partially-typed import statements. Requires
208   using TypeScript 4.3+ in the workspace, default: `true`
209 - `javascript.format.insertSpaceAfterCommaDelimiter` default: `true`
210 - `javascript.format.insertSpaceAfterConstructor` default: `false`
211 - `javascript.format.insertSpaceAfterSemicolonInForStatements` default: `true`
212 - `javascript.format.insertSpaceBeforeAndAfterBinaryOperators` default: `true`
213 - `javascript.format.insertSpaceAfterKeywordsInControlFlowStatements` default:
214   `true`
215 - `javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions`
216   default: `true`
217 - `javascript.format.insertSpaceBeforeFunctionParenthesis` default: `false`
218 - `javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets`
219   default: `false`
220 - `javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces`
221   default: `false`
222 - `javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces`
223   default: `false`
224 - `javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis`
225   default: `false`
226 - `javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces`
227   default: `false`
228 - `javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces`
229   default: `false`
230 - `javascript.format.insertSpaceAfterTypeAssertion` default: `false`
231 - `javascript.format.placeOpenBraceOnNewLineForFunctions` default: `false`
232 - `javascript.format.placeOpenBraceOnNewLineForControlBlocks` default: `false`
233 - `javascript.suggest.includeAutomaticOptionalChainCompletions`: default: `true`
234
235 Configurations are the same as with VSCode. Try completion with `tsserver`,
236 `typescript` or `javascript` in your `coc-settings.json`.
237
238 ## Related extensions
239
240 - [coc-eslint](https://github.com/neoclide/coc-eslint): enable [eslint](https://github.com/eslint/eslint) plugin for tsserver to lint TypeScript and JavaScript files.
241 - [coc-tslint-plugin](https://github.com/neoclide/coc-tslint-plugin): enable [tslint](https://github.com/palantir/tslint) plugin for tsserver ([deprecated](https://github.com/palantir/tslint/issues/4534)).
242 - [coc-styled-components](https://github.com/fannheyward/coc-styled-components/): Styled component for coc.nvim as a tsserver plugin.
243 - [coc-react-refactor](https://github.com/fannheyward/coc-react-refactor): React refactor extension for coc.nvim, forked from vscode-react-refactor.
244 - [coc-vetur](https://github.com/neoclide/coc-vetur): [vue](https://github.com/vuejs/vue) extension.
245 - [coc-angular](https://github.com/iamcco/coc-angular): [angular](https://github.com/angular/angular) extension.
246
247 ## Troubleshooting
248
249 - Add `"tsserver.log": "verbose"` to your `coc-settings.json` (opened by command
250   `:CocConfig`)
251 - To trace LSP communication, add `"tsserver.trace.server": "verbose"` to your
252   `coc-settings.json`
253 - Restart coc server by command `:CocRestart`
254 - Make the issue happen.
255 - Open tsserver log file by command `CocCommand tsserver.openTsServerLog`
256 - Open tsserver output channel by command `CocCommand workspace.showOutput tsserver`
257
258 If you find any issues, please [create an
259 issue](https://github.com/neoclide/coc-tsserver/issues/new).
260
261 ## License
262
263 MIT