Skip to content

Commit

Permalink
Separate biome's configuration command and arguments (#9)
Browse files Browse the repository at this point in the history
mataha authored Dec 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0a614e3 commit f8a6e0d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -5,13 +5,21 @@
import os
import sublime

BIOME_EXECUTABLE = 'biome.cmd' if sublime.platform() == 'windows' else 'biome'
BIOME_LOCATION = os.path.join('@biomejs', 'biome', 'bin', 'biome')


class LspBiomePlugin(NpmClientHandler):
package_name = __package__
server_directory = 'language-server'
server_binary_path = os.path.join(server_directory, 'node_modules', '.bin', BIOME_EXECUTABLE)
server_binary_path = os.path.join(server_directory, 'node_modules', BIOME_LOCATION)

@classmethod
def required_node_version(cls) -> str:
return '>=14'

@classmethod
def get_binary_arguments(cls) -> List[str]:
return ['lsp-proxy']

@classmethod
def is_allowed_to_start(
@@ -24,7 +32,9 @@ def is_allowed_to_start(
biome_path = cls._resolve_biome_path(workspace_folders, configuration)
if not biome_path:
return 'LSP-biome could not resolve specified biome binary.'
configuration.command = [biome_path, 'lsp-proxy']
server = cls.get_server()
if server:
configuration.command = [server.node_bin, biome_path] + cls.get_binary_arguments()
return None

@classmethod
@@ -49,7 +59,7 @@ def _get_workspace_relative_path(cls, rome_lsp_bin: str, workspace_folders: List
@classmethod
def _get_workspace_dependency(cls, workspace_folders: List[WorkspaceFolder]) -> Optional[str]:
for folder in workspace_folders:
binary_path = os.path.join(folder.path, 'node_modules', '.bin', BIOME_EXECUTABLE)
binary_path = os.path.join(folder.path, 'node_modules', BIOME_LOCATION)
if os.path.isfile(binary_path):
return binary_path
return None

0 comments on commit f8a6e0d

Please sign in to comment.