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
5 changes: 5 additions & 0 deletions .github/scripts/install-binary-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ while read -r name type url extra; do
chmod +x "$dest/$name"
rm -rf "$tmpdir"
;;
jar)
wget -q "$url" -O "$dest/$name.jar"
printf '#!/usr/bin/env bash\nexec java -jar "%s/%s.jar" "$@"\n' "$(cd "$dest" && pwd)" "$name" > "$dest/$name"
chmod +x "$dest/$name"
;;
esac
done < "$manifest"
5 changes: 5 additions & 0 deletions .github/tools/binary.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
alejandra bin https://github.com/kamadorueda/alejandra/releases/download/4.0.0/alejandra-x86_64-unknown-linux-musl
buf bin https://github.com/bufbuild/buf/releases/download/v1.47.2/buf-Linux-x86_64
hadolint bin https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
checkmake bin https://github.com/mrtazz/checkmake/releases/download/0.2.2/checkmake-0.2.2.linux.amd64
deno zip https://github.com/denoland/deno/releases/download/v2.1.4/deno-x86_64-unknown-linux-gnu.zip
detekt jar https://github.com/detekt/detekt/releases/download/v1.23.7/detekt-cli-1.23.7-all.jar
hlint tar https://github.com/ndmitchell/hlint/releases/download/v3.10/hlint-3.10-x86_64-linux.tar.gz hlint-3.10/hlint
latexindent bin https://github.com/cmhughes/latexindent.pl/releases/download/V3.24.4/latexindent-linux
swiftformat zip https://github.com/nicklockwood/SwiftFormat/releases/download/0.55.3/swiftformat_linux.zip swiftformat_linux
cbfmt tar https://github.com/lukas-reineke/cbfmt/releases/download/v0.2.0/cbfmt_linux-x86_64_v0.2.0.tar.gz cbfmt_linux-x86_64_v0.2.0/cbfmt
dprint zip https://github.com/dprint/dprint/releases/download/0.49.0/dprint-x86_64-unknown-linux-gnu.zip
ktlint bin https://github.com/pinterest/ktlint/releases/download/1.8.0/ktlint
3 changes: 3 additions & 0 deletions .github/tools/npm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ prettier
@biomejs/biome
sql-formatter
@taplo/cli
eslint
eslint_d
stylelint
1 change: 1 addition & 0 deletions .github/tools/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cpplint
docformatter
flake8
mypy
pylint
ruff
sqlfluff
yapf
66 changes: 65 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
- name: Install tools
run: |
xargs -L1 go install < .github/tools/go.txt
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8
luarocks install busted --local
luarocks install nlua --local
- name: Clone guard.nvim
Expand Down Expand Up @@ -163,13 +164,17 @@ jobs:
with:
neovim: true
version: nightly
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- uses: leso-kn/gh-actions-lua@master
with:
luaVersion: "5.1"
- uses: hishamhm/gh-actions-luarocks@master
- name: Install tools
run: |
sudo apt-get install -y zsh
sudo apt-get install -y zsh shellcheck
luarocks install busted --local
luarocks install nlua --local
bash .github/scripts/install-binary-tools.sh "$HOME/.local/bin"
Expand Down Expand Up @@ -205,3 +210,62 @@ jobs:
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
busted --lua nlua test/apt/*_spec.lua

test-dotnet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: nightly
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0'
- uses: leso-kn/gh-actions-lua@master
with:
luaVersion: "5.1"
- uses: hishamhm/gh-actions-luarocks@master
- name: Install tools
run: |
dotnet tool install -g csharpier
luarocks install busted --local
luarocks install nlua --local
- name: Clone guard.nvim
run: git clone --depth 1 https://github.com/nvimdev/guard.nvim && mv guard.nvim/lua/guard lua/
- name: Run tests
run: |
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
busted --lua nlua test/dotnet/*_spec.lua

test-ruby:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: nightly
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- uses: leso-kn/gh-actions-lua@master
with:
luaVersion: "5.1"
- uses: hishamhm/gh-actions-luarocks@master
- name: Install tools
run: |
gem install rubocop bundler
luarocks install busted --local
luarocks install nlua --local
- name: Setup rubocop Gemfile
run: |
mkdir -p /tmp/rubocop-test
printf "source 'https://rubygems.org'\ngem 'rubocop'\n" > /tmp/rubocop-test/Gemfile
cd /tmp/rubocop-test && bundle install
- name: Clone guard.nvim
run: git clone --depth 1 https://github.com/nvimdev/guard.nvim && mv guard.nvim/lua/guard lua/
- name: Run tests
run: |
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
busted --lua nlua test/ruby/*_spec.lua

10 changes: 5 additions & 5 deletions lua/guard-collection/formatter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ M.cljfmt = {
}

M.csharpier = {
cmd = 'dotnet-csharpier',
args = { '--write-stdout' },
cmd = 'csharpier',
args = { 'format', '--write-stdout' },
stdin = true,
}

Expand Down Expand Up @@ -299,7 +299,7 @@ M.ruff = {

M.ruff_fix = {
cmd = 'ruff',
args = { '--fix', '-', '--stdin-filename' },
args = { 'check', '--fix', '-', '--stdin-filename' },
stdin = true,
fname = true,
}
Expand All @@ -319,8 +319,8 @@ M.biome = {

M.buf = {
cmd = 'buf',
args = { 'format' },
stdin = true,
args = { 'format', '-w' },
fname = true,
}

M.xmllint = {
Expand Down
2 changes: 1 addition & 1 deletion lua/guard-collection/linter/hadolint.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
return {
cmd = 'hadolint',
args = { '--no-fail', '--format=json' },
args = { '--no-fail', '--format=json', '-' },
stdin = true,
parse = require('guard.lint').from_json({
attributes = {
Expand Down
1 change: 1 addition & 0 deletions lua/guard-collection/linter/pylint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ return {
cmd = 'pylint',
args = { '--from-stdin', '--output-format', 'json' },
stdin = true,
fname = true,
parse = lint.from_json({
attributes = {
severity = 'type',
Expand Down
1 change: 1 addition & 0 deletions lua/guard-collection/linter/rubocop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ return {
cmd = 'bundle',
args = { 'exec', 'rubocop', '--format', 'json', '--force-exclusion', '--stdin' },
stdin = true,
fname = true,
parse = lint.from_json({
get_diagnostics = function(...)
return vim.json.decode(...).files[1].offenses
Expand Down
2 changes: 1 addition & 1 deletion lua/guard-collection/linter/ruff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local lint = require('guard.lint')
return {
cmd = 'ruff',
args = {
'check',
'-n',
'-e',
'--output-format',
'json',
'-',
Expand Down
1 change: 1 addition & 0 deletions lua/guard-collection/linter/shellcheck.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
cmd = 'shellcheck',
args = { '--format', 'json1', '--external-sources' },
fname = true,
parse = require('guard.lint').from_json({
get_diagnostics = function(...)
return vim.json.decode(...).comments
Expand Down
20 changes: 20 additions & 0 deletions test/binary/buf_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('buf', function()
local tmpdir = vim.fn.getcwd() .. '/tmp-buf-test'

setup(function()
vim.fn.mkdir(tmpdir, 'p')
end)

teardown(function()
vim.fn.delete(tmpdir, 'rf')
end)

it('can format', function()
local formatted = require('test.helper').run_fmt('buf', 'proto', {
'syntax="proto3";',
'package test;',
'message Foo{string bar=1;}',
}, { tmpdir = tmpdir })
assert.is_true(#formatted > 3)
end)
end)
25 changes: 25 additions & 0 deletions test/binary/cbfmt_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe('cbfmt', function()
local tmpdir = vim.fn.getcwd() .. '/tmp-cbfmt-test'

setup(function()
vim.fn.mkdir(tmpdir, 'p')
vim.fn.writefile({ '[languages]' }, tmpdir .. '/.cbfmt.toml')
end)

teardown(function()
vim.fn.delete(tmpdir, 'rf')
end)

it('can format', function()
local formatted = require('test.helper').run_fmt('cbfmt', 'md', {
'# Title',
'',
'Some text.',
}, { cwd = tmpdir })
assert.are.same({
'# Title',
'',
'Some text.',
}, formatted)
end)
end)
24 changes: 24 additions & 0 deletions test/binary/detekt_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe('detekt', function()
it('can lint', function()
local helper = require('test.helper')
local bufnr, diagnostics = helper.run_lint('detekt', 'kt', {
[[fun main() {]],
[[ val x = 42]],
[[ if (x > 0) {]],
[[ println(x)]],
[[ }]],
[[}]],
})
assert.is_true(#diagnostics > 0)
helper.assert_diag(diagnostics[1], {
bufnr = bufnr,
source = 'detekt',
})
for _, d in ipairs(diagnostics) do
assert.equal(bufnr, d.bufnr)
assert.equal('detekt', d.source)
assert.is_number(d.lnum)
assert.is_string(d.message)
end
end)
end)
28 changes: 28 additions & 0 deletions test/binary/dprint_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe('dprint', function()
local tmpdir = vim.fn.getcwd() .. '/tmp-dprint-test'

setup(function()
vim.fn.mkdir(tmpdir, 'p')
vim.fn.writefile({
'{',
' "typescript": {},',
' "plugins": [',
' "https://plugins.dprint.dev/typescript-0.93.3.wasm"',
' ]',
'}',
}, tmpdir .. '/dprint.json')
end)

teardown(function()
vim.fn.delete(tmpdir, 'rf')
end)

it('can format', function()
local formatted = require('test.helper').run_fmt('dprint', 'ts', {
'const x=1;',
'function foo( ){return x}',
}, { cwd = tmpdir, tmpdir = tmpdir })
assert.is_true(#formatted > 0)
assert.is_truthy(formatted[1]:find('const x'))
end)
end)
21 changes: 21 additions & 0 deletions test/binary/hadolint_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
describe('hadolint', function()
it('can lint', function()
local helper = require('test.helper')
local bufnr, diagnostics = helper.run_lint('hadolint', 'dockerfile', {
[[FROM ubuntu]],
[[RUN apt-get install python]],
})
assert.is_true(#diagnostics > 0)
helper.assert_diag(diagnostics[1], {
bufnr = bufnr,
source = 'hadolint',
severity = vim.diagnostic.severity.WARN,
})
for _, d in ipairs(diagnostics) do
assert.equal(bufnr, d.bufnr)
assert.equal('hadolint', d.source)
assert.is_number(d.lnum)
assert.is_string(d.message)
end
end)
end)
22 changes: 22 additions & 0 deletions test/binary/ktlint_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('ktlint', function()
it('can lint', function()
local helper = require('test.helper')
local bufnr, diagnostics = helper.run_lint('ktlint', 'kt', {
'fun main() {',
' val x=1',
' println(x)',
'}',
})
assert.is_true(#diagnostics > 0)
helper.assert_diag(diagnostics[1], {
bufnr = bufnr,
source = 'ktlint',
})
for _, d in ipairs(diagnostics) do
assert.equal(bufnr, d.bufnr)
assert.equal('ktlint', d.source)
assert.is_number(d.lnum)
assert.is_string(d.message)
end
end)
end)
22 changes: 22 additions & 0 deletions test/binary/shellcheck_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('shellcheck', function()
it('can lint', function()
local helper = require('test.helper')
local bufnr, diagnostics = helper.run_lint('shellcheck', 'sh', {
[[#!/bin/sh]],
[[echo $FOO]],
})
assert.is_true(#diagnostics > 0)
helper.assert_diag(diagnostics[1], {
bufnr = bufnr,
source = 'shellcheck',
severity = vim.diagnostic.severity.INFO,
message_pat = 'Double quote',
})
for _, d in ipairs(diagnostics) do
assert.equal(bufnr, d.bufnr)
assert.equal('shellcheck', d.source)
assert.is_number(d.lnum)
assert.is_string(d.message)
end
end)
end)
9 changes: 9 additions & 0 deletions test/dotnet/csharpier_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('csharpier', function()
it('can format', function()
local formatted = require('test.helper').run_fmt('csharpier', 'cs', {
[[class A{void M(){int x=1;}}]],
})
assert.is_true(#formatted > 1)
assert.is_true(formatted[1]:find('class A') ~= nil)
end)
end)
Loading
Loading