Skip to content

Commit

Permalink
Make multi-lang-server support OS name.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Jan 1, 2025
1 parent 036f21e commit fb0e319
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lsp_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,7 @@ def open_file(self, filepath):
create_file_action_with_single_server(filepath, lang_server_info, lsp_server)
elif multi_lang_server:
# Try to load multi language server when get-multi-lang-server return match one.
multi_lang_server_dir = Path(__file__).resolve().parent / "multiserver"
multi_lang_server_path = multi_lang_server_dir / "{}.json".format(multi_lang_server)

user_multi_lang_server_dir = Path(str(get_emacs_vars(["lsp-bridge-user-multiserver-dir"])[0])).expanduser()
user_multi_lang_server_path = user_multi_lang_server_dir / "{}.json".format(multi_lang_server)
if user_multi_lang_server_path.exists():
multi_lang_server_path = user_multi_lang_server_path
multi_lang_server_path = get_lang_server_path(multi_lang_server, True)

with open(multi_lang_server_path, encoding="utf-8", errors="ignore") as f:
multi_lang_server_info = json.load(f)
Expand Down Expand Up @@ -1045,12 +1039,15 @@ def load_single_server_info(lang_server):
with open(lang_server_info_path, encoding="utf-8", errors="ignore") as f:
return read_lang_server_info(f)

def get_lang_server_path(server_name):
server_dir = Path(__file__).resolve().parent / "langserver"
def get_lang_server_path(server_name, is_multi_server=False):
lang_server_dir = "multiserver" if is_multi_server else "langserver"
lang_server_dir_var = "lsp-bridge-user-multiserver-dir" if is_multi_server else "lsp-bridge-user-langserver-dir"

server_dir = Path(__file__).resolve().parent / lang_server_dir
server_path_current = server_dir / "{}_{}.json".format(server_name, get_os_name())
server_path_default = server_dir / "{}.json".format(server_name)

user_server_dir = Path(str(get_emacs_vars(["lsp-bridge-user-langserver-dir"])[0])).expanduser()
user_server_dir = Path(str(get_emacs_vars([lang_server_dir_var])[0])).expanduser()
user_server_path_current = user_server_dir / "{}_{}.json".format(server_name, get_os_name())
user_server_path_default = user_server_dir / "{}.json".format(server_name)

Expand Down

0 comments on commit fb0e319

Please sign in to comment.