Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove teal #812

Merged
merged 2 commits into from
Jun 13, 2023
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
50 changes: 16 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,35 @@ jobs:
# Check commit messages
- uses: webiny/action-conventional-commits@v1.1.0

build:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
neovim_branch: ['v0.8.3', 'nightly']
runs-on: ubuntu-latest
neovim_branch:
- 'v0.8.3'
- 'v0.9.1'
- 'nightly'

env:
NEOVIM_BRANCH: ${{ matrix.neovim_branch }}
NVIM_TEST_VERSION: ${{ matrix.neovim_branch }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get Neovim SHA
id: get-nvim-sha
run: |
echo "sha=$(git ls-remote https://github.com/neovim/neovim ${{env.NEOVIM_BRANCH}} | cut -f1)" >> $GITHUB_OUTPUT

- name: Cache Deps
id: cache-deps
uses: actions/cache@v3
- uses: leafo/gh-actions-lua@v9
with:
path: deps
key: ${{ steps.get-nvim-sha.outputs.sha }}-${{ hashFiles('.github/workflows/ci.yml', 'Makefile') }}

- name: Install Neovim build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo apt-get update &&
sudo apt-get install -y \
cmake \
g++ \
gettext \
libtool-bin \
lua-bitop \
ninja-build \
unzip
luaVersion: "5.1.5"

- name: Build Neovim
if: steps.cache-deps.outputs.cache-hit != 'true'
run: make test_deps
- uses: leafo/gh-actions-luarocks@v4

- name: Install Lua Deps
run: make lua_deps
- name: install busted
run: luarocks install busted

- name: Check lua files are built from latest teal
run: make tl-ensure
- name: Download Nvim
run: make nvim

- name: Run Test
run: make test
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
doc/tags

neovim

scratch/dummy_ignored.txt

nvim-test-*
nvim-runner-*
6 changes: 6 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
column_width = 100
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "Always"
53 changes: 1 addition & 52 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,9 @@
- [Luarocks](https://luarocks.org/)
- `brew install luarocks`

## Writing Teal

**Do not edit files in the lua dir**.

Gitsigns is implemented in teal which is essentially lua+types.
The teal source files are generated into lua files and must be checked in together when making changes.
CI will enforce this.

Once you have made changes in teal, the corresponding lua files can be built with:

```
make tl-build
```

## Generating docs

Most of the documentation is handwritten however the documentation for the configuration is generated from `teal/gitsigns/config.tl` which contains the configuration schema.
Most of the documentation is handwritten however the documentation for the configuration is generated from `lua/gitsigns/config.lua` which contains the configuration schema.
The documentation is generated with the lua script `gen_help.lua` which has been developed just enough to handle the current configuration schema so from time to time this script might need small improvements to handle new features but for the most part it works.

The documentation can be updated with:
Expand All @@ -46,40 +32,3 @@ To run the testsuite:
```
make test
```

## [Diagnostic-ls](https://github.com/iamcco/diagnostic-languageserver) config for teal

```
require('lspconfig').diagnosticls.setup{
filetypes = {'teal'},
init_options = {
filetypes = {teal = {'tealcheck'}},
linters = {
tealcheck = {
sourceName = "tealcheck",
command = "tl",
args = {'check', '%file'},
isStdout = false, isStderr = true,
rootPatterns = {"tlconfig.lua", ".git"},
formatPattern = {
'^([^:]+):(\\d+):(\\d+): (.+)$', {
sourceName = 1, sourceNameFilter = true,
line = 2, column = 3, message = 4
}
}
}
}
}
}
```

## [null-ls.nvim](https://github.com/jose-elias-alvarez/null-ls.nvim) config for teal

```
local null_ls = require("null-ls")

null_ls.config {sources = {
null_ls.builtins.diagnostics.teal
}}
require("lspconfig")["null-ls"].setup {}
```
102 changes: 37 additions & 65 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,66 @@ export PJ_ROOT=$(PWD)

FILTER ?= .*

LUA_VERSION := 5.1
TL_VERSION := 0.14.1
NEOVIM_BRANCH ?= master
NVIM_RUNNER_VERSION := v0.9.1
NVIM_TEST_VERSION ?= v0.9.1

DEPS_DIR := $(PWD)/deps/nvim-$(NEOVIM_BRANCH)
NVIM_DIR := $(DEPS_DIR)/neovim
ifeq ($(shell uname -s),Darwin)
NVIM_PLATFORM ?= macos
else
NVIM_PLATFORM ?= linux64
endif

LUAROCKS := $(DEPS_DIR)/luarocks/usr/bin/luarocks
LUAROCKS_TREE := $(DEPS_DIR)/luarocks/usr
LUAROCKS_LPATH := $(LUAROCKS_TREE)/share/lua/$(LUA_VERSION)
LUAROCKS_INIT := eval $$($(LUAROCKS) --tree $(LUAROCKS_TREE) path) &&
NVIM_URL := https://github.com/neovim/neovim/releases/download

.DEFAULT_GOAL := build

$(NVIM_DIR):
@mkdir -p $(DEPS_DIR)
git clone --depth 1 https://github.com/neovim/neovim --branch $(NEOVIM_BRANCH) $@
@# disable LTO to reduce compile time
make -C $@ \
DEPS_BUILD_DIR=$(dir $(LUAROCKS_TREE)) \
CMAKE_BUILD_TYPE=RelWithDebInfo \
CMAKE_EXTRA_FLAGS='-DCI_BUILD=OFF -DENABLE_LTO=OFF'
NVIM_RUNNER := nvim-runner-$(NVIM_RUNNER_VERSION)
NVIM_RUNNER_URL := $(NVIM_URL)/$(NVIM_RUNNER_VERSION)/nvim-$(NVIM_PLATFORM).tar.gz

TL := $(LUAROCKS_TREE)/bin/tl
NVIM_TEST := nvim-test-$(NVIM_TEST_VERSION)
NVIM_TEST_URL := $(NVIM_URL)/$(NVIM_TEST_VERSION)/nvim-$(NVIM_PLATFORM).tar.gz

$(TL): $(NVIM_DIR)
@mkdir -p $$(dirname $@)
$(LUAROCKS) --tree $(LUAROCKS_TREE) install tl $(TL_VERSION)
export NVIM_PRG = $(NVIM_TEST)/bin/nvim

INSPECT := $(LUAROCKS_LPATH)/inspect.lua

$(INSPECT): $(NVIM_DIR)
@mkdir -p $$(dirname $@)
$(LUAROCKS) --tree $(LUAROCKS_TREE) install inspect
.DEFAULT_GOAL := build

LUV := $(LUAROCKS_TREE)/lib/lua/$(LUA_VERSION)/luv.so
define fetch_nvim
rm -rf $@
rm -rf nvim-$(NVIM_PLATFORM).tar.gz
wget $(1)
tar -xf nvim-$(NVIM_PLATFORM).tar.gz
rm -rf nvim-$(NVIM_PLATFORM).tar.gz
mv nvim-$(NVIM_PLATFORM) $@
endef

$(LUV): $(NVIM_DIR)
@mkdir -p $$(dirname $@)
$(LUAROCKS) --tree $(LUAROCKS_TREE) install luv
$(NVIM_RUNNER):
$(call fetch_nvim,$(NVIM_RUNNER_URL))

.PHONY: lua_deps
lua_deps: $(TL) $(INSPECT)
$(NVIM_TEST):
$(call fetch_nvim,$(NVIM_TEST_URL))

.PHONY: test_deps
test_deps: $(NVIM_DIR)
.PHONY: nvim
nvim: $(NVIM_RUNNER) $(NVIM_TEST)

export VIMRUNTIME=$(NVIM_DIR)/runtime
export TEST_COLORS=1
LUAROCKS := luarocks --lua-version=5.1 --tree .luarocks

BUSTED = $$( [ -f $(NVIM_DIR)/test/busted_runner.lua ] \
&& echo "$(NVIM_DIR)/build/bin/nvim -ll $(NVIM_DIR)/test/busted_runner.lua" \
|| echo "$(LUAROCKS_INIT) busted" )
.luarocks/bin/busted:
$(LUAROCKS) install busted

.PHONY: test
test: $(NVIM_DIR)
$(BUSTED) -v \
test: $(NVIM_RUNNER) $(NVIM_TEST) .luarocks/bin/busted
eval $$($(LUAROCKS) path) && $(NVIM_RUNNER)/bin/nvim -ll test/busted/runner.lua -v \
--lazy \
--helper=$(PWD)/test/preload.lua \
--output test.busted.outputHandlers.nvim \
--lpath=$(NVIM_DIR)/?.lua \
--lpath=$(NVIM_DIR)/build/?.lua \
--lpath=$(NVIM_DIR)/runtime/lua/?.lua \
--lpath=$(DEPS_DIR)/?.lua \
--output test.busted.output_handler \
--lpath=$(PWD)/lua/?.lua \
--filter="$(FILTER)" \
$(PWD)/test

-@stty sane

.PHONY: tl-check
tl-check: $(TL)
$(TL) check teal/*.tl teal/**/*.tl

.PHONY: tl-build
tl-build: tlconfig.lua $(TL) $(LUV)
@$(TL) build
@$(LUAROCKS_INIT) ./etc/add_comments.lua
@echo Updated lua files

.PHONY: gen_help
gen_help: $(INSPECT)
@$(LUAROCKS_INIT) ./gen_help.lua
gen_help:
@./gen_help.lua
@echo Updated help

.PHONY: build
build: tl-build gen_help

.PHONY: tl-ensure
tl-ensure: tl-build
git diff --exit-code -- lua
build: gen_help
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Gitter](https://badges.gitter.im/gitsigns-nvim/community.svg)](https://gitter.im/gitsigns-nvim/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Super fast git decorations implemented purely in lua/teal.
Super fast git decorations implemented purely in Lua.

## Preview

Expand Down
Loading
Loading