Skip to content

Commit 96d2986

Browse files
committed
Add lua_ls_skip_versions
1 parent d8227e2 commit 96d2986

File tree

9 files changed

+152
-30
lines changed

9 files changed

+152
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
- name: Install dependencies
2727
run: python -m pip install '.'
2828
- name: Download LuaLs for Linux
29-
run: python sphinx_lua_ls/lua_ls.py linux x86_64 --runtime luals ~/lua_ls_release/ubuntu-latest
29+
run: python sphinx_lua_ls/lua_ls.py linux x86_64 --runtime luals --skip 3.16.0 ~/lua_ls_release/ubuntu-latest
3030
- name: Download LuaLs for Windows
31-
run: python sphinx_lua_ls/lua_ls.py win32 amd64 --runtime luals ~/lua_ls_release/windows-latest
31+
run: python sphinx_lua_ls/lua_ls.py win32 amd64 --runtime luals --skip 3.16.0 ~/lua_ls_release/windows-latest
3232
- name: Download LuaLs for MacOs
33-
run: python sphinx_lua_ls/lua_ls.py darwin arm --runtime luals ~/lua_ls_release/macos-latest
33+
run: python sphinx_lua_ls/lua_ls.py darwin arm --runtime luals --skip 3.16.0 ~/lua_ls_release/macos-latest
3434
- name: Download EmmyLua for Linux
3535
run: python sphinx_lua_ls/lua_ls.py linux x86_64 --runtime emmylua ~/lua_ls_release/ubuntu-latest
3636
- name: Download EmmyLua for Windows

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## [Unreleased]
44

5-
- Support Sphinx 9.
5+
- Added support Sphinx 9.
6+
7+
- Added ``lua_ls_skip_versions`` config option to selectively avoid certain
8+
language server releases.
69

710
## [3.7.0-post1] - 2025-11-14
811

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
```shell
1212
pip install -e . --group dev
13+
pip install -U sphinx
1314
```
1415

16+
> *Note:* our tests run with Sphinx 9, but some dependencies are not yet updated
17+
> for it; that's why you have to update Sphinx after installing it.
18+
1519
4. Install pre-commit hooks:
1620

1721
```shell

docs/source/settings.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ Settings
5252
For LuaLs, default value is ``4.0.0``, for EmmyLua it's ``2.0.0``.
5353
Use ``None`` to allow any version.
5454

55+
.. py:data:: lua_ls_skip_versions
56+
:type: list[str] | None
57+
58+
List of lua analyzer versions that shouldn't be used.
59+
60+
For example, if ``lua_ls_skip_versions = ["3.16"]``, language server release
61+
``3.16`` (including all ``3.16.x`` releases) will not be used.
62+
63+
This setting can be used to avoid broken releases without limiting max version
64+
of the lua analyzer.
65+
5566
.. py:data:: lua_ls_default_options
5667
:type: dict[str, str]
5768

@@ -99,12 +110,12 @@ Settings
99110
and :rst:dir:`lua:autoobject:class-signature` options.
100111

101112
.. py:data:: lua_ls_class_default_force_non_colon
102-
:type:
113+
:type: bool
103114

104115
If ``True``, Sphinx-LuaLs will remove ``self`` from class constructor's signature.
105116

106117
.. py:data:: lua_ls_class_default_force_return_self
107-
:type:
118+
:type: bool
108119

109120
If ``True``, Sphinx-LuaLs will replace class constructor's return type with ``self``.
110121

sphinx_lua_ls/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ def run_lua_ls(app: sphinx.application.Sphinx):
7070
max_version = "4.0.0"
7171
else:
7272
max_version = "2.0.0"
73+
skip_versions = domain.config.skip_versions
7374

7475
cwd = pathlib.Path.cwd()
7576
try:
7677
runner = sphinx_lua_ls.lua_ls.resolve(
7778
backend=domain.config.backend,
7879
min_version=min_version,
7980
max_version=max_version,
81+
skip_versions=skip_versions or [],
8082
cwd=root_dir,
8183
reporter=sphinx_lua_ls.lua_ls.SphinxProgressReporter(app.verbosity),
8284
install=domain.config.auto_install,
@@ -195,6 +197,7 @@ def setup(app: sphinx.application.Sphinx):
195197
app.add_config_value("lua_ls_auto_install_location", None, rebuild="")
196198
app.add_config_value("lua_ls_min_version", None, rebuild="env")
197199
app.add_config_value("lua_ls_max_version", "__auto__", rebuild="env")
200+
app.add_config_value("lua_ls_skip_versions", None, rebuild="env")
198201
app.add_config_value("lua_ls_lua_version", None, rebuild="html")
199202
app.add_config_value("lua_ls_default_options", None, rebuild="env")
200203
app.add_config_value("lua_ls_apidoc_roots", None, rebuild="")

sphinx_lua_ls/config.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
_logger = logging.getLogger("sphinx_lua_ls")
1515

1616
T = _t.TypeVar("T")
17+
A = _t.ParamSpec("A")
1718

1819

1920
@dataclass
@@ -25,6 +26,7 @@ class LuaDomainConfig:
2526
auto_install_location: pathlib.Path | None = None
2627
min_version: str | None = None
2728
max_version: str | None = None
29+
skip_versions: list[str] | None = None
2830
lua_version: str | None = None
2931
default_options: dict[str, _t.Any] = dataclasses.field(default_factory=dict)
3032
apidoc_default_options: dict[str, _t.Any] = dataclasses.field(default_factory=dict)
@@ -73,11 +75,17 @@ def _path(name: str, value, root: str | pathlib.Path) -> pathlib.Path:
7375
raise ConfigError(f"incorrect lua_ls_project_root: {e}") from None
7476

7577

76-
def _paths(name: str, value, root: str | pathlib.Path) -> list[pathlib.Path]:
78+
def _list(
79+
name: str,
80+
value,
81+
checker: _t.Callable[_t.Concatenate[str, object, A], T],
82+
*args: A.args,
83+
**kwargs: A.kwargs,
84+
) -> list[T]:
7785
if value is None:
7886
value = []
7987
_type(name, value, list)
80-
return [_path(f"{name}[{i}]", v, root) for i, v in enumerate(value)]
88+
return [checker(f"{name}[{i}]", v, *args, **kwargs) for i, v in enumerate(value)]
8189

8290

8391
def _options(name: str, value) -> dict[str, _t.Any]:
@@ -193,9 +201,10 @@ def set_options(app: sphinx.application.Sphinx):
193201
)
194202

195203
if config["lua_ls_project_directories"] is not None:
196-
domain_config.project_directories = _paths(
204+
domain_config.project_directories = _list(
197205
"lua_ls_project_directories",
198206
config["lua_ls_project_directories"],
207+
_path,
199208
domain_config.project_root,
200209
)
201210

@@ -221,6 +230,10 @@ def set_options(app: sphinx.application.Sphinx):
221230
if config["lua_ls_max_version"] != "__auto__"
222231
else "__auto__"
223232
)
233+
if config["lua_ls_skip_versions"] is not None:
234+
domain_config.skip_versions = _list(
235+
"lua_ls_skip_versions", config["lua_ls_skip_versions"], _version
236+
)
224237

225238
if config["lua_ls_lua_version"]:
226239
domain_config.lua_version = _str_choices(

0 commit comments

Comments
 (0)