Closed onsi closed 2 years ago
AndI just noticed there's a troubleshoot server command. Here's the output:
# Troubleshooting: LSP-typescript
## Version
- LSP: 1.16.1
- Sublime Text: 4126
## Server Test Run
- exit code: 0
- output
## Server Configuration
- command
```json
[
"${node_bin}",
"${server_path}",
"--stdio"
]
"/Users/onsi/Library/Caches/Sublime Text/Package Storage/lsp_utils/node-runtime/16.2.0/node/bin/node" "/Users/onsi/Library/Caches/Sublime Text/Package Storage/LSP-typescript/16.2.0/typescript-language-server/node_modules/typescript-language-server/lib/cli.js" --stdio
source.js, source.jsx, source.ts, source.tsx
source.js, source.jsx, source.ts, source.tsx
{
"logVerbosity": "off",
"maxTsServerMemory": 0,
"npmLocation": "",
"plugins": [],
"preferences": {
"allowIncompleteCompletions": true,
"allowRenameOfImportPath": true,
"allowTextChangesInNewFiles": true,
"displayPartsForJSDoc": true,
"generateReturnInDocTemplate": true,
"includeAutomaticOptionalChainCompletions": true,
"includeCompletionsForImportStatements": true,
"includeCompletionsForModuleExports": true,
"includeCompletionsWithClassMemberSnippets": true,
"includeCompletionsWithInsertText": true,
"includeCompletionsWithSnippetText": true,
"jsxAttributeCompletionStyle": "auto"
}
}
{
"diagnostics": {
"ignoredCodes": []
},
"javascript": {
"format": {
"insertSpaceAfterCommaDelimiter": true,
"insertSpaceAfterConstructor": false,
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"insertSpaceAfterKeywordsInControlFlowStatements": true,
"insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
"insertSpaceAfterSemicolonInForStatements": true,
"insertSpaceAfterTypeAssertion": false,
"insertSpaceBeforeAndAfterBinaryOperators": true,
"insertSpaceBeforeFunctionParenthesis": false,
"insertSpaceBeforeTypeAnnotation": false,
"placeOpenBraceOnNewLineForControlBlocks": false,
"placeOpenBraceOnNewLineForFunctions": false,
"semicolons": "ignore",
"trimTrailingWhitespace": true
},
"inlayHints": {
"includeInlayEnumMemberValueHints": false,
"includeInlayFunctionLikeReturnTypeHints": false,
"includeInlayFunctionParameterTypeHints": false,
"includeInlayParameterNameHints": "none",
"includeInlayParameterNameHintsWhenArgumentMatchesName": false,
"includeInlayPropertyDeclarationTypeHints": false,
"includeInlayVariableTypeHints": false
}
},
"typescript": {
"format": {
"insertSpaceAfterCommaDelimiter": true,
"insertSpaceAfterConstructor": false,
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"insertSpaceAfterKeywordsInControlFlowStatements": true,
"insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
"insertSpaceAfterSemicolonInForStatements": true,
"insertSpaceAfterTypeAssertion": false,
"insertSpaceBeforeAndAfterBinaryOperators": true,
"insertSpaceBeforeFunctionParenthesis": false,
"insertSpaceBeforeTypeAnnotation": false,
"placeOpenBraceOnNewLineForControlBlocks": false,
"placeOpenBraceOnNewLineForFunctions": false,
"semicolons": "ignore",
"trimTrailingWhitespace": true
},
"inlayHints": {
"includeInlayEnumMemberValueHints": false,
"includeInlayFunctionLikeReturnTypeHints": false,
"includeInlayFunctionParameterTypeHints": false,
"includeInlayParameterNameHints": "none",
"includeInlayParameterNameHintsWhenArgumentMatchesName": false,
"includeInlayPropertyDeclarationTypeHints": false,
"includeInlayVariableTypeHints": false
}
}
}
{
"PATH": "/Users/onsi/Library/Caches/Sublime Text/Package Storage/lsp_utils/node-runtime/16.2.0/node/bin:/Users/onsi/Library/Caches/Sublime Text/Package Storage/lsp_utils/node-runtime/16.2.0/node/bin:"
}
/Users/onsi/code/crosspurpose/muhasib/js/pages/pages.js
{
"auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
"lsp_active": true,
"syntax": "Packages/JavaScript/JavaScript.sublime-syntax"
}
source.js
[
"/Users/onsi/code/crosspurpose/muhasib"
]
{
"clients": {
"gopls": {
"command": [
"gopls"
],
"enabled": true,
"initializationOptions": {
"experimentalWorkspaceModule": false
},
"selector": "source.go"
},
"pyls": {
"command": [
"pyls"
],
"enabled": true,
"languageId": "python",
"scopes": [
"source.python"
],
"settings": {
"pyls": {
"configurationSources": [
"pycodestyle"
],
"env": {},
"plugins": {
"jedi": {
"extra_paths": []
},
"jedi_completion": {
"fuzzy": true
},
"mccabe": {
"enabled": false
},
"pycodestyle": {
"enabled": true,
"exclude": [],
"ignore": [
"E501",
"E402"
]
},
"pydocstyle": {
"enabled": false
},
"pyflakes": {
"enabled": true
},
"pylint": {
"enabled": false
},
"pyls_mypy": {
"enabled": false,
"live_mode": true
},
"yapf": {
"enabled": true
}
}
}
},
"syntaxes": [
"Packages/Python/Python.sublime-syntax"
]
}
},
"log_debug": true,
"log_server": [
"panel"
],
"lsp_code_actions_on_save": {
"source.fixAll": true,
"source.organizeImports": true
},
"lsp_format_on_save": true
}
I've known this problem. It's because Typescript returns a code action for "organize imports" even if nothing is actually gonna change. And LSP will keep applying the change as long it receives one, resulting in this loop that you are seeing.
Ideally TypeScript itself would be fixed to not return the suggestion in that case. Less ideally, there could be a work-around implemented in https://github.com/typescript-language-server/typescript-language-server.
There is an issue for it already: https://github.com/microsoft/TypeScript/issues/39823
ok thanks. so sounds like turning off organize imports should help. i'll try that.
I couldn't figure out how to turn off the organize imports code action per language, but I did disable source.organizeImports
in my .sublime-project file and things are fast again.
For future reference if someone comes across this issue my .sublime-project file looks like:
{
"folders":
[
{
"path": "."
},
],
"settings": {
"lsp_format_on_save": true,
"lsp_code_actions_on_save": {
"source.fixAll": true,
"source.organizeImports": false,
},
},
}
If anyone knows how to globally turn off organizeImports
just for typescript/javascript please share!
"source.organizeImports": true,
"source.organizeImports.ts": false,
BTW. The server also supports more specific variants of "organizeImports" that might be enough for your use case and not have this issue - https://github.com/sublimelsp/LSP-typescript#code-actions-on-save
(I guess I meant addMissingImports
)
hey there, I've been humming along on my javascript project and happily using lsp-typescript. I recently started noticing a slowdown (a few seconds, sometimes triggering lsp/ST's timeout) on document save (presumably while running the various on-save codeActions). I've tried going back to an earlier version of my project and that hasn't helped. I did restart my computer recently and that might be correlated but aside from that I can't think of any changes to my setup.
When I turn LSP's logging on I see the following repeated several times in the debug panel whenever I save:
this repeats maybe ~300 times based on the counter. On files that don't timeout (typically smaller files) I eventually get:
Any thoughts what might be causing this looping behavior? Anything I can poke at to help debug things? Any caches/whatnot I should try to clear? Any version upgrades I can try (I'm not actually sure which version of node lsp-typescript is using, I don't actually have node installed separately on my machine).
Thanks.