Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lua/CopilotChat/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ local function create_buf()
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(bufnr, 'copilot-chat')
vim.bo[bufnr].filetype = 'markdown'
vim.treesitter.start(bufnr, 'markdown')
vim.bo[bufnr].syntax = 'markdown'
local ok, parser = pcall(vim.treesitter.get_parser, bufnr, 'markdown')
if ok and parser then
vim.treesitter.start(bufnr, 'markdown')
end
return bufnr
end

Expand Down
24 changes: 22 additions & 2 deletions lua/CopilotChat/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ local function lualib_installed(lib_name)
return res
end

--- Check if a treesitter parser is available
---@param ft string
---@return boolean
local function treesitter_parser_available(ft)
local res, parser = pcall(vim.treesitter.get_parser, 0, ft)
return res and parser ~= nil
end

function M.check()
start('CopilotChat.nvim [core]')

Expand Down Expand Up @@ -58,8 +66,7 @@ function M.check()

start('CopilotChat.nvim [dependencies]')

local has_plenary = lualib_installed('plenary')
if has_plenary then
if lualib_installed('plenary') then
ok('plenary: installed')
else
error('plenary: missing, required for running tests. Install plenary.nvim')
Expand All @@ -74,11 +81,24 @@ function M.check()
'copilot: missing, required for 2 factor authentication. Install copilot.vim or copilot.lua'
)
end

if lualib_installed('tiktoken_core') then
ok('tiktoken_core: installed')
else
warn('tiktoken_core: missing, optional for token counting.')
end

if treesitter_parser_available('markdown') then
ok('treesitter[markdown]: installed')
else
warn('treesitter[markdown]: missing, optional for better chat highlighting')
end

if treesitter_parser_available('diff') then
ok('treesitter[diff]: installed')
else
warn('treesitter[diff]: missing, optional for better diff highlighting')
end
end

return M