1- from LSP .plugin .core .typing import Tuple
2- from lsp_utils import NpmClientHandler
3- import os
1+ from .types import CustomDataChangedNotification
2+ from LSP .plugin import Session , filename_to_uri
3+ from LSP .plugin .core .typing import List
4+ from lsp_utils import ApiWrapperInterface , NpmClientHandler
5+ from os import path
46
57
68def plugin_loaded ():
@@ -14,7 +16,7 @@ def plugin_unloaded():
1416class LspCssPlugin (NpmClientHandler ):
1517 package_name = __package__
1618 server_directory = "language-server"
17- server_binary_path = os . path .join (
19+ server_binary_path = path .join (
1820 server_directory ,
1921 "css-language-features" ,
2022 "server" ,
@@ -24,6 +26,20 @@ class LspCssPlugin(NpmClientHandler):
2426 )
2527
2628 @classmethod
27- def minimum_node_version (cls ) -> Tuple [int , int , int ]:
28- # this should be aligned with VSCode's Nodejs version
29- return (14 , 0 , 0 )
29+ def required_node_version (cls ) -> str :
30+ return '>=14'
31+
32+ def on_ready (self , api : ApiWrapperInterface ) -> None :
33+ session = self .weaksession ()
34+ if not session :
35+ return
36+ self .resolve_custom_data_paths (session )
37+
38+ def resolve_custom_data_paths (self , session : Session ) -> None :
39+ custom_data_paths = session .config .settings .get ('css.customData' ) # type: List[str]
40+ resolved_custom_data_paths = [] # type: List[str]
41+ for folder in session .get_workspace_folders ():
42+ # Converting to URI as server can't handle reading the content if it's a file path.
43+ resolved_custom_data_paths .extend (
44+ [filename_to_uri (path .abspath (path .join (folder .path , p ))) for p in custom_data_paths ])
45+ session .send_notification (CustomDataChangedNotification .create (resolved_custom_data_paths ))
0 commit comments