codota / tabnine-nvim

Tabnine Client for Neovim
https://tabnine.com
359 stars 33 forks source link

Invalid token at character 1 #145

Closed Askath closed 9 months ago

Askath commented 9 months ago

Describe the bug I just installed and tried using Tabnine Pro. After setting everything up and trying to use the chat function, I noticed that whenever a request completed and an answer got generated, Neovim throws an error like the one below.

I noticed that this error only occurs sometimes. Although I also noticed that it might have something to do with closing the chat or stopping a generation of an answer. Which could cause all future requests to throw this error.

To Reproduce Steps to reproduce the behavior:

  1. Open Neovim
  2. Open any file
  3. Open TabnineChat
  4. Highlight Text
  5. Go into the chat window
  6. Enter /explain

Expected behavior Neovim should not throw an error notification after a chat request has been processed successfully.

Version Info:

Additional context Error message:

Error executing vim.schedule lua callback: ...share/nvim/lazy/tabnine-nvim/lua/tabnine/chat/binary.lua:82: Expected value but found unexpected end of string at character 8193 stack traceback: [C]: in function 'decode' ...share/nvim/lazy/tabnine-nvim/lua/tabnine/chat/binary.lua:82: in function '' vim/_editor.lua: in function <vim/_editor.lua:0> Error executing vim.schedule lua callback: ...share/nvim/lazy/tabnine-nvim/lua/tabnine/chat/binary.lua:82: Expected value but found invalid token at character 1

amirbilu commented 9 months ago

Hi Askath, thanks for reaching out. I assume I can just guard this function for unknown values, but it would be great if you could provide exact steps / files to reproduce the issue so I can figure what's going wrong

Askath commented 9 months ago

Hi Askath, thanks for reaching out. I assume I can just guard this function for unknown values, but it would be great if you could provide exact steps / files to reproduce the issue so I can figure what's going wrong

I edited my post. All I do, is open my project in a tmux window. I open neovim and navigate to a Typescript file in my project. I enter :TabnineChat Go back to my file in vim and Highlight a function

/**
   * @param {string} id - The ID of the Fluessigkeitsbilanzierung document to load.
   * @param {FluessigkeitsbilanzierungVo} object - The Fluessigkeitsbilanzierung head to save.
   * Saves the current Fluessigkeitsbilanzierung document and its associated entries.
   */
  saveHead(id: string, object: FluessigkeitsbilanzierungVo) {
    this.service
      .putUpdateFluessigkeitsbilanzierung(id, object)
      .pipe(take(1))
      .subscribe({
        next: (result: FluessigkeitsbilanzierungViewVo) =>
          this.head.set(result),
        error: (error) =>
          console.error('Kopf konnte nicht gespeichert werden: ', error),
      });
  }

Go back into the Chat Window and enter /explain.

I also noticed that commands like :TabnineExplain don't do anything in neovim

Askath commented 9 months ago

Hi Askath, thanks for reaching out. I assume I can just guard this function for unknown values, but it would be great if you could provide exact steps / files to reproduce the issue so I can figure what's going wrong

I just found this in another log file

ERROR [similarity_search::repo_indexing::sharded_workers] [2024-01-22:11:28:37 TabNine ERROR] failed to process work FileToIndex { key: FileToIndexKey { repo_path: "/Users/taradruffel/Developer/typescript/phoenix-frontend", file_path: "/Users/taradruffel/Developer/typescript/phoenix-frontend/src/app/modules/pages/client/documents/liquid-balancing/liquid-balancing.service.ts" }, is_ignored: false }: Terminal error: status: Internal, message: "Service internal error: Not recovered from previous error: Service runtime error: RocksDB delete_cf error: IO error: While open a file for appending: ./storage/collections/tabnine_dense/0/segments/22f26d25-c29a-4ec0-afce-561248dfd77f/000471.log: Too many open files", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Mon, 22 Jan 2024 10:28:37 GMT", "content-length": "0"} }
ERROR [similarity_search::repo_indexing::sharded_workers] [2024-01-22:11:28:37 TabNine ERROR] not trying again FileToIndex { key: FileToIndexKey { repo_path: "/Users/taradruffel/Developer/typescript/phoenix-frontend", file_path: "/Users/taradruffel/Developer/typescript/phoenix-frontend/src/app/modules/pages/client/documents/liquid-balancing/liquid-balancing.service.ts" }, is_ignored: false }
amirbilu commented 9 months ago

Hi Askath, thanks for reaching out. I assume I can just guard this function for unknown values, but it would be great if you could provide exact steps / files to reproduce the issue so I can figure what's going wrong

I edited my post. All I do, is open my project in a tmux window. I open neovim and navigate to a Typescript file in my project. I enter :TabnineChat Go back to my file in vim and Highlight a function

/**
   * @param {string} id - The ID of the Fluessigkeitsbilanzierung document to load.
   * @param {FluessigkeitsbilanzierungVo} object - The Fluessigkeitsbilanzierung head to save.
   * Saves the current Fluessigkeitsbilanzierung document and its associated entries.
   */
  saveHead(id: string, object: FluessigkeitsbilanzierungVo) {
    this.service
      .putUpdateFluessigkeitsbilanzierung(id, object)
      .pipe(take(1))
      .subscribe({
        next: (result: FluessigkeitsbilanzierungViewVo) =>
          this.head.set(result),
        error: (error) =>
          console.error('Kopf konnte nicht gespeichert werden: ', error),
      });
  }

Go back into the Chat Window and enter /explain.

I also noticed that commands like :TabnineExplain don't do anything in neovim

Regarding :TabnineExplain - do you have lsp installed? Say on a TS project?

Askath commented 9 months ago

Yes I do, running angularls and tsserver. Methods also don't have the tabnine text next to it. So I would assume they are not recognised as symbols?

amirbilu commented 9 months ago

I've tried your input and it seems to work well on my machine.

What is the output of: :lua print(vim.inspect(vim.lsp.buf_get_clients()))

Askath commented 9 months ago

I've tried your input and it seems to work well on my machine.

What is the output of: :lua print(vim.inspect(vim.lsp.buf_get_clients()))

{ { _on_attach = <function 1>, attached_buffers = { [19] = true }, cancel_request = <function 2>, commands = {}, config = { autostart = true, capabilities = { textDocument = { callHierarchy = { dynamicRegistration = false }, codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" } } }, dataSupport = true, dynamicRegistration = false, isPreferredSupport = true, resolveSupport = { properties = { "edit" } } }, completion = { completionItem = { commitCharactersSupport = true, deprecatedSupport = true, documentationFormat = { "markdown", "plaintext" }, 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 } } }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 } }, completionList = { itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" } }, contextSupport = true, dynamicRegistration = false, insertTextMode = 1 }, declaration = { linkSupport = true }, definition = { linkSupport = true }, documentHighlight = { dynamicRegistration = false }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false }, implementation = { linkSupport = true }, publishDiagnostics = { relatedInformation = true, tagSupport = { valueSet = { 1, 2 } } }, references = { dynamicRegistration = false }, rename = { dynamicRegistration = false, prepareSupport = true }, semanticTokens = { augmentsSyntaxTokens = true, dynamicRegistration = false, formats = { "relative" }, multilineTokenSupport = false, overlappingTokenSupport = true, requests = { full = { delta = true }, range = false }, serverCancelSupport = false, tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" }, tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" } }, signatureHelp = { dynamicRegistration = false, signatureInformation = { activeParameterSupport = true, documentationFormat = { "markdown", "plaintext" }, parameterInformation = { labelOffsetSupport = true } } }, synchronization = { didSave = true, dynamicRegistration = false, willSave = true, willSaveWaitUntil = true }, typeDefinition = { linkSupport = true } }, window = { showDocument = { support = true }, showMessage = { messageActionItem = { additionalPropertiesSupport = false } }, workDoneProgress = true }, workspace = { applyEdit = true, configuration = true, didChangeWatchedFiles = { dynamicRegistration = false, relativePatternSupport = true }, semanticTokens = { refreshSupport = true }, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, workspaceEdit = { resourceOperations = { "rename", "create", "delete" } }, workspaceFolders = true } }, cmd = { "ngserver", "--stdio", "--tsProbeLocations", "/Users/taradruffel/.local/share/nvim/mason/packages/angular-language-server/node_modules,/Users/taradruffel/Developer/typescript/phoenix-frontend/node_modules", "--ngProbeLocations", "/Users/taradruffel/.local/share/nvim/mason/packages/angular-language-server/node_modules/@angular/language-server/node_modules,/Users/taradruffel/Developer/typescript/phoenix-frontend/node_modules" }, cmd_cwd = "/Users/taradruffel/Developer/typescript/phoenix-frontend", file_types = { "typescript", "typescriptreact", "html", "typescript.tsx" }, filetypes = { "typescript", "html", "typescriptreact", "typescript.tsx" }, flags = {}, get_language_id = <function 3>, handlers = <1>{}, init_options = vim.empty_dict(), log_level = 2, message_level = 2, name = "angularls", on_attach = <function 4>, on_exit = <function 5>, on_init = <function 6>, on_new_config = <function 7>, original_settings = vim.empty_dict(), root_dir = "/Users/taradruffel/Developer/typescript/phoenix-frontend", settings = vim.empty_dict(), workspace_folders = <2>{ { name = "/Users/taradruffel/Developer/typescript/phoenix-frontend", uri = "file:///Users/taradruffel/Developer/typescript/phoenix-frontend" } },

= <3>{ __tostring = } }, handlers = , id = 1, initialized = true, is_stopped = , messages = { messages = {}, name = "angularls", progress = {}, status = {} }, name = "angularls", notify = , offset_encoding = "utf-16", request = , request_sync = , requests = {}, rpc = { is_closing = , notify = , request = , terminate = }, server_capabilities = { codeActionProvider = { codeActionKinds = { "quickfix" }, resolveProvider = true }, codeLensProvider = { resolveProvider = true }, completionProvider = { resolveProvider = true, triggerCharacters = { "<", ".", "*", "[", "(", "$", "|", "@" } }, definitionProvider = true, foldingRangeProvider = true, hoverProvider = true, referencesProvider = true, renameProvider = { prepareProvider = true }, signatureHelpProvider = { retriggerCharacters = { "," }, triggerCharacters = { "(", "," } }, textDocumentSync = { change = 2, openClose = true, save = { includeText = false }, willSave = false, willSaveWaitUntil = false }, typeDefinitionProvider = true, workspace = { workspaceFolders = { supported = true } } }, stop = , supports_method = , workspace_did_change_configuration = , workspace_folders =
}, { _on_attach = , attached_buffers = { [19] = true }, cancel_request = , commands = {}, config = { autostart = true, capabilities = { textDocument = { callHierarchy = { dynamicRegistration = false }, codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" } } }, dataSupport = true, dynamicRegistration = false, isPreferredSupport = true, resolveSupport = { properties = { "edit" } } }, completion = { completionItem = { commitCharactersSupport = true, deprecatedSupport = true, documentationFormat = { "markdown", "plaintext" }, 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 } } }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 } }, completionList = { itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" } }, contextSupport = true, dynamicRegistration = false, insertTextMode = 1 }, declaration = { linkSupport = true }, definition = { linkSupport = true }, documentHighlight = { dynamicRegistration = false }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = false }, implementation = { linkSupport = true }, publishDiagnostics = { relatedInformation = true, tagSupport = { valueSet = { 1, 2 } } }, references = { dynamicRegistration = false }, rename = { dynamicRegistration = false, prepareSupport = true }, semanticTokens = { augmentsSyntaxTokens = true, dynamicRegistration = false, formats = { "relative" }, multilineTokenSupport = false, overlappingTokenSupport = true, requests = { full = { delta = true }, range = false }, serverCancelSupport = false, tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" }, tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" } }, signatureHelp = { dynamicRegistration = false, signatureInformation = { activeParameterSupport = true, documentationFormat = { "markdown", "plaintext" }, parameterInformation = { labelOffsetSupport = true } } }, synchronization = { didSave = true, dynamicRegistration = false, willSave = true, willSaveWaitUntil = true }, typeDefinition = { linkSupport = true } }, window = { showDocument = { support = true }, showMessage = { messageActionItem = { additionalPropertiesSupport = false } }, workDoneProgress = true }, workspace = { applyEdit = true, configuration = true, didChangeWatchedFiles = { dynamicRegistration = false, relativePatternSupport = true }, semanticTokens = { refreshSupport = true }, symbol = { dynamicRegistration = false, hierarchicalWorkspaceSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, workspaceEdit = { resourceOperations = { "rename", "create", "delete" } }, workspaceFolders = true } }, cmd = { "/Users/taradruffel/.local/share/nvim/mason/bin/typescript-language-server", "--stdio" }, cmd_cwd = "/Users/taradruffel/Developer/typescript/phoenix-frontend", filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, flags = {}, get_language_id = , handlers =
, init_options = { hostInfo = "neovim", preferences = { importModuleSpecifierPreference = "non-relative", includeInlayEnumMemberValueHints = true, includeInlayFunctionLikeReturnTypeHints = true, includeInlayFunctionParameterTypeHints = true, includeInlayParameterNameHints = "all", includeInlayParameterNameHintsWhenArgumentMatchesName = true, includeInlayPropertyDeclarationTypeHints = true, includeInlayVariableTypeHints = true } }, keys = { { "co", , desc = "Organize Imports", mode = "n" }, { "cR", , desc = "Remove Unused Imports", mode = "n" } }, log_level = 2, message_level = 2, name = "tsserver", on_attach = , on_exit = , on_init = , on_new_config = , original_settings = { completions = { completeFunctionCalls = true }, javascript = { format = { convertTabsToSpaces = true, indentSize = 2, tabSize = 2 } }, typescript = { format = { convertTabsToSpaces = true, indentSize = 2, tabSize = 2 } } }, root_dir = "/Users/taradruffel/Developer/typescript/phoenix-frontend", settings = { completions = { completeFunctionCalls = true }, javascript = { format = { convertTabsToSpaces = true, indentSize = 2, tabSize = 2 } }, typescript = { format = { convertTabsToSpaces = true, indentSize = 2, tabSize = 2 } } }, single_file_support = true, workspace_folders = <4>{ { name = "/Users/taradruffel/Developer/typescript/phoenix-frontend", uri = "file:///Users/taradruffel/Developer/typescript/phoenix-frontend" } }, =
}, handlers =
, id = 2, initialized = true, is_stopped = , messages = { messages = {}, name = "tsserver", progress = { ["9b95dd6c-413d-46e4-8c9e-9c81f746a44e"] = { done = true, title = "Initializing JS/TS language features…" } }, status = {} }, name = "tsserver", notify = , offset_encoding = "utf-16", request = , request_sync = , requests = { [25] = { bufnr = 19, method = "textDocument/documentHighlight", type = "pending" } }, rpc = { is_closing = , notify = , request = , terminate = }, server_capabilities = { callHierarchyProvider = true, codeActionProvider = { codeActionKinds = { "source.fixAll.ts", "source.removeUnused.ts", "source.addMissingImports.ts", "source.organizeImports.ts", "source.removeUnusedImports.ts", "source.sortImports.ts", "quickfix", "refactor" } }, 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 = { prepareProvider = 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" }, { pattern = { glob = "**", matches = "folder" }, scheme = "file" } } } } }, workspaceSymbolProvider = true }, stop = , supports_method = , workspace_did_change_configuration = , workspace_folders =
} } ```
Askath commented 9 months ago

I found the problem. For some reason when the angularls server has started before tsserver nothing works. If tsserver starts first everything works fine.

Askath commented 9 months ago

I would close this issue for now. Solution for others passing by: Angular ls has no symbol support and tsserver initialised after tabnine.

Setting priorities in mason fixed it. Sorry for the inconvenience and thanks for helping :)

  "williamboman/mason-lspconfig.nvim",
    opts = {
        priorities = {
            tsserver = 10,
            angularls = 5,
        },
    },
amirbilu commented 9 months ago

Interesting. Good catch!