from pygls.server import LanguageServer from lsprotocol.types import ( TEXT_DOCUMENT_COMPLETION, CompletionItem, CompletionList, CompletionParams, ) server = LanguageServer("example-server", "v0.1") @server.feature(TEXT_DOCUMENT_COMPLETION) def completions(params: CompletionParams): items = [] document = server.workspace.get_document(params.text_document.uri) current_line = document.lines[params.position.line].strip() if current_line.endswith("hello."): items = [ CompletionItem(label="world"), CompletionItem(label="friend"), ] return CompletionList( is_incomplete=False, items=items, ) server.start_io()