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: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,4 @@ jobs:
luarocksVersion: "3.12.2"

- name: run test
shell: bash
run: |
luarocks install luacheck
luarocks install vusted
vusted ./test
run: make test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,5 @@ cython_debug/

# (neo)vim helptags
/doc/tags

.dependencies/
9 changes: 8 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"diagnostics.globals": ["describe", "it"],
"runtime.version": "LuaJIT",
"diagnostics.globals": [
"describe",
"it",
"MiniTest",
"before_each",
"after_each"
],
"diagnostics.disable": ["redefined-local"]
}
18 changes: 1 addition & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,12 @@ BUILD_DIR := build

.PHONY: help install-cli install-pre-commit install test tiktoken clean

help:
@echo "Available commands:"
@echo " install-cli - Install Lua and Luarocks using Homebrew"
@echo " install-pre-commit - Install pre-commit using pip"
@echo " install - Install vusted using Luarocks"
@echo " test - Run tests using vusted"
@echo " tiktoken - Download tiktoken_core library"
@echo " clean - Remove build directory"

install-cli:
brew install luarocks
brew install lua

install-pre-commit:
pip install pre-commit
pre-commit install

install:
luarocks install vusted

test:
vusted test
nvim --headless --noplugin -u ./scripts/test.lua -c "lua MiniTest.run()"

all: luajit

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ cd CopilotChat.nvim
2. Install development dependencies:

```bash
# Install pre-commit hooks
make install-pre-commit
```

Expand Down
16 changes: 16 additions & 0 deletions scripts/minimal.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- https://github.com/neovim/neovim/blob/master/contrib/minimal.lua
vim.opt.runtimepath:append(vim.fn.getcwd())

for name, url in pairs({
'https://github.com/nvim-lua/plenary.nvim',
}) do
local install_path = vim.fn.fnamemodify('.dependencies/' .. name, ':p')
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ 'git', 'clone', '--depth=1', url, install_path })
end
vim.opt.runtimepath:append(install_path)
end

require('CopilotChat').setup({
-- Add your configuration here
})
14 changes: 14 additions & 0 deletions scripts/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vim.opt.runtimepath:append(vim.fn.getcwd())

for name, url in pairs({
'https://github.com/nvim-lua/plenary.nvim',
'https://github.com/echasnovski/mini.test',
}) do
local install_path = vim.fn.fnamemodify('.dependencies/' .. name, ':p')
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ 'git', 'clone', '--depth=1', url, install_path })
end
vim.opt.runtimepath:append(install_path)
end

require('mini.test').setup()
18 changes: 0 additions & 18 deletions test/plugin_spec.lua

This file was deleted.

9 changes: 9 additions & 0 deletions tests/test_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local T = MiniTest.new_set()

T['should be able to load'] = function()
MiniTest.expect.no_error(function()
require('CopilotChat')
end)
end

return T
52 changes: 52 additions & 0 deletions tests/test_utils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
local T = MiniTest.new_set()

local cases = {
{ glob = '', expected = '^$' },
{ glob = 'abc', expected = '^abc$' },
{ glob = 'ab#/.', expected = '^ab%#%/%.$' },
{ glob = '\\\\\\ab\\c\\', expected = '^%\\abc\\$' },

{ glob = 'abc.*', expected = '^abc%..*$', matches = { 'abc.txt', 'abc.' }, not_matches = { 'abc' } },
{ glob = '??.txt', expected = '^..%.txt$' },

{ glob = 'a[]', expected = '[^]' },
{ glob = 'a[^]b', expected = '^ab$' },
{ glob = 'a[!]b', expected = '^ab$' },
{ glob = 'a[a][b]z', expected = '^a[a][b]z$' },
{ glob = 'a[a-f]z', expected = '^a[a-f]z$' },
{ glob = 'a[a-f0-9]z', expected = '^a[a-f0-9]z$' },
{ glob = 'a[a-f0-]z', expected = '^a[a-f0%-]z$' },
{ glob = 'a[!a-f]z', expected = '^a[^a-f]z$' },
{ glob = 'a[^a-f]z', expected = '^a[^a-f]z$' },
{ glob = 'a[\\!\\^\\-z\\]]z', expected = '^a[%!%^%-z%]]z$' },
{ glob = 'a[\\a-\\f]z', expected = '^a[a-f]z$' },

{ glob = 'a[', expected = '[^]' },
{ glob = 'a[a-', expected = '[^]' },
{ glob = 'a[a-b', expected = '[^]' },
{ glob = 'a[!', expected = '[^]' },
{ glob = 'a[!a', expected = '[^]' },
{ glob = 'a[!a-', expected = '[^]' },
{ glob = 'a[!a-b', expected = '[^]' },
{ glob = 'a[!a-b\\]', expected = '[^]' },
}

for _, case in ipairs(cases) do
T['glob_to_pattern: ' .. case.glob] = function()
local utils = require('CopilotChat.utils')
local pattern = utils.glob_to_pattern(case.glob)
MiniTest.expect.equality(pattern, case.expected)
if case.matches then
for _, str in ipairs(case.matches) do
MiniTest.expect.equality(str:match(pattern) ~= nil, true)
end
end
if case.not_matches then
for _, str in ipairs(case.not_matches) do
MiniTest.expect.equality(str:match(pattern) ~= nil, false)
end
end
end
end

return T
Loading