Tsserver language server extension for coc.nvim.
Tsserver is part of TypeScript which provide rich features for javascript and typescript.
This extension is a fork of typescript-language-features extension which is bundled with VSCode.
Note: for React to work as expected, you need your JSX filetype to be
javascript.jsx and your TSX filetype to be typescript.jsx or
typescript.tsx. In coc.nvim, these filetypes are mapped to javascriptreact
and typescriptreact because that's what tsserver uses.
Note for javascript project, configure jsconfig.json to make tsserver understand your code.
In your vim/neovim, run command:
:CocInstall coc-tsserver
For yarn2 ( >= v2.0.0-rc.36) user want to use local typescript module:
-
Run command
yarn dlx @yarnpkg/pnpify --sdk vim, which will generate.vim/coc-settings.json, with content:{ "tsserver.tsdk": ".yarn/sdks/typescript/lib", "eslint.packageManager": "yarn", "eslint.nodePath": ".yarn/sdks" }
Disable nvm with the following command:
nvm deactivate
Next, find out what the global path of your installed version of npm with the following command:
which npm
The output of the above command should go into the tsserver.npm property in your coc-settings.json file, a partial example listed below:
"tsserver.npm": "/usr/local/bin/npm"
Almost the same as VSCode.
- Supports javascript & typescript and jsx/tsx.
- Installs typings automatically.
- Commands to work with tsserver, including:
tsserver.reloadProjectstsserver.openTsServerLogtsserver.goToProjectConfigtsserver.restarttsserver.organizeImportstsserver.watchBuild
- Code completion support.
- Go to definition.
- Code validation.
- Document highlight.
- Document symbols of current buffer.
- Folding and folding range of current buffer.
- Format current buffer, range format and format on type.
- Hover for documentation.
- Implementations codeLens and references codeLens.
- Organize imports command.
- Quickfix using code actions.
- Code refactor using code actions.
- Find references.
- Signature help.
- Rename symbols support.
- Rename imports on file rename, require watchman installed in your $PATH.
- Search for workspace symbols.
Tsserver module first resolved from your local workspace. If it's not found,
use tsserver from tsserver.tsdk configuration or use bundled tsserver with
this extension.
Checkout using the configuration file for guide of coc.nvim's configuration.
tsserver.enable:Enable tsserver extension, default:truetsserver.locale:Locale of tsserver, default:""tsserver.typingsCacheLocation:Folder path for cache typings, default:""tsserver.formatOnType:Run format on type special characters., default:truetsserver.enableJavascript:Use tsserver for javascript files, default:truetsserver.maxTsServerMemory:Set the maximum amount of memory to allocate to the TypeScript server processtsserver.tsdk:Directory contains tsserver.js,, default:""tsserver.npm:Executable path of npm for download typings, default:""tsserver.log:Log level of tsserver, default:"off"tsserver.trace.server:Trace level of tsserver, default:"off"tsserver.pluginRoot:Folder contains tsserver plugins, default:[]tsserver.debugPort:Debug port number of tsservertsserver.watchOptions:Configure which watching strategies should be used to keep track of files and directories. Requires using TypeScript 3.8+ in the workspace, default: undefined.tsserver.reportStyleChecksAsWarningsdefault:truetsserver.implicitProjectConfig.checkJs:Enable checkJs for implicit project, default:falsetsserver.implicitProjectConfig.experimentalDecorators:Enable experimentalDecorators for implicit project, default:falsetsserver.disableAutomaticTypeAcquisition:Disable download of typings, default:falsetsserver.useBatchedBufferSync: use batched buffer synchronize support.typescript.updateImportsOnFileMove.enable:Enable update imports on file move., default:truetypescript.implementationsCodeLens.enable:Enable codeLens for implementations, default:truetypescript.referencesCodeLens.enable:Enable codeLens for references, default:truetypescript.preferences.importModuleSpecifierdefault:"auto"typescript.preferences.importModuleSpecifierEndingdefault:truetypescript.preferences.quoteStyledefault:"single"typescript.suggestionActions.enabled:Enable/disable suggestion diagnostics for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace., default:truetypescript.validate.enable:Enable/disable TypeScript validation., default:truetypescript.showUnused: show unused variable hint, default:true.typescript.suggest.enableddefault:truetypescript.suggest.paths:Enable/disable suggest paths in import statement and require calls, default:truetypescript.suggest.autoImports:Enable/disable auto import suggests., default:truetypescript.suggest.completeFunctionCalls:Enable snippet for method suggestion, default:truetypescript.format.enabled:Enable/disable format of typescript files.typescript.format.insertSpaceAfterCommaDelimiterdefault:truetypescript.format.insertSpaceAfterConstructordefault:falsetypescript.format.insertSpaceAfterSemicolonInForStatementsdefault:truetypescript.format.insertSpaceBeforeAndAfterBinaryOperatorsdefault:truetypescript.format.insertSpaceAfterKeywordsInControlFlowStatementsdefault:truetypescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctionsdefault:truetypescript.format.insertSpaceBeforeFunctionParenthesisdefault:falsetypescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBracketsdefault:falsetypescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBracesdefault:falsetypescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesisdefault:falsetypescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBracesdefault:falsetypescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBracesdefault:falsetypescript.format.insertSpaceAfterTypeAssertiondefault:falsetypescript.format.placeOpenBraceOnNewLineForFunctionsdefault:falsetypescript.format.placeOpenBraceOnNewLineForControlBlocksdefault:falsetypescript.suggest.includeAutomaticOptionalChainCompletions: default:truejavascript.format.enabled: Enable/disable format for javascript files.javascript.showUnused: show unused variable hint.javascript.updateImportsOnFileMove.enabledefault:truejavascript.implementationsCodeLens.enabledefault:truejavascript.referencesCodeLens.enabledefault:truejavascript.preferences.importModuleSpecifierdefault:"auto"javascript.preferences.importModuleSpecifierEndingdefault:truejavascript.preferences.quoteStyledefault:"single"javascript.validate.enable: Enable/disable JavaScript validation., default:truejavascript.suggestionActions.enabled: Enable/disable suggestion diagnostics for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace., default:truejavascript.suggest.names: defaulttruejavascript.suggest.enabled: defaulttruejavascript.suggest.paths: Enable/disable suggest paths in import statement and require calls, default:truejavascript.suggest.autoImports: Enable/disable auto import suggests., default:truejavascript.suggest.completeFunctionCalls:Enable snippet for method suggestion, default:truejavascript.format.insertSpaceAfterCommaDelimiterdefault:truejavascript.format.insertSpaceAfterConstructordefault:falsejavascript.format.insertSpaceAfterSemicolonInForStatementsdefault:truejavascript.format.insertSpaceBeforeAndAfterBinaryOperatorsdefault:truejavascript.format.insertSpaceAfterKeywordsInControlFlowStatementsdefault:truejavascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctionsdefault:truejavascript.format.insertSpaceBeforeFunctionParenthesisdefault:falsejavascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBracketsdefault:falsejavascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBracesdefault:falsejavascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesisdefault:falsejavascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBracesdefault:falsejavascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBracesdefault:falsejavascript.format.insertSpaceAfterTypeAssertiondefault:falsejavascript.format.placeOpenBraceOnNewLineForFunctionsdefault:falsejavascript.format.placeOpenBraceOnNewLineForControlBlocksdefault:falsejavascript.suggest.includeAutomaticOptionalChainCompletions: default:true
Configurations are the same as with VSCode. Try completion with tsserver, typescript
or javascript in your coc-settings.json.
- coc-eslint: enable eslint plugin for tsserver to lint TypeScript and JavaScript files.
- coc-tslint-plugin: enable tslint plugin for tsserver (deprecated).
- coc-vetur: vue extension.
- coc-angular: angular extension.
- Add
"tsserver.log": "verbose"to yourcoc-settings.json(opened by command:CocConfig) - To trace LSP communication, add
"tsserver.trace.server": "verbose"to yourcoc-settings.json - Restart coc server by command
:CocRestart - Make the issue happen.
- Open tsserver log file by command
CocCommand tsserver.openTsServerLog - Open tsserver output channel by command
CocCommand workspace.showOutput tsserver
If you find any issues, please create an issue.
MIT