Skip to content

Commit

Permalink
test: migrate to nvim-test
Browse files Browse the repository at this point in the history
Also run the tests with tree-sitter highlighting enabled.
  • Loading branch information
lewis6991 committed Feb 14, 2024
1 parent d0053ee commit aef063a
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 246 deletions.
48 changes: 23 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,35 @@ on:
workflow_dispatch:

jobs:
build:
commit_lint:
runs-on: ubuntu-latest
steps:
# Check commit messages
- uses: webiny/action-conventional-commits@v1.1.0

test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
neovim_branch: ['v0.9.5']
runs-on: ubuntu-latest
neovim_version: ['0.9.5']

env:
NEOVIM_BRANCH: ${{ matrix.neovim_branch }}
NEOVIM_VERSION: ${{ matrix.neovim_version }}

steps:
- uses: actions/checkout@v3

- name: Setup build dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y \
cmake \
g++ \
gettext \
libtool-bin \
lua-bitop \
ninja-build \
unzip
- name: Cache neovim
uses: actions/cache@v3
- name: Checkout
uses: actions/checkout@v4

- uses: leafo/gh-actions-lua@v10
with:
path: neovim-${{env.NEOVIM_BRANCH}}
key: build-${{env.NEOVIM_BRANCH}}
luaVersion: "5.1.5"

- uses: leafo/gh-actions-luarocks@v4

- name: Build Neovim
run: make neovim NEOVIM_BRANCH=$NEOVIM_BRANCH
- name: Download nvim-test
run: make nvim-test

- name: Run Test
run: make test NEOVIM_BRANCH=$NEOVIM_BRANCH
run: make test NEOVIM_VERSION=$NEOVIM_VERSION
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
neovim-*
nvim-test
nvim-treesitter
58 changes: 15 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,29 @@
.DEFAULT_GOAL := test

NEOVIM_BRANCH := v0.9.5
NEOVIM_VERSION := 0.9.5

FILTER=.*

NEOVIM := neovim-$(NEOVIM_BRANCH)
NVIM_TS_SHA := 883c72cd

.PHONY: neovim
neovim: $(NEOVIM)

$(NEOVIM):
git clone --depth 1 https://github.com/neovim/neovim --branch $(NEOVIM_BRANCH) $@
make -C $@
FILTER=.*

nvim-treesitter:
git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter
git clone \
--filter=blob:none \
https://github.com/nvim-treesitter/nvim-treesitter
cd nvim-treesitter && git checkout $(NVIM_TS_SHA)

nvim-treesitter/parser/%.so: nvim-treesitter $(NEOVIM)
$(RM) -r $@
VIMRUNTIME=$(NEOVIM)/runtime $(NEOVIM)/build/bin/nvim \
--headless \
--clean \
--cmd 'set rtp+=./nvim-treesitter' \
-c "TSInstallSync $*" \
-c "q"

export VIMRUNTIME=$(PWD)/$(NEOVIM)/runtime

BUSTED = $$( [ -f $(NEOVIM)/test/busted_runner.lua ] \
&& echo "$(NEOVIM)/build/bin/nvim -ll $(NEOVIM)/test/busted_runner.lua" \
|| echo "$(NEOVIM)/.deps/usr/bin/busted" )
nvim-test:
git clone https://github.com/lewis6991/nvim-test
nvim-test/bin/nvim-test --init

.PHONY: test
test: $(NEOVIM) nvim-treesitter \
nvim-treesitter/parser/cpp.so \
nvim-treesitter/parser/lua.so \
nvim-treesitter/parser/rust.so \
nvim-treesitter/parser/typescript.so
$(BUSTED) \
-v \
--lazy \
--helper=$(PWD)/test/preload.lua \
--output test.busted.outputHandlers.nvim \
--lpath=$(PWD)/$(NEOVIM)/?.lua \
--lpath=$(PWD)/$(NEOVIM)/build/?.lua \
--lpath=$(PWD)/$(NEOVIM)/runtime/lua/?.lua \
--lpath=$(PWD)/nvim-treesitter/lua/?.lua \
--lpath=$(PWD)/?.lua \
test: nvim-test nvim-treesitter
nvim-test/bin/nvim-test test \
--runner_version $(NEOVIM_VERSION) \
--target_version $(NEOVIM_VERSION) \
--lpath=$(PWD)/lua/?.lua \
--filter=$(FILTER) \
$(PWD)/test

-@stty sane
--verbose

lint:
luacheck lua
1 change: 1 addition & 0 deletions lua/treesitter-context/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ local function highlight_contexts(bufnr, ctx_bufnr, contexts)
end_col = necol,
priority = priority + p,
hl_group = hl_from_capture(query, capture, lang),
conceal = metadata.conceal,
})

-- TODO(lewis6991): Extmarks of equal priority appear to apply
Expand Down
Loading

0 comments on commit aef063a

Please sign in to comment.