From 9401c0371056a8860743e54089d3ff3be52d0ae3 Mon Sep 17 00:00:00 2001 From: Atif Date: Thu, 24 Jul 2025 20:07:18 +0600 Subject: [PATCH 1/2] feat: add Windows_NT support in Makefile and dynamic library loading --- Makefile | 3 +++ lua/CopilotChat/tiktoken.lua | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Makefile b/Makefile index cd71bc6e..c5d53c52 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ ifeq ($(UNAME), Linux) else ifeq ($(UNAME), Darwin) OS := macOS EXT := dylib +else ifeq ($(UNAME), Windows_NT) + OS := windows + EXT := dll else $(error Unsupported operating system: $(UNAME)) endif diff --git a/lua/CopilotChat/tiktoken.lua b/lua/CopilotChat/tiktoken.lua index 9bfa2945..a4582cb4 100644 --- a/lua/CopilotChat/tiktoken.lua +++ b/lua/CopilotChat/tiktoken.lua @@ -2,6 +2,23 @@ local notify = require('CopilotChat.notify') local utils = require('CopilotChat.utils') local current_tokenizer = nil +--- @return string +local function get_lib_extension() + if jit.os:lower() == 'mac' or jit.os:lower() == 'osx' then + return '.dylib' + end + if jit.os:lower() == 'windows' then + return '.dll' + end + return '.so' +end + +package.cpath = package.cpath + .. ';' + .. debug.getinfo(1).source:match('@?(.*/)') + .. '../../build/?' + .. get_lib_extension() + local tiktoken_ok, tiktoken_core = pcall(require, 'tiktoken_core') if not tiktoken_ok then tiktoken_core = nil From 5eb3ec28b03964b598868ffee6851208e8822618 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 24 Jul 2025 14:33:49 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6761c5e6..66a56cf7 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ CopilotChat.nvim is a Neovim plugin that brings GitHub Copilot Chat capabilities ## Optional Dependencies - [tiktoken_core](https://github.com/gptlang/lua-tiktoken) - For accurate token counting - - Arch Linux: Install [`luajit-tiktoken-bin`](https://aur.archlinux.org/packages/luajit-tiktoken-bin) or [`lua51-tiktoken-bin`](https://aur.archlinux.org/packages/lua51-tiktoken-bin) from AUR - Via luarocks: `sudo luarocks install --lua-version 5.1 tiktoken_core` - Manual: Download from [lua-tiktoken releases](https://github.com/gptlang/lua-tiktoken/releases) and save as `tiktoken_core.so` in your Lua path