-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add `make diagnose` which prints out all LSP diagnostics to stdout. It is also CI aware, in which case it will create CI annotations (but there's no workflow for it yet). - Cleanup Makefile
- Loading branch information
Showing
2 changed files
with
78 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,54 @@ | ||
pandocrepo = https://github.com/kdheepak/panvimdoc | ||
pandocdir = misc/panvimdoc | ||
TEST_DIR = test/github-theme | ||
PLENARY_DIR = test/plenary | ||
PLENARY_URL = https://github.com/nvim-lua/plenary.nvim/ | ||
pandocrepo ::= https://github.com/kdheepak/panvimdoc | ||
pandocdir ::= misc/panvimdoc | ||
TEST_DIR ::= test/github-theme | ||
PLENARY_DIR ::= test/plenary | ||
PLENARY_URL ::= https://github.com/nvim-lua/plenary.nvim/ | ||
|
||
root_dir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
root_dir ::= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
.PHONY : all | ||
.PHONY: all docgen test check fmt diagnose | ||
all: docgen test check | ||
|
||
.PHONY : docgen | ||
docgen: $(pandocdir) | ||
@pandoc \ | ||
--citeproc \ | ||
--shift-heading-level-by=0 \ | ||
--metadata=project:github-nvim-theme \ | ||
--metadata=vimversion:8.0 \ | ||
--metadata=toc:true \ | ||
--metadata="description:Github's Neovim themes" \ | ||
--metadata=dedupsubheadings:true \ | ||
--metadata=ignorerawblocks:true \ | ||
--metadata=docmapping:true \ | ||
--metadata=docmappingproject:true \ | ||
--metadata=treesitter:true \ | ||
--metadata=incrementheadinglevelby:0 \ | ||
--lua-filter=misc/panvimdoc/scripts/skip-blocks.lua \ | ||
--lua-filter=misc/panvimdoc/scripts/include-files.lua \ | ||
-t misc/panvimdoc/scripts/panvimdoc.lua \ | ||
-o doc/github-nvim-theme.txt \ | ||
Usage.md | ||
@pandoc \ | ||
--citeproc \ | ||
--shift-heading-level-by=0 \ | ||
--metadata=project:github-nvim-theme \ | ||
--metadata=vimversion:8.0 \ | ||
--metadata=toc:true \ | ||
--metadata="description:Github's Neovim themes" \ | ||
--metadata=dedupsubheadings:true \ | ||
--metadata=ignorerawblocks:true \ | ||
--metadata=docmapping:true \ | ||
--metadata=docmappingproject:true \ | ||
--metadata=treesitter:true \ | ||
--metadata=incrementheadinglevelby:0 \ | ||
--lua-filter=misc/panvimdoc/scripts/skip-blocks.lua \ | ||
--lua-filter=misc/panvimdoc/scripts/include-files.lua \ | ||
-t misc/panvimdoc/scripts/panvimdoc.lua \bu | ||
-o doc/github-nvim-theme.txt \ | ||
Usage.md | ||
|
||
$(pandocdir): | ||
git clone --depth=1 --no-single-branch $(pandocrepo) $(pandocdir) | ||
@rm -rf doc/panvimdoc/.git | ||
|
||
.PHONY : test | ||
test: $(PLENARY_DIR) | ||
nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u test/minimal_init.vim \ | ||
-c "PlenaryBustedDirectory $(TEST_DIR) { minimal_init = './test/minimal_init.vim', sequential = true }" | ||
--headless \ | ||
--noplugin \ | ||
-u test/minimal_init.vim \ | ||
-c "PlenaryBustedDirectory $(TEST_DIR) { minimal_init = './test/minimal_init.vim', sequential = true }" | ||
|
||
$(PLENARY_DIR): | ||
git clone --depth=1 --no-single-branch $(PLENARY_URL) $(PLENARY_DIR) | ||
@rm -rf $(PLENARY_DIR)/.git | ||
|
||
.PHONY : check | ||
check : | ||
check: | ||
stylua --check lua/ test -f ./stylua.toml | ||
|
||
.PHONY : fmt | ||
fmt : | ||
fmt: | ||
stylua lua/ test/ -f ./stylua.toml | ||
|
||
diagnose: | ||
scripts/diagnose Hint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
# One of: Error, Warning, Information, or Hint | ||
level="$1" | ||
|
||
export VIMRUNTIME="${VIMRUNTIME-"$(nvim -i NONE -es <<<'lua io.write(vim.env.VIMRUNTIME)')"}" | ||
export LUA_LS="${LUA_LS-"$(which lua-language-server)"}" | ||
|
||
# Add vim's stdlib to library files, and never diagnose lib files (since ALL | ||
# files will be `Opened` by the lsp to do the check). | ||
extcfg=' | ||
{ | ||
workspace: { | ||
library: [ $ENV.VIMRUNTIME, .workspace.library[] ] | ||
}, | ||
diagnostics: { ignoredFiles: "Disable", libraryFiles: "Disable" } | ||
} | ||
' | ||
|
||
jq=' | ||
to_entries[] | ||
| (.key | ltrimstr("file://") | ltrimstr($ENV.PWD)) as $f | ||
| .value[] | ||
| . as {range: {start: {line: $l, character: $c}, end: {line: $eL, character: $eC}}} | ||
| [null, "error", "warning", "notice", "notice"][.severity] as $s | ||
| "::\($s) file=\($f),line=\($l),col=\($c),endLine=\($eL),endColumn=\($eC),title=\(.code)::\(.message)" | ||
' | ||
|
||
"$LUA_LS" \ | ||
--check="$PWD" \ | ||
--checklevel="$level" \ | ||
--logpath=.log \ | ||
--metapath=.meta \ | ||
--configpath=<(jq ". * $extcfg" .luarc.json) | ||
|
||
if [ "${CI-no}" = no ]; then | ||
jq -r 'to_entries[] | "\(.key):\(.value[] | "\(.range.start.line): \(.message)")", ""' .log/check.json | ||
else | ||
jq -r "$jq" .log/check.json | ||
fi | ||
|
||
[ "$(jq 'isempty(.[]?)' .log/check.json)" = true ] || exit 1 |