Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/source/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Settings
.. py:data:: lua_ls_backend
:type: str

Controls which lua analyzer is used. Can be either ``"emmylua"`` or ``"luals"``.
Controls which lua analyzer is used. Can be either ``"emmylua"``, ``"luals"``, or ``"disable"``.
When set to ``"disable"``, no Lua files are analyzed, all language server related settings
are ignored, and :doc:`autodoc` does not work.

.. py:data:: lua_ls_auto_install
:type: bool
Expand Down
9 changes: 9 additions & 0 deletions sphinx_lua_ls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
def run_lua_ls(app: sphinx.application.Sphinx):
domain: sphinx_lua_ls.domain.LuaDomain = app.env.get_domain("lua") # type: ignore

if domain.config.backend == "disable":
return

root_dir = domain.config.project_root
project_directories = domain.config.project_directories
if project_directories is None:
Expand Down Expand Up @@ -130,6 +133,12 @@ def run_apidoc(
app: sphinx.application.Sphinx,
):
domain = _t.cast(sphinx_lua_ls.domain.LuaDomain, app.env.get_domain("lua"))
if domain.config.backend == "disable":
logger.warning(
"apidoc requested, but the language server backend is disabled",
type="lua-ls",
)
return
cwd = pathlib.Path.cwd()
for name, params in domain.config.apidoc_roots.items():
try:
Expand Down
4 changes: 4 additions & 0 deletions sphinx_lua_ls/autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,10 @@ class AutoObjectDirective(AutodocUtilsMixin):
doctype_override: str | None = None

def run(self):
if self.lua_domain.config.backend == "disable":
raise self.error(
"autoobject requested but the Lua language server is disabled"
)
self.prepare_options()

signatures: list[str] = []
Expand Down
8 changes: 5 additions & 3 deletions sphinx_lua_ls/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@dataclass
class LuaDomainConfig:
project_root: pathlib.Path
backend: _t.Literal["emmylua", "luals"] = "luals"
backend: _t.Literal["emmylua", "luals", "disable"] = "luals"
project_directories: list[pathlib.Path] | None = None
auto_install: bool = True
auto_install_location: pathlib.Path | None = None
Expand Down Expand Up @@ -188,9 +188,11 @@ def set_options(app: sphinx.application.Sphinx):

if config["lua_ls_backend"] is not None:
domain_config.backend = _t.cast(
_t.Literal["emmylua", "luals"],
_t.Literal["emmylua", "luals", "disable"],
_str_choices(
"lua_ls_backend", config["lua_ls_backend"], ["luals", "emmylua"]
"lua_ls_backend",
config["lua_ls_backend"],
["luals", "emmylua", "disable"],
),
)
else:
Expand Down