Skip to content

Commit df8efe9

Browse files
authored
fix(os): use vim.uv.os_uname for OS detection (#1449)
Replace usage of jit.os with vim.uv.os_uname().sysname to not rely on neovim builds with LuaJIT
1 parent acd1e6d commit df8efe9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lua/CopilotChat/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ function M.resolve_prompt(prompt, config)
586586
.. vim.trim(require('CopilotChat.instructions.edit_file_block'))
587587
end
588588

589-
config.system_prompt = config.system_prompt:gsub('{OS_NAME}', jit.os)
589+
config.system_prompt = config.system_prompt:gsub('{OS_NAME}', vim.uv.os_uname().sysname)
590590
config.system_prompt = config.system_prompt:gsub('{LANGUAGE}', config.language)
591591
config.system_prompt = config.system_prompt:gsub('{DIR}', state.source.cwd())
592592
end

lua/CopilotChat/tiktoken.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ local class = require('CopilotChat.utils.class')
66
--- Get the library extension based on the operating system
77
--- @return string
88
local function get_lib_extension()
9-
if jit.os:lower() == 'mac' or jit.os:lower() == 'osx' then
9+
local os_name = vim.uv.os_uname().sysname:lower()
10+
if os_name:find('darwin') then
1011
return '.dylib'
11-
end
12-
if jit.os:lower() == 'windows' then
12+
elseif os_name:find('windows') then
1313
return '.dll'
14+
else
15+
return '.so'
1416
end
15-
return '.so'
1617
end
1718

1819
--- Load tiktoken data from cache or download it

0 commit comments

Comments
 (0)