diff --git a/README.md b/README.md index 8237e9931a..fd544cf66e 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,13 @@ It should be noted that lsp-bridge has three scanning modes: 1. Install lsp-bridge and the corresponding LSP Server on the remote server. 2. Start lsp-bridge: `python3 lsp-bridge/lsp_bridge.py`. -3. Use the `lsp-bridge-open-remote-file` command to open files, entering the username, IP, SSH port (default 22), and path, such as `user@ip:[ssh_port]:/path/file`. Enabling the `lsp-bridge-enable-with-tramp` option allows direct opening of tramp files, using the efficient algorithm of lsp-bridge instead of tramp, achieving smooth completion. +3. Use the `lsp-bridge-open-remote-file` command to open files, entering the username, IP, SSH port (default 22), and path, such as `user@ip:[ssh_port]:/path/file` +4. Enabling the `lsp-bridge-enable-with-tramp` option allows direct opening of tramp files, using the efficient algorithm of lsp-bridge instead of tramp, achieving smooth completion. If the host in tramp is defined in `~/.ssh/config`, lsp-bridge can synchronize the following options for remote connection: + - HostName (must be in IP format, domain format may cause issues) + - User + - Port + - GSSAPIAuthentication + - ProxyCommand (currently only supports ProxyCommand option, does not support ProxyJump option) Principle of remote completion: @@ -85,6 +91,7 @@ Note: 1. If the completion menu is not displayed, check the output of `lsp_bridge.py` on the remote server, it may be that the LSP Server is not fully installed. 2. lsp-bridge will use the first *.pub file in `~/.ssh` as a login credential. If public key login fails, you will be asked to enter a password. lsp-bridge will not store the password, it is recommended to use public key login to avoid repeated password entry. 3. To run lsp_bridge.py successfully you need to completely download the entire git repository of lsp-bridge on a remote server, and switch into its directory, lsp_bridge.py requires other files to function properly, so copying only the lsp_bridge.py file can't work +4. If a tramp file encounters an lsp-bridge connection error, you can execute the `lsp-bridge-tramp-show-hostnames` function and then check if the output of the host configuration options meets expectations ## Keymap diff --git a/README.zh-CN.md b/README.zh-CN.md index 4d5f6f7609..cc3b4f1afe 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -70,7 +70,13 @@ lsp-bridge 开箱即用, 安装好语言对应的 [LSP 服务器](https://gith 1. 在远程服务器安装 lsp-bridge 和相应的 LSP Server 2. 启动 lsp-bridge: `python3 lsp-bridge/lsp_bridge.py` -3. 用`lsp-bridge-open-remote-file`命令打开文件, 输入用户名、 IP、 SSH 端口(默认 22) 和路径, 例如`user@ip:[ssh_port]:/path/file`。 启用`lsp-bridge-enable-with-tramp`选项可以直接打开 tramp 文件, 并用 lsp-bridge 的高效算法代替 tramp, 实现流畅补全 +3. 用`lsp-bridge-open-remote-file`命令打开文件, 输入用户名、 IP、 SSH 端口(默认 22) 和路径, 例如`user@ip:[ssh_port]:/path/file` +4. 启用`lsp-bridge-enable-with-tramp`选项可以直接打开 tramp 文件, 并用 lsp-bridge 的高效算法代替 tramp,实现流畅补全。如果 tramp 中 host 是在 `~/.ssh/config` 定义的,那么 lsp-birdge 可以同步下列选项用于远程连接: + - HostName(必须是 ip 形式的 hostname,domain 形式的 hostname 会导致问题) + - User + - Port + - GSSAPIAuthentication + - ProxyCommand(当前只支持用 ProxyCommand 选项,不支持 ProxyJump 选项) 远程补全原理: @@ -83,6 +89,7 @@ lsp-bridge 开箱即用, 安装好语言对应的 [LSP 服务器](https://gith 1. 若补全菜单未显示, 检查远程服务器的`lsp_bridge.py`输出, 可能是 LSP Server 未完全安装 2. lsp-bridge 会用`~/.ssh`的第一个 *.pub 文件作为登录凭证。 如果公钥登录失败, 会要求输入密码。 lsp-bridge 不会存储密码, 建议用公钥登录以避免重复输入密码 3. 你需要在远程服务器完整的下载整个 lsp-bridge git 仓库, 并切换到 lsp-bridge 目录来启动 `lsp_bridge.py`, `lsp_bridge.py` 需要其他文件来保证正常工作, 不能只把 `lsp_bridge.py` 文件拷贝到其他目录来启动 +4. 如果 tramp 文件出现 lsp-bridge 连接错误,可以执行 `lsp-bridge-tramp-show-hostnames` 函数,然后检查输出的 host 配置选项是否符合预期 ## 按键 diff --git a/lsp-bridge.el b/lsp-bridge.el index 619380dba8..6dafff45e4 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -2505,6 +2505,10 @@ We need exclude `markdown-code-fontification:*' buffer in `lsp-bridge-monitor-be (add-hook 'kill-buffer-hook 'lsp-bridge-remote-kill-buffer nil t) (setq lsp-bridge-tramp-sync-var t))) +(defun lsp-bridge-tramp-show-hostnames () + (interactive) + (lsp-bridge-call-async "message_hostnames")) + (defcustom lsp-bridge-tramp-blacklist nil "tramp hosts that don't use lsp-bridge") (defun lsp-bridge-sync-tramp-remote () diff --git a/lsp_bridge.py b/lsp_bridge.py index a22882f402..e4e0719cee 100755 --- a/lsp_bridge.py +++ b/lsp_bridge.py @@ -239,6 +239,9 @@ def open_remote_file(self, path, jump_define_pos): else: message_emacs("Please input valid path match rule: 'ip:/path/file'.") + def message_hostnames(self): + message_emacs(f"host_names:{self.host_names}") + @threaded def sync_tramp_remote(self, server_username, server_host, ssh_port, filename): use_gssapi = False