Comments (20)
#863 支持不使用tramp跳转到references文件 因为我用tramp,这个功能后续我也不会常用,所以猫大有空的话,也测试下,再看看实现合不合理.
发现2个问题:
-
tramp host name解析的地方没考虑纯ip的情况,提了一个fix PR #864
-
file-remote-p
只有在tramp-syntax
为simplified
情况下这里才能判断成功,这个估计得改成string-match-p
,等晚上回来我再看看
https://github.com/manateelazycat/lsp-bridge/blob/dda0d227d071be0406cd1292ca53271b6a65c8ea/lsp-bridge-ref.el#L853C51-L853C79
from lsp-bridge.
tramp只是提供文件路径,lsp-bridge的远程补全是完全不用tramp的同步机制的。
我认为tramp本身的实现就非常垃圾,依然有很多人不用tramp,太卡了。
lsp-bridge唯一支持tramp的目的是方便很多人远程访问目录,方便打开文件
from lsp-bridge.
我的猜测是跟你最近最大的那个补丁有关系,你没有考虑非tramp的场景。
from lsp-bridge.
我的猜测是跟你最近最大的那个补丁有关系,你没有考虑非tramp的场景。
最大的那个补丁 我什么代码都没改 只是移动了一下代码的位置 分类摆放
我昨天提交的这个PR才是第一个改动较大的patch
from lsp-bridge.
分析了一下
(funcall mode)
的问题是我本地的一些mode-hook会获取(buffer-file-name)
,但是lsp-bridge-open-remote-file打开的文件(buffer-file-name)
是nil
,去掉我的mode-hook可以正常打开文件.- 我又测试了一下,
lsp-bridge-find-def
和lsp-bridge-find-references
. 之前的一个patch里因为也调用了(buffer-file-name)
,所以会有问题,需要修改. 由此可以知道lsp-bridge中所有调用(buffer-file-name)
的地方都需要考虑open-remote-file的情况
(defun lsp-bridge-call-file-api (method &rest args)
(if (file-remote-p (buffer-file-name))
(if (lsp-bridge-is-remote-file)
(lsp-bridge-remote-send-lsp-request method args)
(message "[LSP-Bridge] remote file \"%s\" is updating info... skip call %s."
(buffer-file-name) method))
lsp-bridge-enable-with-tramp
需要设置为nil
,否则在lsp-bridge-define--jump
中会通过tramp打开会出错.lsp-bridge-find-references
找到的reference并没有办法跳转,我看lsp-bridge-ref-open-file
实现里并没有调用open-remote-file
, 直接调用的find-file
,所以这些reference如果没有tramp支持并没有办法跳转.那么open-remote-file
这一套机制是否支持lsp-bridge的全功能呢?还是仅支持find-define呢?- 另外open-remote-file在解析远程文件名的时候,不支持包含'.'的用户名,re pattern也需要修正.
def is_valid_ip_path(ssh_path):
"""Check if SSH-PATH is a valid ssh path."""
pattern = r"^(?:([a-z_][a-z0-9_-]*)@)?((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::(\d+))?:~?(.*)$"
match = re.match(pattern, ssh_path)
return match is not None
def split_ssh_path(ssh_path):
"""Split SSH-PATH into username, host, port and path."""
pattern = r"^(?:([a-z_][a-z0-9_-]*)@)?((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::(\d+))?:?(.*)$"
- 我个人是感觉这一套open-remote-file的机制好像有很多限制,设计实现也还并不完善.就如你说的,tramp只是用来打开文件而已,lsp-bridge工作的过程中大部分情况并不通过tramp,编辑时应该也并不会受到tramp低性能的影响.所以我个人还是倾向于通过tramp来访问文件,其通用性和兼容性还是要比open-remote-file要好很多,比如支持使用ssh config里配置服务器alias,打开文件时也支持远程路径补全等等,这些好像open-remote-file目前还没有支持. 仅个人看法.
from lsp-bridge.
2. 我又测试了一下,`lsp-bridge-find-def`和`lsp-bridge-find-references`. 之前的一个patch里因为也调用了`(buffer-file-name)`,所以会有问题,需要修改. 由此可以知道lsp-bridge中所有调用`(buffer-file-name)`的地方都需要考虑open-remote-file的情况
(defun lsp-bridge-call-file-api (method &rest args) (if (file-remote-p (buffer-file-name)) (if (lsp-bridge-is-remote-file) (lsp-bridge-remote-send-lsp-request method args) (message "[LSP-Bridge] remote file \"%s\" is updating info... skip call %s." (buffer-file-name) method))
lsp-bridge-call-file-api
的问题已经提交PR #855
from lsp-bridge.
春节自驾路上,没法一一回复,你说的没问题,我只是觉得不能只有tramp这一种路径,最起码我自己是完全不用tramp的
from lsp-bridge.
春节自驾路上,没法一一回复,你说的没问题,我只是觉得不能只有tramp这一种路径,最起码我自己是完全不用tramp的
不急 猫大空了再沟通
from lsp-bridge.
我简单回复一下哈, 欢迎进一步讨论:
- 社区之间修复了很多 issue 都跟 buffer-file-name 这个函数返回的buffer name带text prop相关, 所以所有用到 (buffer-file-name) 的地方都应该用 lsp-bridge-get-buffer-file-name-text 或者 lsp-bridge-buffer-file-name 替代, 避免因为属性导致各种奇怪的bug
- lsp-bridge-find-def和lsp-bridge-find-references只测试过文件打开以后, 支持远程文件的跳转, 但是你说的文件正在打开中的情况确实没有处理
- lsp-bridge-define--jump 和 tramp 的情况我没有测试过, 因为我平常不用 tramp
- open-remote-file 的机制我觉得遇到什么不方便就改哪个地方吧,因为使用是最好的测试, 不使用直接按照理论方法去改, 容易出现bug
- 对的, tramp目前看最重要的使用方式是和dired结合, 用户可以先通过 dired 访问远程的目录, 然后通过 tramp 的机制快速打开文件, lsp-bridge的整个补全机制和tramp是不相关的, 我原来准备直接在我的 eaf-file-manager 文件管理器中添加远程目录的访问, 这样就可以完全不用 tramp, 但是后面考虑到不是所有用户都用 tramp, 所以我也倾向于在远程目录访问上对 tramp 提供兼容性支持, 毕竟不是所有emacser的习惯都和我一样
- 路径补全的后端其实是可以支持远程文件补全的, 因为 lsp-bridge 的远程补全**和 VSCode 是类似的, 所有补全的计算都在服务器里, 包括 lsp-bridge Python 部分和 LSP Server 或 acm 补全后端, 得到数据后再传输补全候选词到本地进行前端绘制
from lsp-bridge.
我刚刚看了代码, 远程路径补全已经有代码了, 因为我最开始写远程补全的时候测试过 (但是那时候没有测试过 tramp), 如果你那边不能工作, 可以查看一下
今天还要开长途, 估计回复不会那么及时。
from lsp-bridge.
我刚刚看了代码, 远程路径补全已经有代码了, 因为我最开始写远程补全的时候测试过 (但是那时候没有测试过 tramp), 如果你那边不能工作, 可以查看一下
今天还要开长途, 估计回复不会那么及时。
嗯 在文件中编辑时补全路径我知道是支持的
我说的路径补全是指在打开文件的时候可以像打开本地目录一样按tab补全
lsp-bridge-open-remote-file
打开某个服务器文件时目前应该得自己输入完整的路径和文件名
tramp是可以的,所以这是我个人使用tramp的原因之一
2. lsp-bridge-find-def和lsp-bridge-find-references只测试过文件打开以后, 支持远程文件的跳转, 但是你说的文件正在打开中的情况确实没有处理
lsp-bridge-find-references
目前可以正常跳转吗?我这里不使用tramp好像是不行.可以得到references列表,但是没法跳转到对应文件(未打开的文件). 我看lsp-bridge-ref-open-file
的实现好像也没有使用(lsp-bridge-call-async "open_remote_file")
而是直接用的find-file
.
lsp-bridge-define--jump
里会判断lsp-bridge-enable-with-tramp
调用(lsp-bridge-call-async "open_remote_file")
,所以lsp-bridge-find-def
是不使用tramp也是可以正常跳转到未打开的定义文件的.
(defun lsp-bridge-ref-open-file (&optional stay)
(interactive)
(let* ((match-file (lsp-bridge-ref-get-match-file))
(match-line (lsp-bridge-ref-get-match-line))
(match-column (lsp-bridge-ref-get-match-column))
(match-buffer (lsp-bridge-ref-get-match-buffer match-file))
in-org-link-content-p
ref-buffer-window)
(save-excursion
(let ((inhibit-message t))
;; Try fill variables when in org file.
(lsp-bridge-ref-move-to-column match-column)
(setq in-org-link-content-p
(and (lsp-bridge-ref-is-org-file match-file)
(lsp-bridge-ref-in-org-link-content-p)))
;; Open file in other window.
;; Note, don't use `find-file-other-window', it will failed if path is tramp path that start with /sudo:root
(if (and lsp-bridge-ref-open-file-in-request-window
;; check if the window which requested search has beed deleted.
(window-valid-p lsp-bridge-ref-request-search-window))
(select-window lsp-bridge-ref-request-search-window)
(other-window 1))
(find-file match-file)
;; Add to temp list if file's buffer is not exist.
(unless match-buffer
(add-to-list 'lsp-bridge-ref-temp-visit-buffers (current-buffer)))
;; Jump to match point.
;; We use `ignore-errors' to make sure cursor will back to lsp-bridge-ref buffer
;; even target line is not exists in search file (such as delete by user).
(ignore-errors
(lsp-bridge-ref-move-to-point match-line match-column)
(when (lsp-bridge-ref-is-org-file match-file)
;; Expand org block if current file is *.org file.
(org-reveal)
;; Jump to link beginning if keyword in content area.
(when in-org-link-content-p
(search-backward-regexp "\\[\\[" (line-beginning-position) t))
)))
;; Flash match line.
(lsp-bridge-ref-flash-line))
(unless stay
;; Keep cursor in search buffer's window.
(setq ref-buffer-window (get-buffer-window lsp-bridge-ref-buffer))
(if ref-buffer-window
(select-window ref-buffer-window)
(if lsp-bridge-ref-delete-other-windows
(delete-other-windows))
;; Split window and select if color-buffer is not exist in windows.
(split-window)
(other-window 1)
(switch-to-buffer lsp-bridge-ref-buffer)))
;; Ajust column position.
(lsp-bridge-ref-move-to-column match-column)
))
(defun lsp-bridge-define--jump (filename filehost position)
(let (position-before-jump)
(lsp-bridge-define--jump-record-postion)
(if (or (string-equal filehost "") lsp-bridge-enable-with-tramp)
(progn
(setq filename (concat (cdr (assoc filehost lsp-bridge-tramp-alias-alist)) filename))
(let ((match-window (lsp-bridge-find-window-match-filename filename)))
(if (and lsp-bridge-find-def-select-in-open-windows
match-window)
;; Try select to window if `lsp-bridge-find-def-select-in-open-windows' is non-nil.
(select-window match-window)
;; Jump to define.
;; Show define in other window if `lsp-bridge-jump-to-def-in-other-window' is non-nil.
(if lsp-bridge-jump-to-def-in-other-window
(find-file-other-window filename)
(find-file filename))
))
;; Init jump history in new buffer.
(setq-local lsp-bridge-mark-ring (append (list position-before-jump) mark-ring))
(lsp-bridge-define--jump-flash position))
(lsp-bridge-call-async "open_remote_file" (format "%s:%s" filehost filename) position))
))
from lsp-bridge.
5. 另外open-remote-file在解析远程文件名的时候,不支持包含'.'的用户名,re pattern也需要修正.
def is_valid_ip_path(ssh_path): """Check if SSH-PATH is a valid ssh path.""" pattern = r"^(?:([a-z_][a-z0-9_-]*)@)?((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::(\d+))?:~?(.*)$" match = re.match(pattern, ssh_path) return match is not None def split_ssh_path(ssh_path): """Split SSH-PATH into username, host, port and path.""" pattern = r"^(?:([a-z_][a-z0-9_-]*)@)?((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::(\d+))?:?(.*)$"
这个问题提交了一个PR #856
from lsp-bridge.
lsp-bridge-find-references
lsp-bridge-find-references 最开始是可以的, 欢迎提交PR
from lsp-bridge.
5. 另外open-remote-file在解析远程文件名的时候,不支持包含'.'的用户名,re pattern也需要修正.
def is_valid_ip_path(ssh_path): """Check if SSH-PATH is a valid ssh path.""" pattern = r"^(?:([a-z_][a-z0-9_-]*)@)?((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::(\d+))?:~?(.*)$" match = re.match(pattern, ssh_path) return match is not None def split_ssh_path(ssh_path): """Split SSH-PATH into username, host, port and path.""" pattern = r"^(?:([a-z_][a-z0-9_-]*)@)?((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::(\d+))?:?(.*)$"这个问题提交了一个PR #856
已经合并了,感谢补丁
from lsp-bridge.
lsp-bridge-find-references
lsp-bridge-find-references 最开始是可以的, 欢迎提交PR
好的 等我这边的patch都提交完 我可以看下这个怎么实现
from lsp-bridge.
#863
支持不使用tramp跳转到references文件
因为我用tramp,这个功能后续我也不会常用,所以猫大有空的话,也测试下,再看看实现合不合理.
from lsp-bridge.
2. `file-remote-p`只有在`tramp-syntax`为`simplified`情况下这里才能判断成功,这个估计得改成`string-match-p`,等晚上回来我再看看 https://github.com/manateelazycat/lsp-bridge/blob/dda0d227d071be0406cd1292ca53271b6a65c8ea/lsp-bridge-ref.el#L853C51-L853C79
from lsp-bridge.
2. `file-remote-p`只有在`tramp-syntax`为`simplified`情况下这里才能判断成功,这个估计得改成`string-match-p`,等晚上回来我再看看 https://github.com/manateelazycat/lsp-bridge/blob/dda0d227d071be0406cd1292ca53271b6a65c8ea/lsp-bridge-ref.el#L853C51-L853C79
感谢, 已经合并了。
from lsp-bridge.
最新的master我本地测试find.define
, find-ref
, 补全功能应该都没问题了
最开始其实我的问题只是 #831 ,应该是加一个心跳机制就解决的.没想到一路提了这么多patch
感谢猫大 龙年龙腾龘龘!
from lsp-bridge.
辛苦啦,新年快乐,万事顺利
from lsp-bridge.
Related Issues (20)
- 请教如果想在其他地方使用补全怎么实现 HOT 1
- How can i make it work with emacs-direnv? HOT 1
- org-mode source block, manually complete not work , although auto pop up menu completion working HOT 11
- Orderless causes (wrong-type-argument stringp (seq (group 100))) HOT 1
- psearch-replace 导致 wrong-type-argument lsp-bridge-epc-manager nil ? HOT 2
- 执行 lsp-bridge-workspace-list-symbols 报错 HOT 4
- LSP Tailwind fails HOT 10
- Using it in terminal HOT 1
- Is it possible to use ACM with Orderless component separator like in Corfu? HOT 1
- lsp-bridge-workspace-list-symbols 查询结果集,如果是以 jdt:// 开始,无法正常跳转 HOT 7
- 补全消失 HOT 23
- (redisplay t) is consuming lots of cpu HOT 1
- Question: lsp-bridge-workspace-list-symbols can find the symbol, but lsp-bridge-find-def does not HOT 4
- 在latex启动lsp-bridge-mode后只能补全yasnippet中的模板,不能连接latex lsp服务器 HOT 2
- lsp-bridge-find-def not working with remote HOT 5
- Inlay hints HOT 8
- outdated diagnostic HOT 4
- 能加入mojo支持吗? HOT 8
- enabling lsp-bridge breaks syntax highlighting HOT 3
- I found how to fix Tailwindcss HOT 30
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp-bridge.