Code Monkey home page Code Monkey logo

coc-tsserver's Introduction

coc-tsserver

Tsserver language server extension for coc.nvim.

Tsserver is part of TypeScript which provide rich language features for javascript and typescript.

This extension is a fork of typescript-language-features extension which is bundled with VSCode. File type detect and syntax highlight are not supported by this extension, use other vim plugin instead.

Important note: from v2.0.0, tsserver module resolved first from global configuration tsserver.tsdk and use bundled module when not found, if tsserver.useLocalTsdk is enabled, workspace folder configured tsserver.tsdk or typescript module inside current workspace folder would be used when exists.

Install

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/sdks vim, which will generate .vim/coc-settings.json, with content:

    {
      "eslint.packageManager": "yarn",
      "eslint.nodePath": ".yarn/sdks",
      "workspace.workspaceFolderCheckCwd": false,
      "tsserver.tsdk": ".yarn/sdks/typescript/lib"
    }

Features

Almost the same as VSCode.

  • Supports javascript & typescript and jsx/tsx.
  • Installs typings automatically.
  • Commands to work with tsserver, including:
    • tsserver.reloadProjects
    • tsserver.openTsServerLog
    • tsserver.goToProjectConfig
    • tsserver.restart
    • tsserver.watchBuild
    • tsserver.findAllFileReferences
  • Code completion support.
  • Go to definition (more info in microsoft/TypeScript#37777)
  • 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.
  • Source code action, including:
    • Fix all fixable JS/TS issues.
    • Remove all unused code.
    • Add all missing imports.
    • Organize Imports.
    • Sort Imports.
    • Remove Unused Imports
  • Find references.
  • Signature help.
  • Call hierarchy.
  • Selection range.
  • Semantic tokens.
  • Rename symbols support.
  • Automatic tag closing.
  • Rename imports on file rename, require watchman installed in your $PATH.
  • Search for workspace symbols.
  • Inlay hints support using virtual text feature of neovim, which requires:
    • TypeScript >= 4.4.0
    • Neovim >= 0.4.0
    • Enabled by options starts with typescript.inlayHints or javascript.inlayHints.

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.

Commands

Commands contributed to :CocList commands

  • tsserver.reloadProjects Reload current project
  • tsserver.openTsServerLog Open log file of tsserver.
  • tsserver.goToProjectConfig Open project config file.
  • tsserver.restart Restart tsserver
  • tsserver.findAllFileReferences Find File References
  • tsserver.goToSourceDefinition Go to Source Definition
  • tsserver.watchBuild Run tsc --watch for current project by use vim's job feature.
  • tsserver.executeAutofix Fix autofixable problems of current document.
  • tsserver.chooseVersion Choose different typescript version for current project.

Configuration options

Checkout :h coc-configuration for guide of coc.nvim's configuration.

  • tsserver.enable: Enable running of tsserver. Default: true
  • tsserver.tsconfigPath: Path to tsconfig file for the tsserver.watchBuild command. Default: "tsconfig.json"
  • tsserver.locale: Sets the locale used to report JavaScript and TypeScript errors. Defaults to use VS Code's locale. Default: "auto" Valid options: ["auto","de","es","en","fr","it","ja","ko","ru","zh-CN","zh-TW"]
  • tsserver.useLocalTsdk: Use tsserver from typescript module in workspace folder, ignore tsserver.tsdk configuration. Default: false
  • tsserver.maxTsServerMemory: Set the maximum amount of memory to allocate to the TypeScript server process Default: 3072
  • tsserver.watchOptions: Configure which watching strategies should be used to keep track of files and directories. Requires using TypeScript 3.8+ in the workspace.
  • tsserver.tsdk: Specifies the folder path to the tsserver and lib*.d.ts files under a TypeScript install to use for IntelliSense, for example: ./node_modules/typescript/lib. - When specified as a user setting, the TypeScript version from tsserver.tsdk automatically replaces the built-in TypeScript version. - When specified as a workspace setting, the tsserver is used when tsserver.useLocalTsdk is true. Use command :CocCommand tsserver.chooseVersion to choose different typescript version. Default: ""
  • tsserver.npm: Specifies the path to the npm executable used for Automatic Type Acquisition. Default: ""
  • tsserver.log: Log level of tsserver Default: "off" Valid options: ["normal","terse","verbose","off"]
  • tsserver.trace.server: Trace level of tsserver Default: "off" Valid options: ["off","messages","verbose"]
  • tsserver.enableTracing: Enables tracing TS server performance to a directory. These trace files can be used to diagnose TS Server performance issues. The log may contain file paths, source code, and other potentially sensitive information from your project. Default: false
  • tsserver.pluginPaths: Additional paths to discover TypeScript Language Service plugins. Default: []
  • tsserver.reportStyleChecksAsWarnings: Report style checks as warnings. Default: true
  • tsserver.implicitProjectConfig.checkJs: Enable checkJs for implicit project Default: false
  • tsserver.implicitProjectConfig.module: Sets the module system for the program. See more: https://www.typescriptlang.org/tsconfig#module. Default: "ESNext" Valid options: ["CommonJS","AMD","System","UMD","ES6","ES2015","ES2020","ESNext","None","ES2022","Node12","NodeNext"]
  • tsserver.implicitProjectConfig.target: Set target JavaScript language version for emitted JavaScript and include library declarations. See more: https://www.typescriptlang.org/tsconfig#target. Default: "ES2020" Valid options: ["ES3","ES5","ES6","ES2015","ES2016","ES2017","ES2018","ES2019","ES2020","ES2021","ES2022","ESNext"]
  • tsserver.implicitProjectConfig.strictNullChecks: Enable/disable strict null checks in JavaScript and TypeScript files that are not part of a project. Existing jsconfig.json or tsconfig.json files override this setting. Default: true
  • tsserver.implicitProjectConfig.strictFunctionTypes: Enable/disable strict function types in JavaScript and TypeScript files that are not part of a project. Existing jsconfig.json or tsconfig.json files override this setting. Default: true
  • tsserver.implicitProjectConfig.experimentalDecorators: Enable experimentalDecorators for implicit project Default: false
  • tsserver.disableAutomaticTypeAcquisition: Disables automatic type acquisition. Automatic type acquisition fetches @types packages from npm to improve IntelliSense for external libraries. Default: false
  • tsserver.useSyntaxServer: Controls if TypeScript launches a dedicated server to more quickly handle syntax related operations, such as computing code folding. Default: "auto" Valid options: ["always","never","auto"]
  • tsserver.experimental.enableProjectDiagnostics: (Experimental) Enables project wide error reporting. Default: false
  • typescript.check.npmIsInstalled: Check if npm is installed for Automatic Type Acquisition. Default: true
  • typescript.showUnused: Show unused variable hint. Default: true
  • typescript.showDeprecated: Show deprecated variable hint. Default: true
  • typescript.updateImportsOnFileMove.enabled: Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Default: "prompt" Valid options: ["prompt","always","never"]
  • typescript.implementationsCodeLens.enabled: Enable codeLens for implementations Default: false
  • typescript.referencesCodeLens.enabled: Enable codeLens for references Default: false
  • typescript.referencesCodeLens.showOnAllFunctions: Enable/disable references CodeLens on all functions in typescript files. Default: false
  • typescript.preferences.importModuleSpecifier: Preferred path style for auto imports. Default: "shortest" Valid options: ["shortest","relative","non-relative","project-relative"]
  • typescript.preferences.importModuleSpecifierEnding: Preferred path ending for auto imports. Default: "auto" Valid options: ["auto","minimal","index","js"]
  • typescript.preferences.jsxAttributeCompletionStyle: Preferred style for JSX attribute completions. Default: "auto" Valid options: ["auto","braces","none"]
  • typescript.preferences.includePackageJsonAutoImports: Enable/disable searching package.json dependencies for available auto imports. Default: "auto" Valid options: ["auto","on","off"]
  • typescript.preferences.quoteStyle: Preferred quote style to use for quick fixes. Default: "auto" Valid options: ["auto","single","double"]
  • typescript.preferences.useAliasesForRenames: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: true
  • typescript.preferences.autoImportFileExcludePatterns: Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.
  • typescript.preferences.renameShorthandProperties: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: true
  • typescript.suggestionActions.enabled: Enable/disable suggestion diagnostics for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace. Default: true
  • typescript.validate.enable: Enable/disable TypeScript validation. Default: true
  • typescript.suggest.enabled: Enabled/disable autocomplete suggestions. Default: true
  • typescript.suggest.paths: Enable/disable suggest paths in import statement and require calls Default: true
  • typescript.suggest.autoImports: Enable/disable auto import suggests. Default: true
  • typescript.suggest.completeFunctionCalls: Enable snippet for method suggestion Default: true
  • typescript.suggest.includeCompletionsForImportStatements: Enable/disable auto-import-style completions on partially-typed import statements. Requires using TypeScript 4.3+ in the workspace. Default: true
  • typescript.suggest.includeCompletionsWithSnippetText: Enable/disable snippet completions from TS Server. Requires using TypeScript 4.3+ in the workspace. Default: true
  • typescript.suggest.classMemberSnippets.enabled: Enable/disable snippet completions for class members. Requires using TypeScript 4.5+ in the workspace Default: true
  • typescript.suggest.jsdoc.generateReturns: Enable/disable generating @return annotations for JSDoc templates. Requires using TypeScript 4.2+ in the workspace. Default: true
  • typescript.format.enable: Enable format for typescript. Default: true
  • typescript.format.insertSpaceAfterCommaDelimiter: Defines space handling after a comma delimiter. Default: true
  • typescript.format.insertSpaceAfterConstructor: Defines space handling after the constructor keyword. Default: false
  • typescript.format.insertSpaceAfterSemicolonInForStatements: Defines space handling after a semicolon in a for statement. Default: true
  • typescript.format.insertSpaceBeforeAndAfterBinaryOperators: Defines space handling after a binary operator. Default: true
  • typescript.format.insertSpaceAfterKeywordsInControlFlowStatements: Defines space handling after keywords in a control flow statement. Default: true
  • typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions: Defines space handling after function keyword for anonymous functions. Default: true
  • typescript.format.insertSpaceBeforeFunctionParenthesis: Defines space handling before function argument parentheses. Default: false
  • typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: Defines space handling after opening and before closing non-empty parenthesis. Default: false
  • typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: Defines space handling after opening and before closing non-empty brackets. Default: false
  • typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces: Defines space handling after opening and before closing empty braces. Default: false
  • typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: Defines space handling after opening and before closing non-empty braces. Default: false
  • typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: Defines space handling after opening and before closing template string braces. Default: false
  • typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: Defines space handling after opening and before closing JSX expression braces. Default: false
  • typescript.format.insertSpaceAfterTypeAssertion: Defines space handling after type assertions in TypeScript. Default: false
  • typescript.format.placeOpenBraceOnNewLineForFunctions: Defines whether an open brace is put onto a new line for functions or not. Default: false
  • typescript.format.placeOpenBraceOnNewLineForControlBlocks: Defines whether an open brace is put onto a new line for control blocks or not. Default: false
  • typescript.format.semicolons: Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace. Default: "ignore" Valid options: ["ignore","insert","remove"]
  • typescript.suggest.includeAutomaticOptionalChainCompletions: Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled. Default: true
  • typescript.workspaceSymbols.scope: Controls which files are searched by go to symbol in workspace. Default: "allOpenProjects" Valid options: ["allOpenProjects","currentProject"]
  • typescript.autoClosingTags: Enable/disable automatic closing of JSX tags. Default: true
  • typescript.preferGoToSourceDefinition: Makes Go to Definition avoid type declaration files when possible by triggering Go to Source Definition instead. Requires using TypeScript 4.7+ in the workspace. Default: false
  • javascript.showUnused: Show unused variable hint. Default: true
  • javascript.showDeprecated: Show deprecated variable hint. Default: true
  • javascript.updateImportsOnFileMove.enabled: Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Default: "prompt" Valid options: ["prompt","always","never"]
  • javascript.implementationsCodeLens.enabled: Enable/disable implementations CodeLens. This CodeLens shows the implementers of an interface. Default: false
  • javascript.referencesCodeLens.enabled: Enable/disable references CodeLens in JavaScript files. Default: false
  • javascript.referencesCodeLens.showOnAllFunctions: Enable/disable references CodeLens on all functions in JavaScript files. Default: false
  • javascript.preferences.importModuleSpecifier: Preferred path style for auto imports. Default: "shortest" Valid options: ["shortest","relative","non-relative","project-relative"]
  • javascript.preferences.importModuleSpecifierEnding: Preferred path ending for auto imports. Default: "auto" Valid options: ["auto","minimal","index","js"]
  • javascript.preferences.jsxAttributeCompletionStyle: Preferred style for JSX attribute completions. Default: "auto" Valid options: ["auto","braces","none"]
  • javascript.preferences.quoteStyle: Preferred quote style to use for quick fixes. Default: "auto" Valid options: ["auto","single","double"]
  • javascript.preferences.useAliasesForRenames: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: true
  • javascript.preferences.autoImportFileExcludePatterns: Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.
  • javascript.preferences.renameShorthandProperties: Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace. Default: true
  • javascript.validate.enable: Enable/disable JavaScript validation. Default: true
  • javascript.suggestionActions.enabled: Enable/disable suggestion diagnostics for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace. Default: true
  • javascript.suggest.names: Enable/disable including unique names from the file in JavaScript suggestions. Note that name suggestions are always disabled in JavaScript code that is semantically checked using @ts-check or checkJs. Default: true
  • javascript.suggest.enabled: Enabled/disable autocomplete suggestions. Default: true
  • javascript.suggest.paths: Enable/disable suggest paths in import statement and require calls Default: true
  • javascript.suggest.autoImports: Enable/disable auto import suggests. Default: true
  • javascript.suggest.completeFunctionCalls: Enable snippet for method suggestion Default: true
  • javascript.suggest.includeCompletionsForImportStatements: Enable/disable auto-import-style completions on partially-typed import statements. Requires using TypeScript 4.3+ in the workspace. Default: true
  • javascript.suggest.classMemberSnippets.enabled: Enable/disable snippet completions for class members. Requires using TypeScript 4.5+ in the workspace Default: true
  • javascript.suggest.jsdoc.generateReturns: Enable/disable generating @return annotations for JSDoc templates. Requires using TypeScript 4.2+ in the workspace. Default: true
  • javascript.format.enable: Enable format for javascript. Default: true
  • javascript.format.insertSpaceAfterCommaDelimiter: Default: true
  • javascript.format.insertSpaceAfterConstructor: Default: false
  • javascript.format.insertSpaceAfterSemicolonInForStatements: Default: true
  • javascript.format.insertSpaceBeforeAndAfterBinaryOperators: Default: true
  • javascript.format.insertSpaceAfterKeywordsInControlFlowStatements: Default: true
  • javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions: Default: true
  • javascript.format.insertSpaceBeforeFunctionParenthesis: Default: false
  • javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: Default: false
  • javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: Default: false
  • javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces: Default: false
  • javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: Default: false
  • javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: Default: false
  • javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: Default: false
  • javascript.format.insertSpaceAfterTypeAssertion: Default: false
  • javascript.format.placeOpenBraceOnNewLineForFunctions: Default: false
  • javascript.format.placeOpenBraceOnNewLineForControlBlocks: Default: false
  • javascript.suggest.includeAutomaticOptionalChainCompletions: Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled. Default: true
  • typescript.inlayHints.parameterNames.enabled: Enable/disable inlay hints of parameter names. Default: "none" Valid options: ["none","literals","all"]
  • typescript.inlayHints.parameterNames.suppressWhenArgumentMatchesName: Suppress parameter name hints on arguments whose text is identical to the parameter name. Default: true
  • typescript.inlayHints.parameterTypes.enabled: Enable/disable inlay hints of parameter types. Default: false
  • typescript.inlayHints.variableTypes.enabled: Enable/disable inlay hints of variable types. Default: false
  • typescript.inlayHints.propertyDeclarationTypes.enabled: Enable/disable inlay hints of property declarations. Default: false
  • typescript.inlayHints.functionLikeReturnTypes.enabled: Enable/disable inlay hints of return type for function signatures. Default: false
  • typescript.inlayHints.enumMemberValues.enabled: Enable/disable inlay hints of enum member values. Default: false
  • typescript.inlayHints.variableTypes.suppressWhenTypeMatchesName: Suppress type hints on variables whose name is identical to the type name. Requires using TypeScript 4.8+ in the workspace. Default: true
  • javascript.inlayHints.parameterNames.enabled: Enable/disable inlay hints of parameter names. Default: "none" Valid options: ["none","literals","all"]
  • javascript.inlayHints.parameterNames.suppressWhenArgumentMatchesName: Suppress parameter name hints on arguments whose text is identical to the parameter name. Default: true
  • javascript.inlayHints.parameterTypes.enabled: Enable/disable inlay hints of parameter types. Default: false
  • javascript.inlayHints.variableTypes.enabled: Enable/disable inlay hints of variable types. Default: false
  • javascript.inlayHints.propertyDeclarationTypes.enabled: Enable/disable inlay hints of property declarations. Default: false
  • javascript.inlayHints.functionLikeReturnTypes.enabled: Enable/disable inlay hints of return type for function signatures. Default: false
  • javascript.inlayHints.enumMemberValues.enabled: Enable/disable inlay hints of enum member values. Default: false
  • javascript.inlayHints.variableTypes.suppressWhenTypeMatchesName: Suppress type hints on variables whose name is identical to the type name. Requires using TypeScript 4.8+ in the workspace. Default: true
  • javascript.autoClosingTags: Enable/disable automatic closing of JSX tags. Default: true
  • javascript.preferGoToSourceDefinition: Makes Go to Definition avoid type declaration files when possible by triggering Go to Source Definition instead. Requires using TypeScript 4.7+ in the workspace. Default: false
  • javascript.format.semicolons: Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace. Default: "ignore" Valid options: ["ignore","insert","remove"]
  • javascript.suggest.completeJSDocs: Enable/disable suggestion to complete JSDoc comments. Default: true
  • typescript.suggest.completeJSDocs: Enable/disable suggestion to complete JSDoc comments. Default: true
  • javascript.suggest.objectLiteralMethodSnippets.enabled: Enable/disable snippet completions for methods in object literals. Requires using TypeScript 4.7+ in the workspace Default: true
  • typescript.suggest.objectLiteralMethodSnippets.enabled: Enable/disable snippet completions for methods in object literals. Requires using TypeScript 4.7+ in the workspace Default: true

Most Configurations are the same as with VSCode. Install coc-json and try completion with tsserver, typescript or javascript in your coc-settings.json.

Differences between VSCode

Added configurations by coc-tsserver:

  • tsserver.useLocalTsdk only works when used as workspace folder configuration.
  • tsserver.tsconfigPath
  • tsserver.enable

Removed configurations:

  • typescript.tsserver.useSeparateSyntaxServer Use tsserver.useSyntaxServer instead.
  • typescript.enablePromptUseWorkspaceTsdk No propmpts given.
  • typescript.tsc.autoDetect Used for task, not supported.
  • typescript.surveys.enabled Not supported.

Renamed configurations to use tsserver as prefix:

  • typescript.tsdk => tsserver.tsdk
  • typescript.disableAutomaticTypeAcquisition => tsserver.disableAutomaticTypeAcquisition
  • typescript.npm => tsserver.npm
  • typescript.locale => tsserver.locale
  • typescript.tsserver.maxTsServerMemory => tsserver.maxTsServerMemory
  • typescript.tsserver.watchOptions => tsserver.watchOptions
  • typescript.tsserver.useSyntaxServer => tsserver.useSyntaxServer
  • typescript.tsserver.log => tsserver.log
  • typescript.tsserver.trace => tsserver.trace.server
  • typescript.tsserver.enableTracing => tsserver.enableTracing
  • typescript.tsserver.pluginPaths => tsserver.pluginPaths
  • typescript.reportStyleChecksAsWarnings => tsserver.reportStyleChecksAsWarnings
  • js/ts.implicitProjectConfig.checkJs => tsserver.implicitProjectConfig.checkJs
  • js/ts.implicitProjectConfig.experimentalDecorators => tsserver.implicitProjectConfig.experimentalDecorators
  • js/ts.implicitProjectConfig.module => tsserver.implicitProjectConfig.module
  • js/ts.implicitProjectConfig.target => tsserver.implicitProjectConfig.target
  • js/ts.implicitProjectConfig.strictNullChecks => tsserver.implicitProjectConfig.strictNullChecks
  • js/ts.implicitProjectConfig.strictFunctionTypes => tsserver.implicitProjectConfig.strictFunctionTypes
  • typescript.tsserver.experimental.enableProjectDiagnostics => tsserver.experimental.enableProjectDiagnostics

Related extensions

Troubleshooting

  • Add "tsserver.log": "verbose" to your coc-settings.json (opened by command :CocConfig)
  • To trace LSP communication, add "tsserver.trace.server": "verbose" to your coc-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.

Q & A

Q: Automatic type acquisition not work.

A: configure tsserver.npm to your global npm path or configure "tsserver.disableAutomaticTypeAcquisition": false to disable automatic typings installation.

Q: The extension needs some time to work.

A: The initialize of tsserver requires some time, you can add g:coc_status to your status line, see :h coc-status. If your tsserver get slow, try exclude unnecessary files in your jsconfig.json/tsconfig.json, make sure typescript version > 4.9 and disable logging (disabled by default).

Q: Update import on file rename not work.

A: Make sure install watchman in your $PATH. Use command :CocCommand workspace.showOutput watchman to check watchman output.

Q: Not work with buffer just created.

A: Tsserver treat buffer without a disk file belongs to implicit project, VSCode could work because VSCode create empty file first for buffer, save the buffer to disk to make tsserver work.

Q: Not work with my javascript project.

A: Configure jsconfig.json to make tsserver understand your code. Some features may still not work well, it's recommended to use typescript.

Q: Not work on WSL.

A: Copy you project files from mounted dirs to linux home otherwise tsserver may not work properly.

Sponsoring

If you like coc-tsserver, consider supporting me on Patreon or PayPal:

Patreon donate button PayPal donate button

License

MIT

coc-tsserver's People

Contributors

alextes avatar azemetre avatar bobylito avatar carlosala avatar chemzqm avatar chmln avatar christopher-francisco avatar ckipp01 avatar clhuang avatar fannheyward avatar homburg avatar ishanraychaudhuri avatar jpoppe avatar ksaveljev avatar meatwallace avatar mogulla3 avatar morgsmccauley avatar rexagod avatar richchurcher avatar rschristian avatar seletskiy avatar shiro avatar simnalamburt avatar taylon avatar timtyrrell avatar vegerot avatar weirongxu avatar wincent avatar xuanduc987 avatar yardnsm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coc-tsserver's Issues

I get [coc.nvim] error: Error on formatOnType: Cannot read property 'filter' of undefined

...in a tsx file when I enter some text and then press esc.

I have:

    "coc.preferences.formatOnType": true,
    "coc.preferences.formatOnSaveFiletypes": [
      "typescript",
      "typescriptreact",
      "javascript",
      "javascriptreact"
    ],

When I set "coc.preferences.formatOnType": false then the error doesn't come anymore.
Btw what does formatOnType exactly format? It seems that all formatting is done on save by prettier and eslint

Import code action always provides paths relative to baseUrl

This is a minimal reproduction of the problem: baseurl-issue.tar.gz

Steps to Reproduce

Set some value for baseUrl in TypeScript's compiler options:

{
  "compilerOptions": {
    "baseUrl": "node_modules"
  }
}

Create two files, one of which refers to a symbol that is exported by the other but where the relevant import line is missing:

// src/a.ts
export const a = 1
// src/b.ts
export const b = a

Place the cursor on the symbol a in src/b.ts and bring up code actions (e.g. with a key bound to <plug>(coc-codeactions)).

Expected Results

The code action to import a should provide an import path that is relative to src/b.ts:

Import 'a' from module "./a"

I checked the quickfix options in VS Code in the same minimal project, and saw the result that I expected.

Actual Results

The code action to import a provides an import path that is relative to baseUrl. In this case the path is "../src/a" instead of "./a". These are the options that I see provided by coc-tsserver:

:call CocActionAsync('codeAction',     '')
Choose by number:
1. Import 'a' from module "../src/a"
2. Add import
3. Convert named export to default export
4. Move to a new file
Type number and <Enter> or click with mouse (empty cancels):

I noticed that there is a similar issue that has been address in the TypeScript project: microsoft/TypeScript#19920

How do I rename file

Thanks @chemzqm for this wonderful project. Please how do I rename a file so that imports are renamed?

Apologies in case this has been documented somewhere but I can't seem to find it.

Thanks.

Getting 'No Project' error with 1.3.4 and 1.3.5

With coc-tsserver verisons 1.3.4 and 1.3.5, tsserver can no longer see my TS project config. I've tried this with multiple TS projects. With both 1.3.4 and 1.3.5 I see streams of errors as shown below. Reverting to coc-tsserver 1.3.3 fixes the issue.

The Definition not found error was from me trying to jump to a symbol. The Could not determine TypeScript or JavaScript project. error was from me trying to execute tsserver.goToProjectConfig.

## versions

vim version: NVIM v0.4.0-dev
node version: v11.15.0
coc.nvim version: 0.0.69
term: Apple_Terminal
platform: darwin

## Messages[coc.nvim] Definition not found
[coc.nvim] Error on 'highlight': Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:123461:23)
    at ProjectService.doEnsureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126300:131)
    at ProjectService.ensureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126295:75)
    at IOSession.Session.getFileAndProjectWorker (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129803:87)
    at IOSession.Session.getFileAndProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129786:29)
    at IOSession.Session.getDocumentHighlights (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129619:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129028:61)
    at /Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:88
    at IOSession.Session.executeWithRequestId (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130457:28)
    at IOSession.Session.executeCommand (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:33)
    at IOSession.Session.onMessage (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130488:35)
    at Interface.<anonymous> (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:131789:27)
    at Interface.emit (events.js:193:13)
    at Interface._onLine (readline.js:307:10)
    at Interface._normalWrite (readline.js:448:12)
    at Socket.ondata (readline.js:164:10)
    at Socket.emit (events.js:193:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:231:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:154:17)
[coc.nvim] Error on 'highlight': Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:123461:23)
    at ProjectService.doEnsureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126300:131)
    at ProjectService.ensureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126295:75)
    at IOSession.Session.getFileAndProjectWorker (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129803:87)
    at IOSession.Session.getFileAndProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129786:29)
    at IOSession.Session.getDocumentHighlights (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129619:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129028:61)
    at /Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:88
    at IOSession.Session.executeWithRequestId (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130457:28)
    at IOSession.Session.executeCommand (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:33)
    at IOSession.Session.onMessage (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130488:35)
    at Interface.<anonymous> (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:131789:27)
    at Interface.emit (events.js:193:13)
    at Interface._onLine (readline.js:307:10)
    at Interface._normalWrite (readline.js:448:12)
    at Socket.ondata (readline.js:164:10)
    at Socket.emit (events.js:193:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:231:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:154:17)
[coc.nvim] Error on 'highlight': Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:123461:23)
    at ProjectService.doEnsureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126300:131)
    at ProjectService.ensureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126295:75)
    at IOSession.Session.getFileAndProjectWorker (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129803:87)
    at IOSession.Session.getFileAndProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129786:29)
    at IOSession.Session.getDocumentHighlights (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129619:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129028:61)
    at /Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:88
    at IOSession.Session.executeWithRequestId (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130457:28)
    at IOSession.Session.executeCommand (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:33)
    at IOSession.Session.onMessage (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130488:35)
    at Interface.<anonymous> (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:131789:27)
    at Interface.emit (events.js:193:13)
    at Interface._onLine (readline.js:307:10)
    at Interface._normalWrite (readline.js:448:12)
    at Socket.ondata (readline.js:164:10)
    at Socket.emit (events.js:193:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:231:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:154:17)
[coc.nvim] Could not determine TypeScript or JavaScript project.
[coc.nvim] Error on 'highlight': Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:123461:23)
    at ProjectService.doEnsureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126300:131)
    at ProjectService.ensureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126295:75)
    at IOSession.Session.getFileAndProjectWorker (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129803:87)
    at IOSession.Session.getFileAndProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129786:29)
    at IOSession.Session.getDocumentHighlights (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129619:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129028:61)
    at /Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:88
    at IOSession.Session.executeWithRequestId (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130457:28)
    at IOSession.Session.executeCommand (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:33)
    at IOSession.Session.onMessage (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130488:35)
    at Interface.<anonymous> (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:131789:27)
    at Interface.emit (events.js:193:13)
    at Interface._onLine (readline.js:307:10)
    at Interface._normalWrite (readline.js:448:12)
    at Socket.ondata (readline.js:164:10)
    at Socket.emit (events.js:193:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:231:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:154:17)
4 fewer lines

[coc.nvim] Error on 'highlight': Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:123461:23)
    at ProjectService.doEnsureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126300:131)
    at ProjectService.ensureDefaultProjectForFile (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:126295:75)
    at IOSession.Session.getFileAndProjectWorker (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129803:87)
    at IOSession.Session.getFileAndProject (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129786:29)
    at IOSession.Session.getDocumentHighlights (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129619:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:129028:61)
    at /Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:88
    at IOSession.Session.executeWithRequestId (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130457:28)
    at IOSession.Session.executeCommand (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130466:33)
    at IOSession.Session.onMessage (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:130488:35)
    at Interface.<anonymous> (/Users/jason/Downloads/intern-lf-test/node_modules/typescript/lib/tsserver.js:131789:27)
    at Interface.emit (events.js:193:13)
    at Interface._onLine (readline.js:307:10)
    at Interface._normalWrite (readline.js:448:12)
    at Socket.ondata (readline.js:164:10)
    at Socket.emit (events.js:193:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:231:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:154:17)

Unable to resolve typescript paths

When using coc-tsserver in a project that uses typescript paths for importing modules.

i.e. import * as utils from "@my-app/utils"

coc-tsserver is unable to correctly resolve the module.

tsserver not starting

After opening a .ts file, CocInfo shows no tsserver starting and I have no syntax highlighting, completion, or jumping. A checkhealth shows that everything is clean. The other extensions I have are coc-json and coc-neosnippet

If I do a CocList extensions, it shows the three extensions, all enabled but only the neosnippet extension is activated. If I manually launch coc-tsserver, I see that it starts without error in the log and even loads the ts config file properly. A ps shows that a tsserver executable is running. However, even at this point, trying to jump to a function definition shows an error [coc.nvim] Definition provder not found for current document. No other messages are available from messages.

I should also mention that I have cquery enabled as another language server in CocConfig but I'm not sure if that would impact things. I've checked that the tsserver.enable option is set to true in the configuration as well, and have no other customizations.

Any ideas what could be wrong or how to troubleshoot further?

Thanks!

TSServer keeps exiting "normally"

I'm working in a typescript react project where the every few minutes the tsserver will shutdown.

i get the following logs

running CocOpenLog:

    at TypeScriptCompletionItemProvider.<anonymous> (/path/to/coc/extensions/node_modules/coc-tsserver/lib/server/features/completionItemProvider.js:99:34)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/coc/extensions/node_modules/tslib/tslib.js:104:62)

running CocInfo:

[Info  - 5:52:02 pm] TSServer normal exit
[Info  - 5:52:02 pm] TSServer log file: /path/to/bq/sh9c7r_n6_31x2l71lc6n5zr0000gn/T/coc-nvim-tsc.log

in the TSServer log file:

Info 8972 [17:52:2.96] request:
    {"seq":61,"type":"request","command":"completionInfo","arguments":{"file":"/path/to/file","line":70,"offset":16,"includeExternalModuleExports":true,"includeInsertTextCompletions":true}}
Info 8973 [17:52:2.96] Starting updateGraphWorker: Project: /path/to/tsconfig.json

I am currently running 3.5.1 but this was also occurring on 3.4.5.

The strange part is tsserver says it is exiting normally.

It would be great to get to the bottom of this OR provide a few to automatically restart TSServer on "normal" exit.

Unable to resolve typescript paths with minimal setup

This is similar to #9 but I have a much more minimal setup.

Project Layout:

├── package.json
├── src
│   ├── lib.ts
│   └── main.ts
└── tsconfig.json

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  }
}

src/main.ts

import a from '@/lib'

console.log(a)

src/lib.ts

export default 123

workspace output:

[Trace  - 5:00:18 PM] Sending request: compilerOptionsForInferredProjects (0). Response expected: no. Current queue length: 0
Arguments: {
    "options": {
        "module": "commonjs",
        "target": "es2016",
        "jsx": "preserve",
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "allowNonTsExtensions": true
    }
}

How to activate ES6 arrow functions in symbols list?

Hello,

First, congratulations for your CoC plugin, it's a fantastic extension for Neovim!

I just noticed that the coc-tsserver does not list functions defined with the ES6 arrow syntax:

function normalfunc (a,b) {
  return a + b
}

const arrofunc = (a,b) => {
 return a + b
}

If I do a symbols listing, then only normalfunc fill be listed.

Is there a way to configure the ES6 syntax?

[coc.nvim] engine coc & vscode not found

Hi

Upon start of Vim, I get this error message:
[coc.nvim] engine coc & vscode not found in /home/xxx/.config/coc/extensions/node_modules/typescript/package.json

I have installed coc through Plug and coc-tsserver via :CocInstall. I am not using nvm.

What should I do? Can I provide some additional info?

Thanks a million!

suppress missing declaration errors

Hi, I'm using the tsserver for javascript only (no typescript files) is there a way to keep the functionality for js, but not get the missing declaration errors for imported modules?

example of what I mean: the module listed has no ts types

[tsserver 7016] [I] Could not find a declaration file for module '@ux/radio-group'. '/Documents/Projects/top-navigation/n
  Try `npm install @types/ux__radio-group` if it exists or add a new declaration (.d.ts) file containing `declare module '@ux/radio-group

thanks!

insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets

Hi,

It'd be great if coc-tsserver could add something like
typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets
and
javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets

Right now it's formatting from [ 't1', 't2' ] to ['t1', 't2']. I'd like to keep the spaces at the beginning and the end.

Randomly stopped understanding TSX

Hey, so yesterday I had this random problem where tsserver stopped understanding TSX. I'm starting to get errors like Operator '<' cannot be applied to type 'boolean' and 'StyledComponentClass' as errors/annotations.

I hadn't changed any configurations or updated or anything when this started happening, but I updated coc, coc-tsserver, and neovim since then and there's been no resolution.

I suspect this is an error on my end, but I don't really know where to check. My Create React App instance has no problem parsing these files. My init.vim has only one line mentioning coc: Plug 'neoclide/coc.nvim', { 'tag': '*', 'do': './install.sh' } and the only line about tsx is to call Prettier.

Do you have any recommended debugging steps? It seems like the typescript server calls are not including the fact that it's tsx for some reason.

Could not install with vim-plug

It has worked so far, but this morning I ran PlugUpdate and coc-tsserver stopped working. None of the exposed commands were available either. I tried removing it, PlugClean, adding it again, and nothing worked. Only after installing with CocInstall did it start working again.

What kind of logs could I provide to make it easier to debug this situation?

Specifying location of tsconfig.json

My current setup uses .tsconfig.json instead of tsconfig.json. Is it possible to inform coc-tsserver of this somehow? As soon as I rename my tsconfig file from .tsconfig.json to tsconfig.json it works great.

Can not find tsserver error on 1.3.8

It appears that the 1.3.8 release has broken coc-tsserver for me:
The output of :CocInfo on 1.3.8:

## versions

vim version: NVIM v0.3.5
node version: v12.2.0
coc.nvim version: 0.0.71-4ee27ce232
term: screen-256color
platform: linux

## Messages
[coc.nvim] Bundled typescript module not found
[coc.nvim] Can not find tsserver, run ':CocInstall coc-tsserver' to fix it!

This happens when I open a JS file using nvim test.js
I have tried to do :CocInstall coc-tsserver to no avail.
Using vim-plug also does not solve the problem:

Plug 'neoclide/coc-tsserver', {'tag': '1.3.8', 'do': 'yarn install --frozen-lockfile'} 

On downgrade to 1.3.7 using vim-plug the error does not appear and the extension works flawlessly:

Plug 'neoclide/coc-tsserver', {'tag': '1.3.7', 'do': 'yarn install --frozen-lockfile'} 

[Feature Request] auto import (and completions) from @types

First of all, thank you for your amazing work on coc and coc-tsserver! It works great and I like it a lot!

(All what I will say below relates only to .ts and .tsx files)

It works just like VSCode completion, expect in VSCode you also have completion for interfaces from @types.

Here's the steps you can do to get interfaces module completion in VSCode:

  1. Install typings/interfaces for the modules you need: yarn add --dev @types/react-redux.
  2. Type DispatchPr| and confirm that it suggest completion and import of DispatchProps.

Here's the screenshot in VSCode:
Root.tsx — mobile 2018-11-26 12-06-14.png

Is there a way to enable this feature for coc-tsserver? Thank you!

document how to use watchBuild

It would be nice to show an example of how to use watchBuild, and what the expected behavior would be.

Currently, I have it set up like so:

" build and populate errors on change
autocmd User CocNvimInit call CocAction('runCommand', 'tsserver.watchBuild')

It seems to clear my quickfix list on file save, but I do not see project errors in the quickfix list or in :CocList diagnostics.

Dupplicate '@' character when picking completion

Result from CocInfo
Run :CocInfo command and paste the content below.

## versions

vim version: NVIM v0.3.2-dev
node version: v11.2.0
coc.nvim version: 0.0.35
term: screen-256color
platform: darwin

## Error messages

## Output channel: tsserver
[Info  - 6:15:44 AM] Forking TSServer
PATH: /usr/local/bin:/Users/sand/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sand/Works/Go/bin:/Users/sand/Library/Android/sdk/tools:/Users/sand/Library/Android/sdk/tools/bin:/Users/sand/Library/Android/sdk/platform-tools:/Users/sand/Library/Android/sdk/emulator:/Users/sand/.yarn/bin:/Users/sand/Works/Flutter/flutter/bin:/Users/sand/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/Users/sand/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/Users/sand/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/Users/sand/.antigen/bundles/zsh-users/zsh-completions:/Users/sand/.antigen/bundles/zsh-users/zsh-history-substring-search:/Users/sand/.antigen/bundles/zsh-users/zsh-autosuggestions:/Users/sand/.antigen/bundles/lukechilds/zsh-nvm:/Users/sand/.pub-cache/bin:/Users/sand/.fzf/bin:/Users/sand/.yarn/bin:/Users/sand/.pub-cache/bin 
[Info  - 6:15:44 AM] Started TSServer
{
  "path": "/Users/sand/Downloads/verifone-challenge/node_modules/typescript/lib",
  "_api": {
    "versionString": "3.1.6",
    "version": "3.1.6"
  }
}

## Output channel: tslint
[Info  - 6:15:45 AM] TSLint library loaded from: /Users/sand/Downloads/verifone-challenge/node_modules/tslint/lib/index.js
Warning: The 'deprecation' rule requires type information.
Warning: The 'no-use-before-declare' rule requires type information.

Describe the bug
A clear and concise description of what the bug is.
When pick a complete candidate start with @, coc duplicate the @ character.

Note: I'm using <tab> to accept the complete candidate, <up>, <down> to cycle in menu.

To Reproduce
Steps to reproduce the behavior:

Complete something beginning with @

Screenshots
If applicable, add screenshots to help explain your problem.
nov-29-2018 06-19-25

how to specify workspace tsc

I can't seem to figure out how to tell coc-tsserver to use the local typescript install instead of the global one.

How would I go about that?

No Action Available when executing 'doQuickfix'

The file in question is a javascript file but the filetype is set to javascript.jsx. The diagnostics do appear in the command line but when I run CocActionAsyn('doQuickfix') via <Plug>(coc-fix-current) I get *No action available in the commandline. The dianostic in question are identation errors which I can fix using ALE but I was under the impression that I could use code actions to fix it like I would in VSCode. Below are the logs that I retrieved from both tsserver and the LSP

LSP log (abbreviated for brevity)

[Trace  - 8:16:59 PM] Response received: getSupportedCodeFixes (14). Request took 4 ms. Success: true 
Result: [
    "2352",
    "1329",
    "7051",
    "80004",
    "7034",
    ....
]

Tsserver (abbreviated for brevity)

Perf 486  [20:44:15.655] 14::getSupportedCodeFixes: elapsed time (in milliseconds) 0.2613
Info 487  [20:44:15.655] response:
    {"seq":0,"type":"response","command":"getSupportedCodeFixes","request_seq":14,"success":true,"body":["2352","1329","7051","80004","7034","7005","7006","7019","7033","7010","7032","7008","7046","7043","7044","7047","7048","7050","7049","7045","80002","80006","80001","...}

Perhaps the listed actions above do no fix indentations?

Question: How to ignore node_modules in workspaceSymbols

When using CocList -I -N workspaceSymbols, files from node_modules are also included in the results:

image

Is it possible to only search for symbols in "my" code (ignoring libraries)? With a larger project with many dependancies it can be very slow to search for symbols (it even times out after 5 seconds).

Here is my very minimal config, maybe I'm missing some config option:

call plug#begin('~/.vim/plugged')

Plug 'leafgarland/typescript-vim'
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}

call plug#end()

nnoremap <silent> <space>s  :<C-u>CocList -I -N symbols<cr>

typescript.tsx filetype does not format on save

Problem: .tsx files have the correct typescript.tsx filetype, but do not format on save. Changing the extension to .ts or forcing the filetype with an autocmd fixes the issue, but unfortunately this causes the language server to treat JSX as typescript, which of course results in multiple errors.

It's probably worth noting that invoking Prettier directly works fine on the same file (:CocCommand prettier.formatFile).

Versions: coc.nvim 0.0.69, coc-tsserver 1.3.0, coc-prettier 1.1.1, vim-polyglot (latest), Neovim 0.3.7

Related: #36 , sheerun/vim-polyglot#409

My coc-settings.json:

{
  "diagnostic.errorSign": "✖",
  "diagnostic.warningSign": "⚑",
  "diagnostic.infoSign": "⚑",
  "diagnostic.hintSign": "⚑",
  "coc.preferences.formatOnSaveFiletypes": [
    "css",
    "html",
    "javascript",
    "javascript.jsx",
    "json",
    "typescript",
    "typescript.tsx"
  ],
  "tsserver.formatOnType": false
}

I can produce a minimal init.vim if required (I did try with just yats.vim and coc.nvim installed, and the problem reproduced.)

If you can point me to the relevant section of the source, I'd be happy to contribute a PR, just not very familiar with the project.

nvim outputs 'Plug<CocRefresh>' randomly and unpredictably

Example: Just wanted to type check and got che<Plug>CocRefreshck.

This happens quite often when you type normally but it is hard to reproduce. But I found a way: If you smash the buttons fgh like fghfghfghfghffhgfhgf you get hgjhgjhgggjhgjh<Plug>CocRefresh< Plug>CocRefresh<Plug>CocRefreshg<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshjh<Plug>CocRefreshg<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshjh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRe freshg<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshjh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshgh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug> CocRefreshjh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshg<Plug>CocRefres

The tsserver log shows:
Info 251 [18:39:58.668] request: {"seq":25,"type":"request","command":"updateOpen","arguments":{"changedFiles":[{"fileName":"/MYJSFILE.js","textChanges":[{"newText":"hgjhgjhgggjhgjh<Plug>CocRefresh< Plug>CocRefresh<Plug>CocRefreshg<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshjh<Plug>CocRefreshg<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshjh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRe freshg<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshjh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshgh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug> CocRefreshjh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefresh<Plug>CocRefreshg<Plug>CocRefres","start":{"line":1,"offset":38},"end":{"line":1,"offset":38}}]}]}} Info 252 [18:39:58.669] Project '/dev/null/inferredProject1*' (Inferred) 0 Info 252 [18:39:58.672] >Files (1473)

I had some extensions installed but deinstalled all and tested them isolated and without any extension this bug doesn't come but once I installed coc-tsserver it appears.

I have latest node v12.6.0 and the latest nvim nightly v0.4.0-1326-g34c6e5bea

Allow disabling and enabling featurs per-buffer, on the fly

As discussed in neoclide/coc.nvim#361, It'd be useful to be able to set tsserver options per buffer, specifically tsserver.enableJavascript.

When working in repositories with mixed flow and untyped javascript files, I'd like the typescript extension to check untyped javascript files, but enabling tsserver.enableJavascript breaks flow file, since type annotations are only allowed in ts files.

A b:coc_tsserver_disable buffer variable would be great

Trouble installing plugin after 1.3.15 release

After the latest release, I'm having issues installing the plugin. Aparently, since the removal of webpack from the dependencies, the build command isn't run to completion, at least when installing the plugin through vim-plug.

Trying to run yarn install --frozen-lockfile directly on the plugin's folder leads to a loop, where after package installation the prepare hook tries to run npx webpack, which in turn prompts to install webpack-cli, kicking the loop again:

$ yarn install --frozen-lockfile                                                                                                                    
yarn install v1.17.3
[1/5] Validating package.json...
warning [email protected]: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
$ npx npm-run-all clean build
[#####################################################################] 221/221[.....
npx: installed 58 in 6.573s
yarn run v1.17.3
warning [email protected]: The engine "coc" appears to be invalid.
$ rimraf lib
Done in 0.11s.
yarn run v1.17.3
warning [email protected]: The engine "coc" appears to be invalid.
$ npx webpack
npx: installed 322 in 14.204s
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
 - webpack-cli (https://github.com/webpack/webpack-cli)
   The original webpack full-featured CLI.
We will use "yarn" to install the CLI via "yarn add -D".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'yarn add -D webpack-cli')...
[1/5] Validating package.json...
warning [email protected]: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "[email protected]".
[5/5] Building fresh packages...
[...snip...]
$ npx npm-run-all clean build
warning [email protected]: The engine "coc" appears to be invalid.
$ rimraf lib
warning [email protected]: The engine "coc" appears to be invalid.
$ npx webpack
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
 - webpack-cli (https://github.com/webpack/webpack-cli)
   The original webpack full-featured CLI.
We will use "yarn" to install the CLI via "yarn add -D".
Do you want to install 'webpack-cli' (yes/no): 

So far the only workaround I've found was rolling back the webpack dependencies removal change.

Import modules

When I type implements OnInit autocompletion works - it's great, but nothing appears on top of the imports.

tsconfig and tsc not found

First and foremost, thank you for all the work put into this coc - it's awesome. 🙏

I updated all my coc.nvim plugins today on all my systems and noted that I started getting [coc.nvim] Local & global tsc not found and [coc.nvim] tsconfig.json not found when starting coc-tsserver. I didn't have this issue on 1.1.33.

coc-tsserver seems to run fine with the errors. So, are these errors intended?

My :CocInfo is:

## versions

vim version: NVIM v0.4.0-582-g3b7a4f233
node version: v10.15.3
coc.nvim version: 0.0.65
term: xterm-256color
platform: linux

## Error messages

## Output channel: snippets

## Output channel: tsserver
[Info  - 11:52:05 AM] Forking TSServer
PATH: /usr/local/sbin:/usr/local/bin:/usr/bin:/home/sqve/.local/bin:/home/sqve/.nvm/versions/node/v10.15.3/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/sqve/.local/bin:/home/sqve/.nvm/versions/node/v10.15.3/bin:/home/sqve/.local/bin:/home/sqve/.nvm/versions/node/v10.15.3/bin
[Info  - 11:52:05 AM] Started TSServer
{
  "path": "/home/sqve/.config/coc/extensions/node_modules/typescript/lib",
  "_pathLabel": "",
  "_api": {
    "versionString": "3.3.4000",
    "version": "3.3.4000"
  }
}

Conflict with flow lsp

I Work on different js codebases written vanilla js, flow js and some times typescript.
what is the preferred way to manage conflict between flow lsp and coc-tsserver maybe.
maybe disable coc-tsserver when there is .flowconfig available in workspace root?

Reporting of false errors in tsx files for html elements

I've been stuck on this for quite some time and am now asking for help. I'm not sure if this is a bug.
I'm trying to switch to coc-nvim for completions, but for typescript tsx files, I keep getting complaints for the various html tags...
[tsserver 2304] [E] Cannot find name 'div'.
[tsserver 2304] [E] Cannot find name 'header'.
etc etc

Here's a minimal reproduction:
(Based on instructions in https://facebook.github.io/create-react-app/docs/adding-typescript)
$ npx create-react-app@next painful_ts
$ cd painful_ts
$ npm install --save typescript @types/node @types/react @types/react-dom @types/jest
$ mv src/App.js src/App.tsx
$ mv src/index.js src/index.tsx
$ npm start
$ nvim src/App.tsx
--> Bajillion error markers about tsserver not being able to understand html tags

If I do 'go to definition' on the import React... line, it takes me to the relevant React definitions file. I also see definitions for div etc in that file under interface ReactHTML {.... But go to definition does not work on the div or img or any other html tags.

So what is going on?

Interestingly, if I go to an old existing react TS project, and i open one of the tsx files, things seem to work okay. 'Go to definition' for the html tags take me to the right definitions file. The tsc version was 2.6.2 in an old project. I updated it to latest 3.2.2, then the errors appeared again on opening files. I downgraded typescript to 2.6.2 again, but I STILL saw the errors there.

Pretty confused. Help would be appreciated.
Thanks.

tsserver-javascript timeout

When editing with *.js files, vim becomes pretty slow, and it warns source tsserver-javascript timeout after 2000ms, but when editing *.ts files, everything seems ok.

completion not work

image

nvim version: 0.3.8
typescript version: 3.5.3

tsserver log:

[Trace  - 13:58:58] Event received: semanticDiag (0).
Data: {
    "file": "/Users/tankaiwen/Project/person/uform/build.ts",
    "diagnostics": [
        {
            "start": {
                "line": 3,
                "offset": 10
            },
            "end": {
                "line": 3,
                "offset": 25
            },
            "text": "'printDiagnostic' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        },
        {
            "start": {
                "line": 5,
                "offset": 9
            },
            "end": {
                "line": 5,
                "offset": 13
            },
            "text": "'host' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        }
    ]
}
[Trace  - 13:58:58] Event received: suggestionDiag (0).
Data: {
    "file": "/Users/tankaiwen/Project/person/uform/build.ts",
    "diagnostics": [
        {
            "start": {
                "line": 4,
                "offset": 27
            },
            "end": {
                "line": 4,
                "offset": 37
            },
            "text": "'configPath' is declared but its value is never read.",
            "code": 6133,
            "category": "suggestion",
            "reportsUnnecessary": true
        }
    ]
}
[Trace  - 13:58:58] Async response received: requestCompleted (4). Request took 2573 ms.
[Trace  - 13:58:59] Sending request: geterr (5). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/tankaiwen/Project/person/uform/build.ts"
    ]
}
[Trace  - 13:58:59] Event received: syntaxDiag (0).
Data: {
    "file": "/Users/tankaiwen/Project/person/uform/build.ts",
    "diagnostics": [
        {
            "start": {
                "line": 7,
                "offset": 1
            },
            "end": {
                "line": 7,
                "offset": 2
            },
            "text": "Identifier expected.",
            "code": 1003,
            "category": "error"
        }
    ]
}
[Trace  - 13:58:59] Event received: semanticDiag (0).
Data: {
    "file": "/Users/tankaiwen/Project/person/uform/build.ts",
    "diagnostics": [
        {
            "start": {
                "line": 3,
                "offset": 10
            },
            "end": {
                "line": 3,
                "offset": 25
            },
            "text": "'printDiagnostic' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        },
        {
            "start": {
                "line": 5,
                "offset": 9
            },
            "end": {
                "line": 5,
                "offset": 13
            },
            "text": "'host' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        }
    ]
}
[Trace  - 13:58:59] Event received: suggestionDiag (0).
Data: {
    "file": "/Users/tankaiwen/Project/person/uform/build.ts",
    "diagnostics": [
        {
            "start": {
                "line": 4,
                "offset": 27
            },
            "end": {
                "line": 4,
                "offset": 37
            },
            "text": "'configPath' is declared but its value is never read.",
            "code": 6133,
            "category": "suggestion",
            "reportsUnnecessary": true
        }
    ]
}
[Trace  - 13:58:59] Async response received: requestCompleted (5). Request took 5 ms.
[Trace  - 13:59:00] Sending request: updateOpen (6). Response expected: no. Current queue length: 0
Arguments: {
    "changedFiles": [
        {
            "fileName": "/Users/tankaiwen/Project/person/uform/build.ts",
            "textChanges": [
                {
                    "newText": "",
                    "start": {
                        "line": 6,
                        "offset": 5
                    },
                    "end": {
                        "line": 6,
                        "offset": 6
                    }
                }
            ]
        },
        {
            "fileName": "/Users/tankaiwen/Project/person/uform/build.ts",
            "textChanges": [
                {
                    "newText": ".",
                    "start": {
                        "line": 6,
                        "offset": 5
                    },
                    "end": {
                        "line": 6,
                        "offset": 5
                    }
                }
            ]
        }
    ]
}
[Trace  - 13:59:00] Sending request: completionInfo (7). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/tankaiwen/Project/person/uform/build.ts",
    "line": 6,
    "offset": 6,
    "includeExternalModuleExports": true,
    "includeInsertTextCompletions": true,
    "triggerCharacter": "."
}
[Trace  - 13:59:00] Response received: completionInfo (7). Request took 59 ms. Success: true 
Result: {
    "isGlobalCompletion": false,
    "isMemberCompletion": true,
    "isNewIdentifierLocation": false,
    "entries": [
        {
            "name": "addEmitHelper",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "addEmitHelpers",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "addSyntheticLeadingComment",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "addSyntheticTrailingComment",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "classicNameResolver",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "ClassificationType",
            "kind": "enum",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "ClassificationTypeNames",
            "kind": "enum",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "collapseTextChangeRangesAcrossMultipleVersions",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "convertCompilerOptionsFromJson",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "convertToObject",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "convertTypeAcquisitionFromJson",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },
        {
            "name": "couldStartTrivia",
            "kind": "function",
            "kindModifiers": "declare",
            "sortText": "0"
        },

It seems tsserver send completionInfo successfully, but the it isn't display on the screen in the end.

my coc-settings:

{
  "coc.preferences.formatOnSaveFiletypes": ["css", "typescript", "typescript.jsx", "typescript.tsx","Markdown", "javascript", "javascript.jsx"],
  "eslint.filetypes": [
    "javascript",
    "javascript.jsx"
  ],

  "prettier.requireConfig": true,
  "coc.preferences.formatOnType": true,
  "eslint.autoFixOnSave": true,
  "coc.preferences.jumpCommand": "tabe",
  "coc.preferences.colorSupport": true,
  "coc.preferences.enableFloatHighlight": true,
  "tsserver.enableJavascript": true,
  "tsserver.npm": "/Users/tankaiwen/.nvm/versions/node/v8.11.3/bin/node",
  "tsserver.log": "verbose",
  "snippets.extends": {
    "javascriptreact": ["javascript"],
    "typescript": ["javascript"],
    "typescriptreact": ["javascript"]
  },
  "suggest.noselect": false,
  "typescript.suggestionActions.enabled": true
}

New features

This module keeps update with typescript-language-features extension of VSCode.

How do I...

Sorry if this has been asked before.

I'm trying to simulate the vscode experience in nvim and there are fundamentally two features I miss:

  • Smarter autocompletion: the sorting of my current autocomplete suggestions is alphabetical. The one in vscode is by recent use. Is it possible to enable this?
  • Populate symbols: when I currently go into :CocList > symbols, it is empty. This extension claims to offer the possibility to find symbols at least in the buffer. Vscode's Go To Symbol is very powerful, can I emulate this?

Thanks.

Best way to handle JSX / TSX

Hey 👋,

vim-polyglot recently changed their jsx and tsx provider, sheerun/vim-polyglot@26c678b, and it's creating issues with coc-tsserver due to it using the filetype javascript and typescript for both regular files and files which include jsx and tsx syntax. This is going to be an issue due to the popularity of vim-polyglot.

Is there a way to configure coc-tsserver to default to jsx or tsx? If no, what would be the best way to handle these issues? Are a autocmd looking on file extension the best way?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.