lsp-bridge -- 速度最快的语法补全插件

期待,已经准备好打赏了

lsp-bridge 的好处是,用户装好 company 和 lsp server 以后啥都不用设置,lsp-bridge 会自动处理各种情况,打开文件的时候再也不会像 lsp-mode 那样顿一下。

1 个赞

想试用一下 lsp-bridge, 配置好后,补全的 ui 没有出现. lsp-bridge buffer 的内容是:

--- Send request (1): textDocument/completion
{
   "jsonrpc": "2.0",
   "method": "textDocument/completion",
   "params": {
      "textDocument": {
         "uri": "file:///home/lixunsong/Documents/python_work/1.py"
      },
      "position": {
         "line": 20,
         "character": 15
      },
      "context": {
         "triggerKind": 3
      }
   },
   "id": 25110
}

--- Recv message
{
   "jsonrpc": "2.0",
   "id": 25110,
   "result": null
}
Traceback (most recent call last):
  File "/home/lixunsong/.emacs.d/site-lisp/lsp-bridge/lsp-bridge.py", line 151, in handle_server_message
    print("***** ", list(map(lambda item: item["label"], response_result["items"])))
TypeError: 'NoneType' object is not subscriptable

Process *lsp-bridge* aborted (core dumped)

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.977e[0m: Theme parsing error: gtk.css:5601:11: Not using units is deprecated. Assuming 'px'.

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.977e[0m: Theme parsing error: gtk.css:5601:14: '0' is not a valid color name

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5694:26: 'text-shadow' is not a valid color name

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5702:26: 'text-shadow' is not a valid color name

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5838:14: '202020' is not a valid color name

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5853:20: Junk at end of value for border-width

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5878:20: Junk at end of value for border-width

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5905:20: Junk at end of value for border-width

(python3:736261): Gtk-e[1;33mWARNINGe[0m **: e[34m09:22:51.978e[0m: Theme parsing error: gtk.css:5957:26: 'text-shadow' is not a valid color name

不知道是哪里出了问题?

lsp-bridge.el 没有更新到最新版

似乎还是不行,现在是 pull 的最新的了。

一个简单的 capf,可以出来补全项。

(defun lsp-bridge-completion-at-point ()
    (let (
          (bounds (bounds-of-thing-at-point 'symbol)))
      (list (car bounds) (cdr bounds)
            lsp-bridge-completion-items
            :exclusive 'no)))

有没有样本代码可以让我测试?

我是在单文件里面测试的,代码很简单,如下:

import numpy as np

def conv(img, kernel):
    h, w = img.shape
    kh, kw = kernel.shape
    outh = (h - kh) + 1
    outw = (w - kw) + 1
    res = np.zeros((outh, outw))
    for i in range(outh):
        for j in range(outw):
            res[i, j] = np.dot(img[i:i+kh, j:j+kw].reshape(-1), kernel.reshape(-1).transpose())

    return res

img = np.linspace(1, 100, 100).reshape(10, 10)
print('img ', img)
kernel = np.ones((3, 3))
print('kernel:', kernel)
print(conv(img, kernel))

我试了一下,可以的呀。

你把文件移动到 HOME 下面测试一下,我怀疑你的那个 python_work 目录里面有一些其他文件影响 pyright 分析了。

上面记录了一下接下来要完成的任务,欢迎大家一起开发,我先休息几天了。

4 个赞

在单个的项目文件夹里面也用不了,这会是我没装上导致的吗?lsp-bridge 的那个 buffer 里面始终也是报一样的错误:

你安装了pyright了吗?

安装了的 子树补丁

用pip还是npm安装的呀?

我记得是 npm 安装的

目前来看为了更好的性能禁调diagnostic是可以理解的,也有各种替代品,但是code action呢?code action应该也不会是频繁的请求吧,而且也只会被用户主动请求而不会后台自动请求。理论上来说增加code action的功能应该不会卡?

对,不会卡。

但是需要大家一起去贡献代码,lsp-bridge只是提供一个底层机制解决性能问题,保证emacs不会卡。

我不会去响应社区所有需求,毕竟不是商业软件,谁有需求就去写PR吧。

2 个赞

可惜实现语言是 python ,要是 rust 就好了,不太喜欢 pip 装一堆依赖

只要安装一个 epc,没有一堆 :grinning_face_with_smiling_eyes:

2 个赞