Skip to content

Commit 13765da

Browse files
authored
fix: Make lsp an optional dependency (#492)
1 parent b6ce999 commit 13765da

File tree

3 files changed

+223
-203
lines changed

3 files changed

+223
-203
lines changed

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ dependencies = [
7070
"numpy>=2.2.2",
7171
"mcp[cli]",
7272
"neo4j",
73-
"pygls>=2.0.0a2",
74-
"lsprotocol==2024.0.0b1",
75-
"attrs>=25.1.0",
7673
]
7774

7875
license = { text = "Apache-2.0" }
@@ -120,6 +117,7 @@ types = [
120117
"types-requests>=2.32.0.20241016",
121118
"types-toml>=0.10.8.20240310",
122119
]
120+
lsp = ["pygls>=2.0.0a2", "lsprotocol==2024.0.0b1", "attrs>=25.1.0"]
123121
[tool.uv]
124122
cache-keys = [{ git = { commit = true, tags = true } }]
125123
dev-dependencies = [
@@ -162,7 +160,6 @@ dev-dependencies = [
162160
"pytest-lsp>=1.0.0b1",
163161
]
164162

165-
166163
[tool.uv.workspace]
167164
exclude = ["codegen-examples"]
168165

src/codegen/cli/commands/lsp/lsp.py

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

33
import click
44

5-
from codegen.extensions.lsp.lsp import server
5+
logger = logging.getLogger(__name__)
66

77

88
@click.command(name="lsp")
99
def lsp_command():
10+
try:
11+
from codegen.extensions.lsp.lsp import server
12+
except ImportError:
13+
logger.exception("LSP is not installed. Please install it with `uv tool install codegen[lsp]`")
14+
return
1015
logging.basicConfig(level=logging.INFO)
1116
server.start_io()

0 commit comments

Comments
 (0)