some shite WIP

This commit is contained in:
Ivar Fatland
2026-04-30 20:41:50 +02:00
parent 47c5b39af5
commit 9ff13e3007
+26 -3
View File
@@ -1,13 +1,23 @@
from dataclasses import dataclass
from pathlib import Path
from typing import final
from pygls.lsp.server import LanguageServer from pygls.lsp.server import LanguageServer
from lsprotocol import types from lsprotocol import types
ls = LanguageServer("ctags-ls", "v0.1") ls = LanguageServer("ctags-ls", "v0.1")
@ls.feature(types.TEXT_DOCUMENT_COMPLETION) @ls.feature(
types.TEXT_DOCUMENT_COMPLETION,
types.CompletionOptions(trigger_characters=["."])
)
def completions(params: types.CompletionParams): def completions(params: types.CompletionParams):
items = [] items = [
types.CompletionItem(label="foo"),
types.CompletionItem(label="bar"),
types.CompletionItem(label="baz"),
]
document = ls.workspace.get_text_document(params.text_document.uri) document = ls.workspace.get_text_document(params.text_document.uri)
current_line = document.lines[params.position.line].strip() current_line = document.lines[params.position.line][:params.position.character]
if current_line.endswith("hello."): if current_line.endswith("hello."):
items = [ items = [
types.CompletionItem(label="world"), types.CompletionItem(label="world"),
@@ -17,3 +27,16 @@ def completions(params: types.CompletionParams):
def main(): def main():
ls.start_io() ls.start_io()
@final
class Tags:
def __init__(self) -> None:
self.last_mtime: int = 0
self.cache: dict[str, Tag] = {}
@dataclass
class Tag:
symbol: str
file: Path
search_pattern: str
type: types.CompletionItemKind