Skip to content

Commit

Permalink
We merge PATH from exec-path variable, to make sure lsp-bridge find…
Browse files Browse the repository at this point in the history
… LSP server command if it can find by Emacs.
  • Loading branch information
manateelazycat committed Aug 11, 2023
1 parent d7dbd6f commit 0f74bbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ def is_running_in_server():

return running_in_server

is_merge_emacs_exec_path = False
def merge_emacs_exec_path():
global is_merge_emacs_exec_path

# Only merge once.
if not is_merge_emacs_exec_path:
paths = os.environ["PATH"].split(":")
[emacs_paths, ] = get_emacs_vars(["exec-path"])
new_paths = list(dict.fromkeys(paths + emacs_paths))

os.environ["PATH"] = ":".join(new_paths)

is_merge_emacs_exec_path = True

lsp_file_host = ""
def set_lsp_file_host(host):
global lsp_file_host
Expand Down
3 changes: 3 additions & 0 deletions lsp_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ def turn_off(self, filepath, message):
eval_in_emacs("lsp-bridge--turn-off", filepath, get_lsp_file_host())

def check_lang_server_command(self, lang_server_info, filepath, turn_off_on_error=True):
# We merge PATH from `exec-path` variable, to make sure lsp-bridge find LSP server command if it can find by Emacs.
merge_emacs_exec_path()

if len(lang_server_info["command"]) > 0:
server_command = lang_server_info["command"][0]
server_command_path = shutil.which(server_command)
Expand Down

0 comments on commit 0f74bbf

Please sign in to comment.