Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

补全消失 #888

Open
haoran-mc opened this issue Mar 12, 2024 · 31 comments
Open

补全消失 #888

haoran-mc opened this issue Mar 12, 2024 · 31 comments

Comments

@haoran-mc
Copy link

haoran-mc commented Mar 12, 2024

golang只有内部包时能正常补全,在包含外部包时补全会消失,仅能补全第一次。

有时在等待很久后又能够恢复补全,时间不一定,十分钟、二十分钟。

gotest

markdown-mode、yasnippet、lsp-bridge 是最新的commit。

GNU Emacs 28.3 (build 1, aarch64-apple-darwin23.0.0, Carbon Version 170 AppKit 2487) of 2024-02-06
❯ go version
go version go1.22.1 darwin/arm64

❯ uname -a
Darwin ran-macbook-air.local 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:42:57 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8112 arm64

最小的配置 .emacs

(setq debug-on-error t)

(add-to-list 'load-path "~/Documents/emacs/local-packages/markdown-mode")
(require 'markdown-mode)

(add-to-list 'load-path "~/Documents/emacs/local-packages/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

(add-to-list 'load-path "~/Documents/emacs/local-packages/go-mode.el")
(require 'go-mode)

;; lsp-bridge
(add-to-list 'load-path "~/Documents/emacs/local-packages/lsp-bridge")
(require 'lsp-bridge)
(setq lsp-bridge-enable-log t)
(global-lsp-bridge-mode)

(provide 'init)

*Message* buffer:

[yas] Prepared just-in-time loading of snippets (but no snippets found).
Waiting for git... [2 times]
For information about GNU Emacs and the GNU system, type C-h C-a. [2 times]
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active file ’main.go’, enjoy hacking!
Mark set [2 times]
[LSP-Bridge] Process terminated.
[LSP-Bridge] Process restarted.
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active file ’main.go’, enjoy hacking!

*lsp-bridge* buffer:
lsp-bridge.txt

*lsp-bridge-epc con 82* buffer 没有内容。

在我创建这个issue时,minibuffer第一次给出了error:

Debugger entered--Lisp error: (cl-assertion-failed ((cl-plusp length) nil))
  cl--assertion-failed((cl-plusp length))
  (or (cl-plusp length) (cl--assertion-failed '(cl-plusp length)))
  (progn (or (cl-plusp length) (cl--assertion-failed '(cl-plusp length))) nil)
  (let* ((length (lsp-bridge-epc-net-decode-length)) (start (+ 6 (point))) (end (+ start length)) _content) (progn (or (cl-plusp length) (cl--assertion-failed '(cl-plusp length))) nil) (prog1 (save-restriction (narrow-to-region start end) (read (decode-coding-string (buffer-string) 'utf-8-unix))) (delete-region (point-min) end)))
  lsp-bridge-epc-net-read()
  (condition-case error (lsp-bridge-epc-net-read) (error (debug 'error error) (error "net-read error: %S" error)))
  lsp-bridge-epc-net-read-or-lose(#<process lsp-bridge-epc con 82>)
  (let ((event (lsp-bridge-epc-net-read-or-lose process)) (ok nil)) (lsp-bridge-epc-log "<< RECV [%S]" event) (unwind-protect (condition-case err (progn (apply 'lsp-bridge-epc-signal-send (cons (progn (or ... ...) (aref connection 4)) event)) (setq ok t)) ('error (lsp-bridge-epc-log "MsgError: %S / <= %S" err event))) (if ok nil (lsp-bridge-epc-process-available-input connection process))))
  (while (lsp-bridge-epc-net-have-input-p) (let ((event (lsp-bridge-epc-net-read-or-lose process)) (ok nil)) (lsp-bridge-epc-log "<< RECV [%S]" event) (unwind-protect (condition-case err (progn (apply 'lsp-bridge-epc-signal-send (cons (progn ... ...) event)) (setq ok t)) ('error (lsp-bridge-epc-log "MsgError: %S / <= %S" err event))) (if ok nil (lsp-bridge-epc-process-available-input connection process)))))
  (save-current-buffer (set-buffer (process-buffer process)) (while (lsp-bridge-epc-net-have-input-p) (let ((event (lsp-bridge-epc-net-read-or-lose process)) (ok nil)) (lsp-bridge-epc-log "<< RECV [%S]" event) (unwind-protect (condition-case err (progn (apply 'lsp-bridge-epc-signal-send (cons ... event)) (setq ok t)) ('error (lsp-bridge-epc-log "MsgError: %S / <= %S" err event))) (if ok nil (lsp-bridge-epc-process-available-input connection process))))))
  lsp-bridge-epc-process-available-input(#s(lsp-bridge-epc-connection :name "lsp-bridge-epc con 82" :process #<process lsp-bridge-epc con 82> :buffer #<buffer *lsp-bridge-epc con 82*> :channel ("lsp-bridge-epc con 82" nil (methods . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG METHODS: %S" args) (lsp-bridge-epc-handler-methods #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (caadr args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (epc-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG EPC-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-epc-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-return-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET: %S" args) (apply 'lsp-bridge-epc-handler-return #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status ok :value nil)) (call . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG CALL: %S" args) (apply 'lsp-bridge-epc-handler-called-method #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)))) #<process lsp-bridge-epc con 82>)
  (save-current-buffer (set-buffer (progn (or (progn (and (memq (type-of connection) cl-struct-lsp-bridge-epc-connection-tags) t)) (signal 'wrong-type-argument (list 'lsp-bridge-epc-connection connection))) (aref connection 3))) (goto-char (point-max)) (insert message) (lsp-bridge-epc-process-available-input connection process))
  lsp-bridge-epc-process-filter(#s(lsp-bridge-epc-connection :name "lsp-bridge-epc con 82" :process #<process lsp-bridge-epc con 82> :buffer #<buffer *lsp-bridge-epc con 82*> :channel ("lsp-bridge-epc con 82" nil (methods . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG METHODS: %S" args) (lsp-bridge-epc-handler-methods #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (caadr args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (epc-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG EPC-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-epc-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-return-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET: %S" args) (apply 'lsp-bridge-epc-handler-return #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status ok :value nil)) (call . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG CALL: %S" args) (apply 'lsp-bridge-epc-handler-called-method #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)))) #<process lsp-bridge-epc con 82> "000010(return 165 ())\n")
  (closure ((connection . #s(lsp-bridge-epc-connection :name "lsp-bridge-epc con 82" :process #<process lsp-bridge-epc con 82> :buffer #<buffer *lsp-bridge-epc con 82*> :channel ("lsp-bridge-epc con 82" nil (methods . ...) (epc-error . ...) (return-error . ...) (return . ...) (call . ...)))) (channel "lsp-bridge-epc con 82" nil (methods . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (epc-error . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return-error . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status ok :value nil)) (call . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil))) (connection-process . #<process lsp-bridge-epc con 82>) (connection-buf . #<buffer *lsp-bridge-epc con 82*>) (connection-name . "lsp-bridge-epc con 82") (connection-id . 82) (port . 52860) (host . "127.0.0.1") cl-struct-lsp-bridge-epc-connection-tags cl-struct-lsp-bridge-deferred-object-tags t) (p m) (lsp-bridge-epc-process-filter connection p m))(#<process lsp-bridge-epc con 82> "000010(return 165 ())\n")
  recursive-edit()
  debug(error (cl-assertion-failed ((cl-plusp length) nil)))
  cl--assertion-failed((cl-plusp length))
  (or (cl-plusp length) (cl--assertion-failed '(cl-plusp length)))
  (progn (or (cl-plusp length) (cl--assertion-failed '(cl-plusp length))) nil)
  (let* ((length (lsp-bridge-epc-net-decode-length)) (start (+ 6 (point))) (end (+ start length)) _content) (progn (or (cl-plusp length) (cl--assertion-failed '(cl-plusp length))) nil) (prog1 (save-restriction (narrow-to-region start end) (read (decode-coding-string (buffer-string) 'utf-8-unix))) (delete-region (point-min) end)))
  lsp-bridge-epc-net-read()
  (condition-case error (lsp-bridge-epc-net-read) (error (debug 'error error) (error "net-read error: %S" error)))
  lsp-bridge-epc-net-read-or-lose(#<process lsp-bridge-epc con 82>)
  (let ((event (lsp-bridge-epc-net-read-or-lose process)) (ok nil)) (lsp-bridge-epc-log "<< RECV [%S]" event) (unwind-protect (condition-case err (progn (apply 'lsp-bridge-epc-signal-send (cons (progn (or ... ...) (aref connection 4)) event)) (setq ok t)) ('error (lsp-bridge-epc-log "MsgError: %S / <= %S" err event))) (if ok nil (lsp-bridge-epc-process-available-input connection process))))
  (while (lsp-bridge-epc-net-have-input-p) (let ((event (lsp-bridge-epc-net-read-or-lose process)) (ok nil)) (lsp-bridge-epc-log "<< RECV [%S]" event) (unwind-protect (condition-case err (progn (apply 'lsp-bridge-epc-signal-send (cons (progn ... ...) event)) (setq ok t)) ('error (lsp-bridge-epc-log "MsgError: %S / <= %S" err event))) (if ok nil (lsp-bridge-epc-process-available-input connection process)))))
  (save-current-buffer (set-buffer (process-buffer process)) (while (lsp-bridge-epc-net-have-input-p) (let ((event (lsp-bridge-epc-net-read-or-lose process)) (ok nil)) (lsp-bridge-epc-log "<< RECV [%S]" event) (unwind-protect (condition-case err (progn (apply 'lsp-bridge-epc-signal-send (cons ... event)) (setq ok t)) ('error (lsp-bridge-epc-log "MsgError: %S / <= %S" err event))) (if ok nil (lsp-bridge-epc-process-available-input connection process))))))
  lsp-bridge-epc-process-available-input(#s(lsp-bridge-epc-connection :name "lsp-bridge-epc con 82" :process #<process lsp-bridge-epc con 82> :buffer #<buffer *lsp-bridge-epc con 82*> :channel ("lsp-bridge-epc con 82" nil (methods . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG METHODS: %S" args) (lsp-bridge-epc-handler-methods #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (caadr args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (epc-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG EPC-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-epc-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-return-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET: %S" args) (apply 'lsp-bridge-epc-handler-return #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status ok :value nil)) (call . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG CALL: %S" args) (apply 'lsp-bridge-epc-handler-called-method #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)))) #<process lsp-bridge-epc con 82>)
  (save-current-buffer (set-buffer (progn (or (progn (and (memq (type-of connection) cl-struct-lsp-bridge-epc-connection-tags) t)) (signal 'wrong-type-argument (list 'lsp-bridge-epc-connection connection))) (aref connection 3))) (goto-char (point-max)) (insert message) (lsp-bridge-epc-process-available-input connection process))
  lsp-bridge-epc-process-filter(#s(lsp-bridge-epc-connection :name "lsp-bridge-epc con 82" :process #<process lsp-bridge-epc con 82> :buffer #<buffer *lsp-bridge-epc con 82*> :channel ("lsp-bridge-epc con 82" nil (methods . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG METHODS: %S" args) (lsp-bridge-epc-handler-methods #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (caadr args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (epc-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG EPC-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-epc-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return-error . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET-ERROR: %S" args) (apply 'lsp-bridge-epc-handler-return-error #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG RET: %S" args) (apply 'lsp-bridge-epc-handler-return #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status ok :value nil)) (call . #s(lsp-bridge-deferred-object :callback (lambda (args) (lsp-bridge-epc-log "SIG CALL: %S" args) (apply 'lsp-bridge-epc-handler-called-method #s(lsp-bridge-epc-manager :title "python3 /Users/haoran/Documents/emacs/local-packag..." :server-process #<process *lsp-bridge*<1>> :commands ... :port 52860 :connection #1 :methods nil :sessions ... :exit-hooks nil) (lsp-bridge-epc-args args))) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)))) #<process lsp-bridge-epc con 82> "000010(return 164 ())\n")
  (closure ((connection . #s(lsp-bridge-epc-connection :name "lsp-bridge-epc con 82" :process #<process lsp-bridge-epc con 82> :buffer #<buffer *lsp-bridge-epc con 82*> :channel ("lsp-bridge-epc con 82" nil (methods . ...) (epc-error . ...) (return-error . ...) (return . ...) (call . ...)))) (channel "lsp-bridge-epc con 82" nil (methods . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (epc-error . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return-error . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil)) (return . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status ok :value nil)) (call . #s(lsp-bridge-deferred-object :callback (lambda ... ... ...) :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil))) (connection-process . #<process lsp-bridge-epc con 82>) (connection-buf . #<buffer *lsp-bridge-epc con 82*>) (connection-name . "lsp-bridge-epc con 82") (connection-id . 82) (port . 52860) (host . "127.0.0.1") cl-struct-lsp-bridge-epc-connection-tags cl-struct-lsp-bridge-deferred-object-tags t) (p m) (lsp-bridge-epc-process-filter connection p m))(#<process lsp-bridge-epc con 82> "000010(return 164 ())\n")
@manateelazycat
Copy link
Owner

lsp-bridge-enable-log 选项关闭以后会正常吗?因为这个选项只是调试用的,打开会极度影响性能

@haoran-mc
Copy link
Author

haoran-mc commented Mar 12, 2024

lsp-bridge-enable-log关闭后也是这个状况。

@manateelazycat
Copy link
Owner

manateelazycat commented Mar 12, 2024

给一个最小的重新代码吧,我有空测试一下

@haoran-mc
Copy link
Author

package main

import (
	"fmt"
	"time"

	"github.com/gin-gonic/gin"
)

func main() {
	a := 2
	for a == 2 {
		time.Sleep(1 * time.Second)
		a = 3
	}
	fmt.Println("--> a = 3")

	r := gin.Default()
	r.Run(":8080")
}

@ydzhou
Copy link

ydzhou commented Mar 15, 2024

Can confirm a similar issue with gopls
When I use arrow-key to navigate the candidate list, the list will disapear and then I cannot autocomplete anymore.

@ydzhou
Copy link

ydzhou commented Mar 15, 2024

lsp-bridge-go-issue.mov

@manateelazycat
Copy link
Owner

manateelazycat commented Mar 15, 2024

截图 2024-03-16 03-49-17
截图 2024-03-16 03-49-53

@haoran-mc 我今天晚上测试了一下, 一直都是可以补全的。

我看了你的 lsp-bridge.txt 日志, 你只有第一次 textDocument/completion 请求有回应, 第二次就不行了。

你的 golang 项目是按照我README写的: 补全之前执行 go mod init 命令 这样做的吗?

我的 gopls 是直接通过 pacman 安装的, 版本是 0.15.2-1

@haoran-mc
Copy link
Author

❯ go mod init github.com/haoran-mc/testlsp
go: creating new go.mod: module github.com/haoran-mc/testlsp
❯ nvim main.go
❯ cat main.go
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: main.go
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ package main
   2   │
   3   │ import "github.com/gin-gonic/gin"
   4   │
   5   │ func main() {
   6   │     r := gin.Default()
   7   │     r.Run(":8080")
   8   │ }
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ go mod tidy
go: finding module for package github.com/gin-gonic/gin
go: found github.com/gin-gonic/gin in github.com/gin-gonic/gin v1.9.1
❯ cat go.mod
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: go.mod
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ module github.com/haoran-mc/testlsp
   2   │
   3   │ go 1.22.1
   4   │
   5   │ require github.com/gin-gonic/gin v1.9.1
   6   │
   7   │ require (
       |       ...
  32   │ )
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

项目是这样搭建的,因为 emacs 现在不能补全,所以暂时使用 nvim 编辑。

nvim 中的 gopls 会提示:

/Users/haoran/testlsp/go.mod:3: invalid go version '1.22.1': must match format 1.23 [Error loading workspace]

然后我就把 go.mod 第三行的 1.22.1 改成了 1.22。

这时 nvim 能正常工作,但是 emacs 会出现上面补全消失的情况。

之后把 go.1.22 修改回 go.1.22.1 emacs 也还是补全消失。

❯ gopls version
golang.org/x/tools/gopls v0.15.1

我是使用 go install golang.org/x/tools/gopls@latest 下载的 gopls。

@manateelazycat
Copy link
Owner

截图 2024-03-17 02-34-41

我按照你上面的步骤构建golang项目, 可以工作。

你的配置是只加载了 lsp-bridge 吗? 还是有别的配置在影响 lsp-bridge 或 acm ?

@ydzhou
Copy link

ydzhou commented Mar 16, 2024

@manateelazycat Can you try this repo: https://github.com/kubernetes/kubernetes
Not working for me. gopls 0.15.2

@haoran-mc
Copy link
Author

haoran-mc commented Mar 17, 2024

我的配置只有这些,放在 ~/.emacs 文件中,然后删除了 ~/.emacs.d 文件夹。

(setq debug-on-error t)

(add-to-list 'load-path "~/Documents/emacs/local-packages/markdown-mode")
(require 'markdown-mode)

(add-to-list 'load-path "~/Documents/emacs/local-packages/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

(add-to-list 'load-path "~/Documents/emacs/local-packages/go-mode.el")
(require 'go-mode)

(add-to-list 'load-path "~/Documents/emacs/local-packages/lsp-bridge")
(require 'lsp-bridge)
(global-lsp-bridge-mode)

(provide 'init)

今天测试发现上面用了 gin 的小 demo 可以补全了,重启多次也都可以正常补全。

然后我在 github 上找了一些仓库,二十多个,只有内部包的项目都可以补全。需要第三方库的项目,尽管只依赖一个第三方库也不能补全。

打开项目前我都进行了 go mod tidy。

@manateelazycat
Copy link
Owner

感觉是gopls.json参数配置的问题,可以看一下vscode的gopls是怎么配置的

@manateelazycat
Copy link
Owner

@jixiuf Can you help to fix this? Thanks. ;)

@yuzukicat
Copy link

我遇到了同样的问题。MacOS(emacs29) 和 NixOS(emacs30) 中都遇到过。gopls v0.15.2, go v1.22.2。我使用了 go-mode-hook, emacs 会报错 function lsp-bridge is void。MacOS是新安装的环境,补全只在第一次打开项目起作用,之后就没有补全了。

@mrunhap
Copy link
Contributor

mrunhap commented Mar 30, 2024

我这里 go 的项目也无法补全了,同项目 eglot 是可以补全了, lsp-bridge 补全 c 也是可以的但是 go 不行

@manateelazycat
Copy link
Owner

有问题的同学都提供一下最小重现代码吧, 我目前个人测试没有问题

manateelazycat added a commit that referenced this issue Apr 21, 2024
…id acm menu not show completion candidates when candidates return by LSP server much bigger than the limit of acm-backend-lsp-candidates-max-number
@manateelazycat
Copy link
Owner

我今天推送了新的补丁

bc10c15

这个补丁应该修复了LSP Server返回超多补全项时acm菜单不显示候选词的问题。

不显示补全的原因是, 原来有一批用户不希望 lsp-bridge 在 Python 端过滤候选词, 但是完全不过滤候选词, 当LSP server返回的候选词过多就会导致Emacs因为创建过多的对象而引起GC, 最终卡住Emacs, 所以后面引入了 acm-backend-lsp-candidates-max-number 选项来避免GC。

但是这样设计也是有问题的, 如果 LSP server 返回的候选词远远大于 acm-backend-lsp-candidates-max-number 的设定 (比如 Tailwindcss LSP server), 默认不过滤的策略, lsp-bridge 只是会一直发送 acm-backend-lsp-candidates-max-number 范围内的候选词, 而这些候选词和用户的输入并没有关系。

新的设计是, lsp-bridge 总是会在Python端过滤候选词, 只是用户可以配置 acm-backend-lsp-match-mode 的匹配模式, 这样就解决了LSP server返回过多候选项时acm不显示补全候选词的bug。

@manateelazycat
Copy link
Owner

@haoran-mc @ydzhou @mrunhap @yuzukicat 这个帖子的大佬们, 你们可以更新到最新版帮我验证一下这个问题还存在吗?

@haoran-mc
Copy link
Author

haoran-mc commented Apr 23, 2024

@manateelazycat 已更新到最新版,问题还存在。还是等待几分钟就可以正常补全。

@manateelazycat
Copy link
Owner

等几分钟才能补全, 是不是 gopls 在后台下载库或者再做目录索引的工作呀? 能否帮我打开日志, 看一下 *lsp-bridge* 的内容?

我是最近在修复 Tailwindcss 的问题的时候, 想到可能也能修复 gopls 的问题。

@haoran-mc
Copy link
Author

haoran-mc commented Apr 23, 2024

是的,代码越多、需要的库越多,等待的时间越长。 几分钟、十几分钟、二十几分钟... 之后能一直正常使用。

*lsp-bridge*: lsp.log

[yas] Prepared just-in-time loading of snippets (but no snippets found).
Waiting for git... [2 times]
For information about GNU Emacs and the GNU system, type C-h C-a. [2 times]
Making completion list...
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active project ’dockertest’, enjoy hacking!
Mark set [2 times]
Mark activated
Mark set [2 times]
Saving file /Users/haoran/gotest/dockertest/container.go...
Wrote /Users/haoran/gotest/dockertest/container.go
[LSP-Bridge] Process terminated.
[LSP-Bridge] Process restarted.
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active project ’dockertest’, enjoy hacking!
Mark set [2 times]
Saving file /Users/haoran/lsp.log...
Wrote /Users/haoran/lsp.log
previous-line: Beginning of buffer
(No changes need to be saved)

@manateelazycat
Copy link
Owner

好的, 我分析一下日志, 看看能否加一下提示, 目前看代码补全可以用了。

@manateelazycat
Copy link
Owner

是的,代码越多、需要的库越多,等待的时间越长。 几分钟、十几分钟、二十几分钟... 之后能一直正常使用。

*lsp-bridge*: lsp.log

[yas] Prepared just-in-time loading of snippets (but no snippets found).
Waiting for git... [2 times]
For information about GNU Emacs and the GNU system, type C-h C-a. [2 times]
Making completion list...
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active project ’dockertest’, enjoy hacking!
Mark set [2 times]
Mark activated
Mark set [2 times]
Saving file /Users/haoran/gotest/dockertest/container.go...
Wrote /Users/haoran/gotest/dockertest/container.go
[LSP-Bridge] Process terminated.
[LSP-Bridge] Process restarted.
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active project ’dockertest’, enjoy hacking!
Mark set [2 times]
Saving file /Users/haoran/lsp.log...
Wrote /Users/haoran/lsp.log
previous-line: Beginning of buffer
(No changes need to be saved)

我分析了一下日志, 没有啥问题, 目前还不知道为什么要等待那么长时间。

@manateelazycat
Copy link
Owner

@haoran-mc

你尝试把 lspbridge/langserver/gopls.json 文件改成下面的内容, 再看看能否补全? 我怀疑 handle_workspace_configuration_request 函数返回了 gopls 不喜欢的参数, 然后 gopls 就不再补全了, 今天我在开发 workDoneProgress 协议的时候发现 gopls 这个特性。

{
  "name": "gopls",
  "languageId": "go",
  "command": [
    "gopls",
    "-remote=auto"
  ],
  "settings": {}
}

@haoran-mc
Copy link
Author

haoran-mc commented Apr 29, 2024

更新到最新 commit,没有成功

❯ cat langserver/gopls.json
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: langserver/gopls.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "name": "gopls",
   3   │   "languageId": "go",
   4   │   "command": [
   5   │     "gopls",
   6   │     "-remote=auto"
   7   │   ],
   8 ~ │   "settings": {}
   9   │ }
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@manateelazycat
Copy link
Owner

你改成

{
  "name": "gopls",
  "languageId": "go",
  "command": [
    "gopls",
    "-rpc.trace",
    "--debug=localhost:6060",
    "-remote=auto"
  ],
  "settings": {}
}

试一下, gopls 启动后, 浏览器访问 localhost:6060 , 看看有没有什么信息, 我怀疑什么地方配置错了, 导致 gopls 无法补全

@haoran-mc
Copy link
Author

haoran-mc commented Apr 29, 2024

这个页面,还有 6060 的其它页面,没什么变化。在可补全的项目下,和不可补全的项目下一样。

image

之前这个项目是可以补全的,现在改了之后,变这样了。

Apr-29-2024 17-19-27

@manateelazycat
Copy link
Owner

好吧, 感谢你的测试, 只能看哪天有灵感才能修复了。

@manateelazycat
Copy link
Owner

eglot

能帮我发送一下 eglot 和 LSP Server 通信的日志吗? 我检查一下是否 lsp-bridge 遗漏了某些配置? 谢谢

@manateelazycat
Copy link
Owner

是的,代码越多、需要的库越多,等待的时间越长。 几分钟、十几分钟、二十几分钟... 之后能一直正常使用。

*lsp-bridge*: lsp.log

[yas] Prepared just-in-time loading of snippets (but no snippets found).
Waiting for git... [2 times]
For information about GNU Emacs and the GNU system, type C-h C-a. [2 times]
Making completion list...
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active project ’dockertest’, enjoy hacking!
Mark set [2 times]
Mark activated
Mark set [2 times]
Saving file /Users/haoran/gotest/dockertest/container.go...
Wrote /Users/haoran/gotest/dockertest/container.go
[LSP-Bridge] Process terminated.
[LSP-Bridge] Process restarted.
[LSP-Bridge] found language server: /Users/haoran/go/bin/gopls
[LSP-Bridge] Active project ’dockertest’, enjoy hacking!
Mark set [2 times]
Saving file /Users/haoran/lsp.log...
Wrote /Users/haoran/lsp.log
previous-line: Beginning of buffer
(No changes need to be saved)

从这个现象看, 更像是 go import 的那些包在下载, 下载完以后就可以补全了。
我看到日志里面是 docker test 的项目, docker 镜像里应该没有go的这些库吧?

@haoran-mc
Copy link
Author

它只是仓库的名字叫dockertest,但是并不是连到docker里面的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants