Skip to content

Commit

Permalink
Refactor get_language_id code.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed May 16, 2024
1 parent 6b4f48d commit 87ecb45
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/lspserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

INLAY_HINT_REQUEST_ID_DICT = {}

TAILWINDCSS_LANGUAGE_ID_DICT = {"jsx": "javascriptreact"}

class LspServerSender(MessageSender):
def __init__(self, process: subprocess.Popen, server_name, project_name):
super().__init__(process)
Expand Down Expand Up @@ -433,9 +435,9 @@ def parse_document_uri(self, filepath, external_file_link):
return uri

def get_language_id(self, fa):
language_id_dict={"jsx":"javascriptreact"}
# Get extension name.
_, extension = os.path.splitext(fa.filepath)
extension_name = extension.split(os.path.extsep)[-1]
extension_name = extension.split(os.path.extsep)[-1].lower()

if "languageIds" in self.server_info:
if extension_name in self.server_info["languageIds"]:
Expand All @@ -448,7 +450,8 @@ def get_language_id(self, fa):
#
# Please reference issue https://github.com/tailwindlabs/tailwindcss-intellisense/issues/925.
if language_id == "":
return extension_name.lower() if not language_id_dict.get(extension_name.lower()) else language_id_dict.get(extension_name.lower())
match_language_id = TAILWINDCSS_LANGUAGE_ID_DICT.get(extension_name)
return match_language_id if match_language_id else extension_name
else:
return language_id

Expand Down

0 comments on commit 87ecb45

Please sign in to comment.