Skip to content

Commit

Permalink
🧑‍💻 Add get_uri()
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Feb 14, 2024
1 parent 040cfeb commit d7f7446
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/tree_sitter_lsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ def get_path(self) -> str:
"""
return self.uri2path(self.uri)

def get_uri(self) -> str:
r"""Get uri.
:rtype: str
"""
return os.path.join(os.path.dirname(self.uri), self.get_text())

@staticmethod
def uri2path(uri: str) -> str:
r"""Uri2path.
Expand Down Expand Up @@ -133,7 +140,9 @@ def get_text_edit(self, new_text: str) -> TextEdit:
"""
return TextEdit(self.get_range(), new_text)

def get_document_link(self, target: str, **kwargs) -> DocumentLink:
def get_document_link(
self, target: str = "{{uni.get_uri()}}", **kwargs
) -> DocumentLink:
r"""Get document link.
:param target:
Expand Down Expand Up @@ -423,7 +432,7 @@ def get_text_edits(self, uri: str, tree: Tree) -> list[TextEdit]:
return []

def get_document_links(
self, uri: str, tree: Tree, template: str
self, uri: str, tree: Tree, template: str = "{{uni.get_uri()}}"
) -> list[DocumentLink]:
r"""Get document links.
Expand Down

0 comments on commit d7f7446

Please sign in to comment.