66from typing import Any , Callable , List , Optional , Tuple
77
88from lsprotocol .types import (
9- ALL_TYPES_MAP ,
109 INITIALIZE ,
1110 INITIALIZED ,
1211 TEXT_DOCUMENT_COMPLETION ,
2625 MarkupKind ,
2726 Position ,
2827 Range ,
28+ SaveOptions ,
2929 TextDocumentPositionParams ,
30- TextDocumentSaveRegistrationOptions ,
3130 TextEdit ,
3231)
3332from pygls .server import LanguageServer
3736logger = logging .getLogger (__name__ )
3837
3938
40- # fix pygls bug
41- ALL_TYPES_MAP ["TextDocumentSaveOptions" ] = TextDocumentSaveRegistrationOptions
42-
43-
4439class CMakeLanguageServer (LanguageServer ):
4540 _api : Optional [API ]
4641
@@ -159,7 +154,7 @@ def completions(params: CompletionParams) -> CompletionList:
159154 def formatting (
160155 params : DocumentFormattingParams ,
161156 ) -> Optional [List [TextEdit ]]:
162- doc = self .workspace .get_document (params .text_document .uri )
157+ doc = self .workspace .get_text_document (params .text_document .uri )
163158 content = doc .source
164159 formatted = subprocess .check_output (
165160 ["cmake-format" , "-" ],
@@ -206,7 +201,7 @@ def hover(params: TextDocumentPositionParams) -> Optional[Hover]:
206201 @self .thread ()
207202 @self .feature (
208203 TEXT_DOCUMENT_DID_SAVE ,
209- TextDocumentSaveRegistrationOptions (include_text = False ),
204+ SaveOptions (include_text = False ),
210205 )
211206 @self .feature (INITIALIZED )
212207 def run_cmake (* args : Any ) -> None :
@@ -216,14 +211,14 @@ def run_cmake(*args: Any) -> None:
216211 self ._api .read_reply ()
217212
218213 def _cursor_function (self , uri : str , position : Position ) -> Optional [str ]:
219- doc = self .workspace .get_document (uri )
214+ doc = self .workspace .get_text_document (uri )
220215 lines = doc .source .split ("\n " )[: position .line + 1 ]
221216 lines [- 1 ] = lines [- 1 ][: position .character - 1 ].strip ()
222217 words = re .split (r"[\s\n()]+" , "\n " .join (lines ))
223218 return words [- 1 ] if words else None
224219
225220 def _cursor_line (self , uri : str , position : Position ) -> str :
226- doc = self .workspace .get_document (uri )
221+ doc = self .workspace .get_text_document (uri )
227222 content = doc .source
228223 line = content .split ("\n " )[position .line ]
229224 return str (line )
@@ -260,4 +255,4 @@ def main() -> None:
260255
261256 logging .basicConfig (level = logging .INFO )
262257 logging .getLogger ("pygls" ).setLevel (logging .WARNING )
263- CMakeLanguageServer ("cmake-language-server" , __version__ ).start_io () # type: ignore
258+ CMakeLanguageServer ("cmake-language-server" , __version__ ).start_io ()
0 commit comments