-
-
Notifications
You must be signed in to change notification settings - Fork 622
ci: lua language server and Makefile #2546
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
Changes from all commits
0d6b860
a2902e5
78bfdf8
df807c4
5a01aa8
1f2e52c
04aa5a2
8d9b108
eb856a5
931efb3
4e9ee61
48494be
10de5c2
fea0f04
c12a3af
a1e293f
820b7b3
b5de0c1
b60ea9c
edbf501
2356e3d
747854a
240ef77
1532885
4d836e8
7e3caf9
00fe0a9
7f94529
f6fe6b3
e51863e
4bd4717
824d7e7
99d4fbf
5e65115
95b9146
d353323
4198691
e14aa5a
eb9f7cd
e1fae69
5e62d1e
c50ccea
ed0c82f
828bbc8
fa7ebc2
a8cb50d
fcef6a1
1b509db
6b0fcc4
1a24ad8
2ad6aa5
b0f55dc
995d3cb
1aa2574
9311fd8
81b32ca
003752c
077d56e
59b34b8
d12dc49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/luals-out/ | ||
/luals/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env bash | ||
#!/bin/sh | ||
|
||
stylua . --check || exit 1 | ||
luacheck . || exit 1 | ||
make |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", | ||
"runtime.version" : "Lua 5.1", | ||
"workspace": { | ||
"library": [ | ||
"$VIMRUNTIME/lua/vim/lsp", | ||
"${3rd}/luv/library" | ||
] | ||
}, | ||
"diagnostics": { | ||
"libraryFiles": "Disable", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are many warnings in the libraries themselves. |
||
"globals": [ | ||
"vim" | ||
alex-courtis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,31 +4,76 @@ Thank you for contributing. | |
|
||
See [Development](https://github.com/nvim-tree/nvim-tree.lua/wiki/Development) for environment setup, tips and tools. | ||
|
||
## Styling and formatting | ||
# Tools | ||
|
||
Code is formatted using luacheck, and linted using stylua. | ||
You can install these with: | ||
Following are used during CI and strongly recommended during local development. | ||
|
||
```bash | ||
luarocks install luacheck | ||
cargo install stylua | ||
Lint: [luacheck](https://github.com/lunarmodules/luacheck/) | ||
|
||
Style: [StyLua](https://github.com/JohnnyMorganz/StyLua) | ||
|
||
Language server: [luals](https://luals.github.io) | ||
|
||
You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks` | ||
|
||
# Quality | ||
|
||
The following quality checks are mandatory and are performed during CI. They run on the entire `lua` directory and return 1 on any failure. | ||
|
||
You can run them all via `make` or `make all` | ||
|
||
You can setup git hooks to run all checks by running `scripts/setup-hooks.sh` | ||
|
||
## lint | ||
|
||
1. Runs luacheck quietly using `.luacheck` settings | ||
|
||
```sh | ||
make lint | ||
``` | ||
|
||
## style | ||
|
||
1. Runs stylua using `.stylua.toml` settings | ||
1. Runs `scripts/doc-comments.sh` to validate annotated documentation | ||
|
||
```sh | ||
make style | ||
``` | ||
|
||
You can automatically fix stylua issues via: | ||
|
||
```sh | ||
make style-fix | ||
``` | ||
|
||
## check | ||
|
||
1. Runs the checks that the LSP lua language server runs inside nvim using `.luarc.json` via `scripts/luals-check.sh` | ||
|
||
```sh | ||
make check | ||
``` | ||
|
||
You can setup the git hooks by running `scripts/setup-hooks.sh`. | ||
Assumes `$VIMRUNTIME` is `/usr/share/nvim/runtime`. Adjust as necessary e.g. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added to wiki as well: https://github.com/nvim-tree/nvim-tree.lua/wiki/Development#lua-language-server |
||
## Adding new actions | ||
```sh | ||
VIMRUNTIME="/my/path/to/runtime" make check | ||
``` | ||
|
||
# Adding New Actions | ||
|
||
To add a new action, add a file in `actions/name-of-the-action.lua`. You should export a `setup` function if some configuration is needed. | ||
Once you did, you should run the `scripts/update-help.sh`. | ||
|
||
## Documentation | ||
Once you did, you should run `make help-update` | ||
|
||
# Documentation | ||
|
||
When adding new options, you should declare the defaults in the main `nvim-tree.lua` file. | ||
Once you did, you should run the `scripts/update-help.sh`. | ||
|
||
Documentation for options should also be added to `nvim-tree-opts` in `doc/nvim-tree-lua.txt` | ||
|
||
## Pull Request | ||
# Pull Request | ||
|
||
Please reference any issues in the description e.g. "resolves #1234". | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
all: lint style check | ||
|
||
# | ||
# mandatory checks | ||
# | ||
lint: luacheck | ||
|
||
style: stylua style-doc | ||
|
||
check: luals | ||
|
||
# | ||
# subtasks | ||
# | ||
luacheck: | ||
luacheck -q lua | ||
|
||
stylua: | ||
stylua lua --check | ||
|
||
style-doc: | ||
scripts/doc-comments.sh | ||
|
||
luals: | ||
scripts/luals-check.sh | ||
|
||
# | ||
# fixes | ||
# | ||
style-fix: | ||
stylua lua | ||
|
||
# | ||
# utility | ||
# | ||
help-update: | ||
scripts/help-update.sh | ||
|
||
# | ||
# CI | ||
# | ||
help-check: help-update | ||
git diff --exit-code doc/nvim-tree-lua.txt | ||
|
||
|
||
.PHONY: all lint style check luacheck stylua style-doc luals style-fix help-update help-check | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
|
||
# Performs a lua-language-server check on all files. | ||
# luals-out/check.json will be produced on any issues, returning 1. | ||
# Outputs only check.json to stdout, all other messages to stderr, to allow jq etc. | ||
# $VIMRUNTIME specifies neovim runtime path, defaults to "/usr/share/nvim/runtime" if unset. | ||
|
||
if [ -z "${VIMRUNTIME}" ]; then | ||
export VIMRUNTIME="/usr/share/nvim/runtime" | ||
fi | ||
|
||
DIR_SRC="lua" | ||
DIR_OUT="luals-out" | ||
|
||
# clear output | ||
rm -rf "${DIR_OUT}" | ||
mkdir "${DIR_OUT}" | ||
|
||
# execute inside lua to prevent luals itself from being checked | ||
OUT=$(lua-language-server --check="${DIR_SRC}" --configpath="${PWD}/.luarc.json" --checklevel=Information --logpath="${DIR_OUT}" --loglevel=error) | ||
RC=$? | ||
|
||
echo "${OUT}" >&2 | ||
|
||
if [ $RC -ne 0 ]; then | ||
echo "failed with RC=$RC" | ||
exit $RC | ||
fi | ||
|
||
# any output is a fail | ||
case "${OUT}" in | ||
*Diagnosis\ complete*) | ||
if [ -f "${DIR_OUT}/check.json" ]; then | ||
cat "${DIR_OUT}/check.json" | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Baby steps: just lsp and uv for now.
cmd, api and fn will take some time.