diff options
Diffstat (limited to 'examples/hello-world/main.py')
-rw-r--r-- | examples/hello-world/main.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/hello-world/main.py b/examples/hello-world/main.py new file mode 100644 index 0000000..cb2c0e4 --- /dev/null +++ b/examples/hello-world/main.py @@ -0,0 +1,28 @@ +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() |