fix: add python 3.14 support, adopt pygls >=2.0.0 api

This commit is contained in:
2026-03-14 23:56:20 +01:00
parent 3e5e86736c
commit 46bc1aaa84
10 changed files with 40 additions and 115 deletions

1
.github/CODEOWNERS vendored
View File

@@ -1 +0,0 @@
* @regen100

View File

@@ -1,30 +0,0 @@
name: Publish
on:
push:
tags:
- v*
permissions:
contents: write
jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
- name: Build
run: |
pdm build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}
- name: Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true

View File

@@ -1,54 +0,0 @@
name: Tests
on:
pull_request:
push:
branches:
- master
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-22.04, windows-2022]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python }}
cache: true
- name: Setup VC
uses: ilammy/msvc-dev-cmd@v1
if: contains(matrix.os, 'windows')
- name: Install CMake
if: contains(matrix.os, 'ubuntu')
run: |
CMAKE_VERSION=3.25.1
curl -sSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz | tar xz
sudo cp -rT cmake-${CMAKE_VERSION}-linux-x86_64 /usr/local
- name: Install dependencies
run: |
cmake --version
python -m pip install --upgrade setuptools pip wheel
python -m pip install tox tox-gh-actions
- name: Test with tox
run: |
tox
env:
os: ${{ matrix.os }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
name: Python ${{ matrix.python }} on ${{ matrix.os }}
fail_ci_if_error: false

5
.gitignore vendored
View File

@@ -1,5 +1,8 @@
cmake_language_server/version.py cmake_language_server/version.py
.venv/
pyrightconfig.json
/build/ /build/
/dist/ /dist/
__pycache__/ __pycache__/
@@ -11,3 +14,5 @@ coverage.xml
.pdm-python .pdm-python
__pypackages__/ __pypackages__/
.pdm-build/

View File

@@ -31,7 +31,7 @@ from lsprotocol.types import (
TextDocumentPositionParams, TextDocumentPositionParams,
TextEdit, TextEdit,
) )
from pygls.server import LanguageServer from pygls.lsp.server import LanguageServer
from .api import API from .api import API

36
pdm.lock generated
View File

@@ -4,17 +4,20 @@
[metadata] [metadata]
groups = ["default", "dev", "lint"] groups = ["default", "dev", "lint"]
strategy = ["cross_platform"] strategy = ["cross_platform"]
lock_version = "4.4.1" lock_version = "4.5.0"
content_hash = "sha256:801e3af66b4127c047d051c3b10a9b5e0b793d27f5eab4fd0b1514cfdda34803" content_hash = "sha256:ef24aee91e46f0db41b85228c16cb2703f20aff76eb93225d2a982304959120e"
[[metadata.targets]]
requires_python = ">=3.10.0,<3.16"
[[package]] [[package]]
name = "attrs" name = "attrs"
version = "23.2.0" version = "25.4.0"
requires_python = ">=3.7" requires_python = ">=3.9"
summary = "Classes Without Boilerplate" summary = "Classes Without Boilerplate"
files = [ files = [
{file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, {file = "attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373"},
{file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, {file = "attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11"},
] ]
[[package]] [[package]]
@@ -278,16 +281,16 @@ files = [
[[package]] [[package]]
name = "lsprotocol" name = "lsprotocol"
version = "2023.0.1" version = "2025.0.0"
requires_python = ">=3.7" requires_python = ">=3.8"
summary = "Python implementation of the Language Server Protocol." summary = "Python types for Language Server Protocol."
dependencies = [ dependencies = [
"attrs>=21.3.0", "attrs>=21.3.0",
"cattrs!=23.2.1", "cattrs!=23.2.1",
] ]
files = [ files = [
{file = "lsprotocol-2023.0.1-py3-none-any.whl", hash = "sha256:c75223c9e4af2f24272b14c6375787438279369236cd568f596d4951052a60f2"}, {file = "lsprotocol-2025.0.0-py3-none-any.whl", hash = "sha256:f9d78f25221f2a60eaa4a96d3b4ffae011b107537facee61d3da3313880995c7"},
{file = "lsprotocol-2023.0.1.tar.gz", hash = "sha256:cc5c15130d2403c18b734304339e51242d3018a05c4f7d0f198ad6e0cd21861d"}, {file = "lsprotocol-2025.0.0.tar.gz", hash = "sha256:e879da2b9301e82cfc3e60d805630487ac2f7ab17492f4f5ba5aaba94fe56c29"},
] ]
[[package]] [[package]]
@@ -412,16 +415,17 @@ files = [
[[package]] [[package]]
name = "pygls" name = "pygls"
version = "1.3.1" version = "2.0.1"
requires_python = ">=3.8" requires_python = ">=3.9"
summary = "A pythonic generic language server (pronounced like 'pie glass')" summary = "A pythonic generic language server (pronounced like 'pie glass')"
dependencies = [ dependencies = [
"attrs>=24.3.0",
"cattrs>=23.1.2", "cattrs>=23.1.2",
"lsprotocol==2023.0.1", "lsprotocol==2025.0.0",
] ]
files = [ files = [
{file = "pygls-1.3.1-py3-none-any.whl", hash = "sha256:6e00f11efc56321bdeb6eac04f6d86131f654c7d49124344a9ebb968da3dd91e"}, {file = "pygls-2.0.1-py3-none-any.whl", hash = "sha256:d29748042cea5bedc98285eb3e2c0c60bf3fc73786319519001bf72bbe8f36cc"},
{file = "pygls-1.3.1.tar.gz", hash = "sha256:140edceefa0da0e9b3c533547c892a42a7d2fd9217ae848c330c53d266a55018"}, {file = "pygls-2.0.1.tar.gz", hash = "sha256:2f774a669fbe2ece977d302786f01f9b0c5df7d0204ea0fa371ecb08288d6b86"},
] ]
[[package]] [[package]]

View File

@@ -6,9 +6,9 @@ authors = [
{name = "Regen"}, {name = "Regen"},
] ]
dependencies = [ dependencies = [
"pygls>=1.1.1", "pygls>=2.0.0",
] ]
requires-python = ">=3.8.0,<3.14" requires-python = ">=3.10.0,<3.16"
readme = "README.md" readme = "README.md"
license = {text = "MIT"} license = {text = "MIT"}
keywords = ["cmake", "completion", "vim", "lsp"] keywords = ["cmake", "completion", "vim", "lsp"]

View File

@@ -7,7 +7,7 @@ from typing import Iterable, Tuple
import pytest import pytest
from lsprotocol.types import EXIT, SHUTDOWN from lsprotocol.types import EXIT, SHUTDOWN
from pygls.server import LanguageServer from pygls.lsp.server import LanguageServer
from cmake_language_server.server import CMakeLanguageServer from cmake_language_server.server import CMakeLanguageServer
@@ -54,7 +54,7 @@ def client_server() -> Iterable[Tuple[LanguageServer, CMakeLanguageServer]]:
if hasattr(client.loop, "_signal_handlers"): if hasattr(client.loop, "_signal_handlers"):
client.loop._signal_handlers.clear() client.loop._signal_handlers.clear()
client.lsp.send_request(SHUTDOWN) # type:ignore[no-untyped-call] client.protocol.send_request(SHUTDOWN) # type:ignore[no-untyped-call]
client.lsp.notify(EXIT) client.protocol.notify(EXIT)
client_thread.join() client_thread.join()
server_thread.join() server_thread.join()

View File

@@ -27,7 +27,7 @@ from lsprotocol.types import (
TextDocumentIdentifier, TextDocumentIdentifier,
TextDocumentItem, TextDocumentItem,
) )
from pygls.server import LanguageServer from pygls.lsp.server import LanguageServer
from cmake_language_server.server import CMakeLanguageServer from cmake_language_server.server import CMakeLanguageServer
@@ -38,7 +38,7 @@ def _init(client: LanguageServer, root: Path) -> None:
retry = 3 retry = 3
while retry > 0: while retry > 0:
try: try:
client.lsp.send_request( # type:ignore[no-untyped-call] client.protocol.send_request( # type:ignore[no-untyped-call]
INITIALIZE, INITIALIZE,
InitializeParams( InitializeParams(
process_id=1234, process_id=1234,
@@ -56,7 +56,7 @@ def _open(client: LanguageServer, path: Path, text: Optional[str] = None) -> Non
if text is None: if text is None:
text = path.read_text() text = path.read_text()
client.lsp.notify( client.protocol.notify(
TEXT_DOCUMENT_DID_OPEN, TEXT_DOCUMENT_DID_OPEN,
DidOpenTextDocumentParams( DidOpenTextDocumentParams(
text_document=TextDocumentItem( text_document=TextDocumentItem(
@@ -81,7 +81,7 @@ def _test_completion(
position=Position(line=0, character=len(content)), position=Position(line=0, character=len(content)),
context=context, context=context,
) )
ret = client.lsp.send_request( # type:ignore[no-untyped-call] ret = client.protocol.send_request( # type:ignore[no-untyped-call]
TEXT_DOCUMENT_COMPLETION, params TEXT_DOCUMENT_COMPLETION, params
).result(timeout=CALL_TIMEOUT) ).result(timeout=CALL_TIMEOUT)
assert isinstance(ret, CompletionList) assert isinstance(ret, CompletionList)
@@ -107,7 +107,7 @@ def test_workspace_did_change_configuration(
old_api = server._api old_api = server._api
client.lsp.notify( client.protocol.notify(
WORKSPACE_DID_CHANGE_CONFIGURATION, WORKSPACE_DID_CHANGE_CONFIGURATION,
DidChangeConfigurationParams( DidChangeConfigurationParams(
settings={"initialization_options": {"buildDirectory": "c_build"}} settings={"initialization_options": {"buildDirectory": "c_build"}}
@@ -169,7 +169,7 @@ def test_formatting(
_init(client, datadir) _init(client, datadir)
path = datadir / "CMakeLists.txt" path = datadir / "CMakeLists.txt"
_open(client, path, "a ( b c ) ") _open(client, path, "a ( b c ) ")
response = client.lsp.send_request( # type:ignore[no-untyped-call] response = client.protocol.send_request( # type:ignore[no-untyped-call]
TEXT_DOCUMENT_FORMATTING, TEXT_DOCUMENT_FORMATTING,
DocumentFormattingParams( DocumentFormattingParams(
text_document=TextDocumentIdentifier(uri=path.as_uri()), text_document=TextDocumentIdentifier(uri=path.as_uri()),
@@ -186,7 +186,7 @@ def test_hover(
_init(client, datadir) _init(client, datadir)
path = datadir / "CMakeLists.txt" path = datadir / "CMakeLists.txt"
_open(client, path, "project()") _open(client, path, "project()")
response = client.lsp.send_request( # type:ignore[no-untyped-call] response = client.protocol.send_request( # type:ignore[no-untyped-call]
TEXT_DOCUMENT_HOVER, TEXT_DOCUMENT_HOVER,
HoverParams( HoverParams(
text_document=TextDocumentIdentifier(uri=path.as_uri()), text_document=TextDocumentIdentifier(uri=path.as_uri()),

View File

@@ -1,5 +1,5 @@
[tox] [tox]
env_list = py{39,310,311,312,313} env_list = py{39,310,311,312,313,314}
isolated_build = True isolated_build = True
passenv = * passenv = *
setenv = setenv =
@@ -12,6 +12,7 @@ python =
3.11: py311 3.11: py311
3.12: py312 3.12: py312
3.13: py313 3.13: py313
3.14: py314
[testenv] [testenv]
allowlist_externals = allowlist_externals =