typescript-language-server / typescript-language-server

TypeScript & JavaScript Language Server

Home Page:https://www.npmjs.com/package/typescript-language-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TSServer >=4.1.0 never publishes textDocument/publishDiagnostics event (NeoVim)

cdimitroulas opened this issue · comments

Hello there,

I have encountered an issue with the most recent versions of tsserver (4.1.0, 4.1.1 and 4.1.2) where diagnostics are not being published and thus do not appear in my editor.

I have tried switching to various other versions of tsserver and 4.0.0 and 3.3.2 both work as expected.

It seems that on these later versions the textDocument/publishDiagnostics event is never sent from the LSP server and thus the editor has no diagnostics to show. There are no obvious errors in the log to explain why this is happening. If I stop the LSP server, it does actually publish a textDocument/publishDiagnostics event with an empty diagnostics list. Here are some logs from one example I tested on version 4.1.2:

[INFO][2023-11-16 19:05:24] .../vim/lsp/rpc.lua:662	"Starting RPC client"	{  args = { "--stdio" },  cmd = "/Users/cdimitroulas/.local/share/nvim/mason/bin/tailwindcss-language-server",  extra = {    cwd = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground"  }}
[DEBUG][2023-11-16 19:05:24] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      textDocument = {        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          insertTextMode = 1        }      },      workspace = {        configuration = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.4"    },    initializationOptions = {      userLanguages = {        eelixir = "html-eex",        eruby = "erb"      }    },    processId = 3747,    rootPath = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground",    rootUri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground",    trace = "off",    workspaceFolders = { {        name = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground",        uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground"      } }  }}
[INFO][2023-11-16 19:05:24] .../vim/lsp/rpc.lua:662	"Starting RPC client"	{  args = { "--stdio" },  cmd = "/Users/cdimitroulas/.local/share/nvim/mason/bin/typescript-language-server",  extra = {    cwd = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground"  }}
[DEBUG][2023-11-16 19:05:24] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      textDocument = {        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          insertTextMode = 1        }      },      workspace = {        configuration = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.4"    },    initializationOptions = {      hostInfo = "neovim",      plugins = { {          location = "/Users/cdimitroulas/.asdf/installs/nodejs/16.15.1/.npm/lib/node_modules/typescript-tshm-plugin",          name = "typescript-tshm-plugin"        } }    },    processId = 3747,    rootPath = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground",    rootUri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground",    trace = "off",    workspaceFolders = { {        name = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground",        uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground"      } }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      codeActionProvider = true,      colorProvider = true,      completionProvider = {        resolveProvider = true,        triggerCharacters = { '"', "'", "`", " ", ".", "(", "[", "!", "/", ":" }      },      documentLinkProvider = vim.empty_dict(),      hoverProvider = true,      textDocumentSync = 1    }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "initialized",  params = vim.empty_dict()}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "workspace/didChangeConfiguration",  params = {    settings = {      editor = {        tabSize = 2      },      tailwindCSS = {        classAttributes = { "class", "className", "class:list", "classList", "ngClass" },        lint = {          cssConflict = "warning",          invalidApply = "error",          invalidConfigPath = "error",          invalidScreen = "error",          invalidTailwindDirective = "error",          invalidVariant = "error",          recommendedVariantOrder = "warning"        },        validate = true      }    }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "workspace/didChangeConfiguration",  params = {    settings = {      editor = {        tabSize = 2      },      tailwindCSS = {        classAttributes = { "class", "className", "class:list", "classList", "ngClass" },        lint = {          cssConflict = "warning",          invalidApply = "error",          invalidConfigPath = "error",          invalidScreen = "error",          invalidTailwindDirective = "error",          invalidVariant = "error",          recommendedVariantOrder = "warning"        },        validate = true      }    }  }}
[INFO][2023-11-16 19:05:25] .../lua/vim/lsp.lua:1344	"LSP[tailwindcss]"	"server_capabilities"	{  server_capabilities = {    codeActionProvider = true,    colorProvider = true,    completionProvider = {      resolveProvider = true,      triggerCharacters = { '"', "'", "`", " ", ".", "(", "[", "!", "/", ":" }    },    documentLinkProvider = vim.empty_dict(),    hoverProvider = true,    textDocumentSync = {      change = 1,      openClose = true,      save = {        includeText = false      },      willSave = false,      willSaveWaitUntil = false    }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "typescript",      text = 'import { Effect, Console } from "effect"\n\nconst increment = (x: number) => x + 1\n \nconst divide = (a: number, b: number): Effect.Effect<never, Error, number> =>\n  b === 0\n    ? Effect.fail(new Error("Cannot divide by zero"))\n    : Effect.succeed(a / b)\n \nconst task1 = Effect.promise(() => Promise.resolve(10))\nconst task2 = Effect.promise(() => Promise.resolve(2))\n \nexport const program: Effect.Effect<never, never, number> = Effect.gen(function* (_) {\n  const a = yield* _(task1)\n  const b = yield* _(task2)\n  const n1 = yield* _(divide(a, b))\n  const n2 = increment(n1)\n  return `Result is: ${n2}`\n})\n\nconst x: string = 1\n',      uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground/src/effect-ts.ts",      version = 0    }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 0,  jsonrpc = "2.0",  method = "workspace/configuration",  params = {    items = { {        section = "editor"      } }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:403	"server_request: callback result"	{  result = { {      tabSize = 2    } },  status = true}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 0,  jsonrpc = "2.0",  result = { {      tabSize = 2    } }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  method = "workspace/configuration",  params = {    items = { {        section = "tailwindCSS"      } }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:403	"server_request: callback result"	{  result = { {      classAttributes = { "class", "className", "class:list", "classList", "ngClass" },      lint = {        cssConflict = "warning",        invalidApply = "error",        invalidConfigPath = "error",        invalidScreen = "error",        invalidTailwindDirective = "error",        invalidVariant = "error",        recommendedVariantOrder = "warning"      },      validate = true    } },  status = true}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 1,  jsonrpc = "2.0",  result = { {      classAttributes = { "class", "className", "class:list", "classList", "ngClass" },      lint = {        cssConflict = "warning",        invalidApply = "error",        invalidConfigPath = "error",        invalidScreen = "error",        invalidTailwindDirective = "error",        invalidVariant = "error",        recommendedVariantOrder = "warning"      },      validate = true    } }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "window/logMessage",  params = {    message = "[Global] Creating projects: []",    type = 4  }}
[INFO][2023-11-16 19:05:25] ...lsp/handlers.lua:539	"[Global] Creating projects: []"
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "window/logMessage",  params = {    message = 'Using Typescript version (workspace) 5.2.2 from path "/Users/cdimitroulas/code/cdimitroulas/typescript-playground/node_modules/typescript/lib/tsserver.js"',    type = 3  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      codeActionProvider = true,      codeLensProvider = {        resolveProvider = true      },      completionProvider = {        resolveProvider = true,        triggerCharacters = { ".", '"', "'", "/", "@", "<" }      },      definitionProvider = true,      documentFormattingProvider = true,      documentHighlightProvider = true,      documentRangeFormattingProvider = true,      documentSymbolProvider = true,      executeCommandProvider = {        commands = { "_typescript.applyWorkspaceEdit", "_typescript.applyCodeAction", "_typescript.applyRefactoring", "_typescript.configurePlugin", "_typescript.organizeImports", "_typescript.applyRenameFile", "_typescript.goToSourceDefinition" }      },      foldingRangeProvider = true,      hoverProvider = true,      implementationProvider = true,      inlayHintProvider = true,      linkedEditingRangeProvider = false,      referencesProvider = true,      renameProvider = true,      selectionRangeProvider = true,      semanticTokensProvider = {        full = true,        legend = {          tokenModifiers = { "declaration", "static", "async", "readonly", "defaultLibrary", "local" },          tokenTypes = { "class", "enum", "interface", "namespace", "typeParameter", "type", "parameter", "variable", "enumMember", "property", "function", "member" }        },        range = true      },      signatureHelpProvider = {        retriggerCharacters = { ")" },        triggerCharacters = { "(", ",", "<" }      },      textDocumentSync = 2,      typeDefinitionProvider = true,      workspace = {        fileOperations = {          willRename = {            filters = { {                pattern = {                  glob = "**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}",                  matches = "file"                },                scheme = "file"              } }          }        }      },      workspaceSymbolProvider = true    }  }}
[INFO][2023-11-16 19:05:25] ...lsp/handlers.lua:539	'Using Typescript version (workspace) 5.2.2 from path "/Users/cdimitroulas/code/cdimitroulas/typescript-playground/node_modules/typescript/lib/tsserver.js"'
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "initialized",  params = vim.empty_dict()}
[INFO][2023-11-16 19:05:25] .../lua/vim/lsp.lua:1344	"LSP[tsserver]"	"server_capabilities"	{  server_capabilities = {    codeActionProvider = true,    codeLensProvider = {      resolveProvider = true    },    completionProvider = {      resolveProvider = true,      triggerCharacters = { ".", '"', "'", "/", "@", "<" }    },    definitionProvider = true,    documentFormattingProvider = true,    documentHighlightProvider = true,    documentRangeFormattingProvider = true,    documentSymbolProvider = true,    executeCommandProvider = {      commands = { "_typescript.applyWorkspaceEdit", "_typescript.applyCodeAction", "_typescript.applyRefactoring", "_typescript.configurePlugin", "_typescript.organizeImports", "_typescript.applyRenameFile", "_typescript.goToSourceDefinition" }    },    foldingRangeProvider = true,    hoverProvider = true,    implementationProvider = true,    inlayHintProvider = true,    linkedEditingRangeProvider = false,    referencesProvider = true,    renameProvider = true,    selectionRangeProvider = true,    semanticTokensProvider = {      full = true,      legend = {        tokenModifiers = { "declaration", "static", "async", "readonly", "defaultLibrary", "local" },        tokenTypes = { "class", "enum", "interface", "namespace", "typeParameter", "type", "parameter", "variable", "enumMember", "property", "function", "member" }      },      range = true    },    signatureHelpProvider = {      retriggerCharacters = { ")" },      triggerCharacters = { "(", ",", "<" }    },    textDocumentSync = {      change = 2,      openClose = true,      save = {        includeText = false      },      willSave = false,      willSaveWaitUntil = false    },    typeDefinitionProvider = true,    workspace = {      fileOperations = {        willRename = {          filters = { {              pattern = {                glob = "**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}",                matches = "file"              },              scheme = "file"            } }        }      }    },    workspaceSymbolProvider = true  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "typescript",      text = 'import { Effect, Console } from "effect"\n\nconst increment = (x: number) => x + 1\n \nconst divide = (a: number, b: number): Effect.Effect<never, Error, number> =>\n  b === 0\n    ? Effect.fail(new Error("Cannot divide by zero"))\n    : Effect.succeed(a / b)\n \nconst task1 = Effect.promise(() => Promise.resolve(10))\nconst task2 = Effect.promise(() => Promise.resolve(2))\n \nexport const program: Effect.Effect<never, never, number> = Effect.gen(function* (_) {\n  const a = yield* _(task1)\n  const b = yield* _(task2)\n  const n1 = yield* _(divide(a, b))\n  const n2 = increment(n1)\n  return `Result is: ${n2}`\n})\n\nconst x: string = 1\n',      uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground/src/effect-ts.ts",      version = 0    }  }}
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/typescriptVersion",  params = {    source = "workspace",    version = "5.2.2"  }}
[DEBUG][2023-11-16 19:05:25] .../lua/vim/lsp.lua:1391	"LSP[tsserver]"	"client.request"	4	"textDocument/semanticTokens/full"	{  textDocument = {    uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground/src/effect-ts.ts"  }}	<function 1>	1
[DEBUG][2023-11-16 19:05:25] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 2,  jsonrpc = "2.0",  method = "textDocument/semanticTokens/full",  params = {    textDocument = {      uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground/src/effect-ts.ts"    }  }}
[DEBUG][2023-11-16 19:05:26] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 2,  jsonrpc = "2.0",  result = {    data = { 2, 6, 9, 10, 9, 0, 13, 1, 6, 1, 0, 14, 1, 6, 0, 2, 6, 6, 10, 9, 0, 10, 1, 6, 1, 0, 11, 1, 6, 1, 0, 19, 6, 2, 0, 0, 14, 5, 2, 16, 1, 2, 1, 6, 0, 1, 13, 4, 10, 8, 0, 9, 5, 0, 16, 1, 13, 7, 10, 8, 0, 8, 1, 6, 0, 0, 4, 1, 6, 0, 2, 6, 5, 7, 9, 0, 15, 7, 10, 8, 0, 14, 7, 0, 16, 0, 8, 7, 11, 16, 1, 6, 5, 7, 9, 0, 15, 7, 10, 8, 0, 14, 7, 0, 16, 0, 8, 7, 11, 16, 2, 13, 7, 7, 9, 0, 16, 6, 2, 0, 0, 38, 3, 10, 8, 0, 15, 1, 10, 1, 1, 8, 1, 7, 41, 0, 11, 1, 10, 0, 0, 2, 5, 7, 8, 1, 8, 1, 7, 41, 0, 11, 1, 10, 0, 0, 2, 5, 7, 8, 1, 8, 2, 7, 41, 0, 12, 1, 10, 0, 0, 2, 6, 10, 8, 0, 7, 1, 7, 40, 0, 3, 1, 7, 40, 1, 8, 2, 7, 41, 0, 5, 9, 10, 8, 0, 10, 2, 7, 40, 1, 23, 2, 7, 40, 3, 6, 1, 7, 9 }  }}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 3,  jsonrpc = "2.0",  method = "shutdown"}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 2,  jsonrpc = "2.0",  method = "shutdown"}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 3,  jsonrpc = "2.0"}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "@/tailwindCSS/projectsDestroyed",  params = { vim.NIL }}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = {},    uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground/src/effect-ts.ts"  }}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 2,  jsonrpc = "2.0"}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "exit"}
[DEBUG][2023-11-16 19:05:50] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "exit"}

Any ideas why this might be happening? I made sure to try this with the latest version of Typescript and Node v20.

Your client sends very limited capabilities which don't include the textDocument.publishDiagnostics capability:

{
    id = 1, jsonrpc = "2.0", method = "initialize", params = {
        capabilities = {
            textDocument = {
                completion = {
                    completionItem = {
                        commitCharactersSupport = true,
                        deprecatedSupport = true,
                        insertReplaceSupport = true,
                        insertTextModeSupport = {
                            valueSet = {
                                1,
                                2
                            }
                        },
                        labelDetailsSupport = true,
                        preselectSupport = true,
                        resolveSupport = {
                            properties = {
                                "documentation",
                                "detail",
                                "additionalTextEdits",
                                "sortText",
                                "filterText",
                                "insertText",
                                "textEdit",
                                "insertTextFormat",
                                "insertTextMode"
                            }
                        },
                        snippetSupport = true,
                        tagSupport = {
                            valueSet = {
                                1
                            }
                        }
                    },
                    completionList = {
                        itemDefaults = {
                            "commitCharacters",
                            "editRange",
                            "insertTextFormat",
                            "insertTextMode",
                            "data"
                        }
                    },
                    contextSupport = true,
                    dynamicRegistration = false,
                    insertTextMode = 1
                }
            },
            workspace = {
                configuration = true
            }
        },
        clientInfo = {
            name = "Neovim",
            version = "0.9.4"
        },
        initializationOptions = {
            hostInfo = "neovim",
            plugins = {
                {
                    location = "/Users/cdimitroulas/.asdf/installs/nodejs/16.15.1/.npm/lib/node_modules/typescript-tshm-plugin", name = "typescript-tshm-plugin"
                }
            }
        },
        processId = 3747,
        rootPath = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground",
        rootUri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground",
        trace = "off",
        workspaceFolders = {
            {
                name = "/Users/cdimitroulas/code/cdimitroulas/typescript-playground", uri = "file:///Users/cdimitroulas/code/cdimitroulas/typescript-playground"
            }
        }
    }
}

It should announce all features it supports.