2020-09-05 23:22:27 +00:00
|
|
|
## Requirements
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
- [Neovim](https://neovim.io/) :P
|
2020-09-05 23:22:27 +00:00
|
|
|
- Documentation is generated by `scripts/docgen.lua`.
|
|
|
|
- Only works on unix, you can ignore it on Windows.
|
|
|
|
- Lint task requires [luacheck](https://github.com/luarocks/luacheck#installation).
|
|
|
|
|
|
|
|
## Lint
|
|
|
|
|
|
|
|
PRs are checked with Luacheck. To run the linter locally:
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-09-05 23:22:27 +00:00
|
|
|
make lint
|
|
|
|
|
|
|
|
## Generating docs
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
> Note: Github Actions automatically generates the docs, so only modify
|
|
|
|
> `README_template.md` or the `docs` object on the server config.
|
|
|
|
> Don't modify `README.md` directly.
|
2019-11-14 23:20:31 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
To preview the generated `README.md` locally, run `scripts/docgen.lua` from
|
|
|
|
`nvim` (from the project root):
|
2019-11-14 23:20:31 +00:00
|
|
|
|
2019-12-08 06:10:33 +00:00
|
|
|
nvim -R -Es +'set rtp+=$PWD' +'luafile scripts/docgen.lua'
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-09-05 23:22:27 +00:00
|
|
|
## Configs
|
2019-11-14 23:20:31 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
The `configs` module is a singleton where configs are defined. In `vim.validate`
|
|
|
|
parlance here is the "spec":
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
configs.SERVER_NAME = {
|
|
|
|
default_config = {'t'};
|
|
|
|
on_new_config = {'f', true};
|
|
|
|
on_attach = {'f', true};
|
|
|
|
commands = {'t', true};
|
|
|
|
docs = {'t', true};
|
|
|
|
}
|
|
|
|
docs = {
|
|
|
|
description = {'s', true};
|
|
|
|
default_config = {'t', true};
|
|
|
|
}
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
- Keys in `docs.default_config` match those of
|
2020-01-31 08:00:50 +00:00
|
|
|
`configs.SERVER_NAME.default_config`, and can be used to specify custom
|
2019-12-08 06:10:33 +00:00
|
|
|
documentation. This is useful for functions, whose docs cannot be easily
|
|
|
|
auto-generated.
|
2020-01-31 10:20:41 +00:00
|
|
|
- `commands` is a map of `name:definition` key:value pairs, where `definition`
|
|
|
|
is a list whose first value is a function implementing the command and the
|
|
|
|
rest are either array values which will be formed into flags for the command
|
|
|
|
or special keys like `description`. Example:
|
|
|
|
```
|
2019-11-14 08:50:01 +00:00
|
|
|
commands = {
|
|
|
|
TexlabBuild = {
|
|
|
|
function()
|
|
|
|
buf_build(0)
|
|
|
|
end;
|
2019-11-14 08:51:30 +00:00
|
|
|
"-range";
|
2019-11-14 08:50:01 +00:00
|
|
|
description = "Build the current buffer";
|
|
|
|
};
|
|
|
|
};
|
2020-01-31 10:20:41 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The `configs.__newindex` metamethod consumes the config definition and returns
|
|
|
|
an object with a `setup()` method, to be invoked by users:
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-09-06 08:49:21 +00:00
|
|
|
require'lspconfig'.SERVER_NAME.setup{}
|
2019-11-14 08:50:01 +00:00
|
|
|
|
2020-01-31 10:20:41 +00:00
|
|
|
After you set `configs.SERVER_NAME` you can add arbitrary language-specific
|
|
|
|
functions to it if necessary.
|
2019-11-14 08:50:01 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2020-01-31 08:00:50 +00:00
|
|
|
configs.texlab.buf_build = buf_build
|