Repository: CopilotC-Nvim/CopilotChat.nvim

Issue #444: Vimscript function must not be called in a lua loop callback
Created: 2024-10-30T15:07:53Z
nvim version: v0.10.2
CopilotChat: e172d73
lazy.nvim: cf8ecc2
Configuration:
	{
		'CopilotC-Nvim/CopilotChat.nvim',
		dependencies = {
			{ "nvim-telescope/telescope.nvim" },
			{ "nvim-lua/plenary.nvim" },
		},
		config = function(_, opts)
			local chat = require("CopilotChat")
			chat.setup(opts)
        end,
	},

When opening  vim, I get the following message:
Error executing luv callback:
.../nvim/lazy/CopilotChat.nvim/lua/CopilotChat/tiktoken.lua:8: E5560: Vimscript function must not be called in a lua loop callback
stack traceback:
        [C]: in function 'mkdir'
        .../nvim/lazy/CopilotChat.nvim/lua/CopilotChat/tiktoken.lua:8: in function 'get_cache_path'
        .../nvim/lazy/CopilotChat.nvim/lua/CopilotChat/tiktoken.lua:32: in function <.../nvim/lazy/CopilotChat.nvim/lua/CopilotChat/tiktoken.lua:30>
        [C]: in function 'expand'
        ...e/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/copilot.lua:80: in function 'find_config_path'
        ...e/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/copilot.lua:106: in function 'get_cached_token'
        ...e/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/copilot.lua:298: in function 'fn'
        ...are/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/utils.lua:26: in function 'Copilot'
        ...hare/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/init.lua:612: in function 'setup'
        /home/user/.config/nvim/lua/plugins/copilot.lua:102: in function 'config'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:376: in function <...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:374>
        [C]: in function 'xpcall'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:135: in function 'try'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:391: in function 'config'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:358: in function '_load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:197: in function 'load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:127: in function 'startup'
        ...hpena/.local/share/nvim/lazy/lazy.nvim/lua/lazy/init.lua:112: in function 'setup'
        /home/user/.config/nvim/lua/config/lazy.lua:25: in main chunk
        [C]: in function 'require'
        /home/user/.config/nvim/init.lua:3: in main chunk

Duplicate issue #415: Expected value but found invalid token at character 1
Created: 2024-09-18T11:16:47Z
Hi there, I am trying to use CopilotChat.nvim.  I think maybe the main difference is I am using packer.nvim as my package manager.  I am installing Copilot chat like so:
  use {
    'CopilotC-Nvim/CopilotChat.nvim',
    branch = 'canary',
    requires = {
      'github/copilot.vim',
      'nvim-lua/plenary.nvim',
    }
  }

-- copilot chat
require("CopilotChat").setup({
   debug = true,
})
Then I run PackerSync and it looks like CopilotChat is installed correctly.  (PackerSync is also making sure that all other libraries / dependencies are up-to-date as well)
Here is the output of checkhealth CopilotChat:
CopilotChat: require("CopilotChat.health").check()

CopilotChat.nvim [core] ~
- OK nvim: NVIM v0.10.1
  Build type: Release
  LuaJIT 2.1.1725453128
  Run ":verbose version" for more info

CopilotChat.nvim [commands] ~
- OK curl: curl 8.9.1 (x86_64-pc-linux-gnu) libcurl/8.9.1 OpenSSL/3.3.2 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.63.0 nghttp3/1.5.0
  Release-Date: 2024-07-31
  Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
  Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
- OK git: git version 2.46.0

CopilotChat.nvim [dependencies] ~
- OK plenary: installed
- OK copilot: copilot.vim
- WARNING tiktoken_core: missing, optional for token counting. See README for installation instructions.
- OK treesitter[markdown]: installed
- OK treesitter[diff]: installed

However, if I try to enter a prompt into the window, or if I run CopilotChatExplain, I am getting the following error:
[CopilotChat.nvim] "Expected value but found invalid token at character 1
Any help to debug would be greatly appreciated.  Thanks!

Closing comment (2024-10-31T14:56:44Z): The commits to the canary branch from 2024-10-30 fixed errors mentioned in this issue, including one related to #444. Feel free to close this issue.