sublimelsp / lsp_utils

Module with LSP-related utilities for Sublime Text
https://sublimelsp.github.io/lsp_utils/
MIT License
13 stars 6 forks source link

[Feature Request] Restrict max supported Node.js version #89

Closed jfcherng closed 1 year ago

jfcherng commented 2 years ago

This feature request comes from https://github.com/TheSecEng/LSP-copilot/issues/51. The Copilot server files are compiled in WASM files, which freezes ST if the user uses Node v18. Having minimum_node_version() is not enough.

I am imaging something like the following:

class NpmClientHandler(GenericClientHandler):
    @classmethod
    def maximum_node_version(cls) -> Optional[Tuple[int, int, int]]:
        return None

Or even better, deprecates minimum_node_version() and introduces

class NpmClientHandler(GenericClientHandler):
    @classmethod
    def support_node_version(cls, node_version: Tuple[int, int, int]) -> bool:
        """Whether the given Node version is supported by this client."""
        return True

    @classmethod
    def unsupport_node_message(cls, node_version: Tuple[int, int, int]) -> str:
        return "Node.js {} is not supported. Supported versions are v16 and v17.".format('.'.join(node_version))

Or

class NpmClientHandler(GenericClientHandler):
    @classmethod
    def support_node_version(cls, node_version: Tuple[int, int, int]) -> Union[Literal[True], str]:
        """Whether the given Node version is supported by this client."""
        return True  # or error message
rchl commented 2 years ago

I'm thinking... deprecate current class method and introduce one that returns semantic version (can be a range).

    @classmethod
    def supported_node_version(cls) -> str:
        return '16 - 18'

Then we'd need to also vendor https://python-semanticversion.readthedocs.io or https://github.com/FichteFoll/pysemver to handle semantic version matching.

jfcherng commented 2 years ago

Whatever works ;)