Skip to content

Commit c4827f0

Browse files
committed
Add lua_ls_max_version
1 parent 03ea989 commit c4827f0

File tree

5 files changed

+129
-32
lines changed

5 files changed

+129
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
They also allow overriding object's signature, which may be useful when
1111
automatically generated signature is too long.
1212

13+
- Added `lua_ls_max_version` config option to safeguard against incompatible changes
14+
to documentation export format.
15+
1316
## [3.4.0]
1417

1518
- **Potential breaking change:** use `confdir` instead of `srcdir` as base path

docs/source/settings.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,21 @@ Settings
3636
.. py:data:: lua_ls_min_version
3737
:type: str
3838

39-
Controls the minimal version of the used lua analyzer.
39+
Controls the minimum version of the used lua analyzer.
40+
41+
Analyzer version should be greater than or equal to this version.
42+
43+
For LuaLs, default value is ``3.0.0``, for EmmyLua it's ``0.11.0``.
44+
45+
.. py:data:: lua_ls_max_version
46+
:type: str | None
47+
48+
Controls the maximum version of the used lua analyzer.
49+
50+
Analyzer version should be strictly less than this version.
51+
52+
For LuaLs, default value is ``4.0.0``, for EmmyLua it's ``2.0.0``.
53+
Use ``None`` to allow any version.
4054

4155
.. py:data:: lua_ls_default_options
4256
:type: dict[str, str]

sphinx_lua_ls/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ def run_lua_ls(app: sphinx.application.Sphinx):
6464
min_version = "3.0.0"
6565
else:
6666
min_version = "0.11.0"
67+
max_version = domain.config.max_version
68+
if max_version == "__auto__":
69+
if domain.config.backend == "luals":
70+
max_version = "4.0.0"
71+
else:
72+
max_version = "2.0.0"
6773

6874
cwd = pathlib.Path.cwd()
6975
try:
7076
runner = sphinx_lua_ls.lua_ls.resolve(
7177
backend=domain.config.backend,
7278
min_version=min_version,
79+
max_version=max_version,
7380
cwd=root_dir,
7481
reporter=sphinx_lua_ls.lua_ls.SphinxProgressReporter(app.verbosity),
7582
install=domain.config.auto_install,
@@ -187,6 +194,7 @@ def setup(app: sphinx.application.Sphinx):
187194
app.add_config_value("lua_ls_auto_install", True, rebuild="")
188195
app.add_config_value("lua_ls_auto_install_location", None, rebuild="")
189196
app.add_config_value("lua_ls_min_version", None, rebuild="env")
197+
app.add_config_value("lua_ls_max_version", "__auto__", rebuild="env")
190198
app.add_config_value("lua_ls_lua_version", None, rebuild="html")
191199
app.add_config_value("lua_ls_default_options", None, rebuild="env")
192200
app.add_config_value("lua_ls_apidoc_roots", None, rebuild="")

sphinx_lua_ls/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class LuaDomainConfig:
2424
auto_install: bool = True
2525
auto_install_location: pathlib.Path | None = None
2626
min_version: str | None = None
27+
max_version: str | None = None
2728
lua_version: str | None = None
2829
default_options: dict[str, _t.Any] = dataclasses.field(default_factory=dict)
2930
apidoc_default_options: dict[str, _t.Any] = dataclasses.field(default_factory=dict)
@@ -214,6 +215,10 @@ def set_options(app: sphinx.application.Sphinx):
214215
domain_config.min_version = _version(
215216
"lua_ls_min_version", config["lua_ls_min_version"]
216217
)
218+
if config["lua_ls_max_version"] is not None:
219+
domain_config.max_version = _version(
220+
"lua_ls_max_version", config["lua_ls_max_version"]
221+
)
217222

218223
if config["lua_ls_lua_version"]:
219224
domain_config.lua_version = _str_choices(

0 commit comments

Comments
 (0)