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

void-variable acm-backend-lsp-server-command-exist when using polymode and quarto-mode #787

Closed
maikol-solis opened this issue Nov 18, 2023 · 9 comments

Comments

@maikol-solis
Copy link

maikol-solis commented Nov 18, 2023

Hi!

With eglot or lsp-mode, I can work with a Quarto files (https://github.com/quarto-dev/quarto-emacs) due to polymode (https://github.com/polymode/polymode) divides the file into different modes.

In this toy example, quarto-mode jumps between marksman and languageserver (https://github.com/REditorSupport/languageserver) depending on if your cursor is inside or outside a code chunk.

<!-- markdown-mode: marksman -->
regular markdown text  

```{r}
# ess-mode: languageserver
print( rnorm(10))      
```

However, I'm having this issue when lsp-bridge is activated. And it always happens, in particular, if I want to format the chunks.

Debugger entered--Lisp error: (void-variable acm-backend-lsp-server-command-exist)
  (and lsp-bridge-mode (lsp-bridge-has-lsp-server-p) acm-backend-lsp-server-command-exist (lsp-bridge-process-live-p))
  lsp-bridge-call-file-api-p()
  (if (lsp-bridge-call-file-api-p) (progn (if (and (boundp 'acm-backend-lsp-filepath) (file-exists-p acm-backend-lsp-filepath)) (if lsp-bridge-buffer-file-deleted (progn (save-buffer) (set (make-local-variable 'lsp-bridge-buffer-file-deleted) nil) (message "[LSP-Bridge] %s is back, will send the %s LSP requ..." acm-backend-lsp-filepath method)) (if (and acm-backend-lsp-filepath (not (string-equal acm-backend-lsp-filepath ""))) (progn (let (it) (setq it ...) it)))) (if lsp-bridge-buffer-file-deleted nil (lsp-bridge-close-buffer-file) (set (make-local-variable 'lsp-bridge-buffer-file-deleted) t) (message "[LSP-Bridge] %s is not exist, stop send the %s LSP..." acm-backend-lsp-filepath method)))))
  (if (lsp-bridge-is-remote-file) (lsp-bridge-remote-send-lsp-request method args) (if (lsp-bridge-call-file-api-p) (progn (if (and (boundp 'acm-backend-lsp-filepath) (file-exists-p acm-backend-lsp-filepath)) (if lsp-bridge-buffer-file-deleted (progn (save-buffer) (set (make-local-variable ...) nil) (message "[LSP-Bridge] %s is back, will send the %s LSP requ..." acm-backend-lsp-filepath method)) (if (and acm-backend-lsp-filepath (not ...)) (progn (let ... ... it)))) (if lsp-bridge-buffer-file-deleted nil (lsp-bridge-close-buffer-file) (set (make-local-variable 'lsp-bridge-buffer-file-deleted) t) (message "[LSP-Bridge] %s is not exist, stop send the %s LSP..." acm-backend-lsp-filepath method))))))
  lsp-bridge-call-file-api("signature_help" (:line 250 :character 8))
  (if (equal lsp-bridge-cursor-before-command lsp-bridge-cursor-after-command) nil (lsp-bridge-call-file-api "signature_help" (lsp-bridge--position)))
  (progn (if (equal lsp-bridge-cursor-before-command lsp-bridge-cursor-after-command) nil (lsp-bridge-call-file-api "signature_help" (lsp-bridge--position))))
  (if (lsp-bridge-has-lsp-server-p) (progn (if (equal lsp-bridge-cursor-before-command lsp-bridge-cursor-after-command) nil (lsp-bridge-call-file-api "signature_help" (lsp-bridge--position)))))
  lsp-bridge-signature-help-fetch()
  funcall(lsp-bridge-signature-help-fetch)
  (closure (t) nil (funcall 'lsp-bridge-signature-help-fetch))()
  apply((closure (t) nil (funcall 'lsp-bridge-signature-help-fetch)) nil)
  timer-event-handler([t 0 0 500000 t (closure (t) nil (funcall 'lsp-bridge-signature-help-fetch)) nil idle 0 nil])

The *lsp-bridge* buffer only says this

ERROR:epc:ReturnError([Symbol('wrong-type-argument'), Symbol('stringp'), []])

I can help to debug this further if you need additional information.

Thanks for your help.

Best.

@getong
Copy link
Contributor

getong commented Nov 19, 2023

when using lsp-bridge-restart-process, it also occurs:

Eval in Emacs: (lsp-bridge--first-start '56756)
ERROR:epc:ReturnError([Symbol('wrong-type-argument'), Symbol('stringp'), []])

@manateelazycat
Copy link
Owner

Can you upgrade to newest version and try again?

@maikol-solis
Copy link
Author

maikol-solis commented Nov 26, 2023

Hi!

I have many outputs in the *Message* or in *lsp-bridge* buffer, installing the latest commit (8d64a8a):

Wrote /Users/maikol/OneDrive/home/test.qmd
"test.qmd" 7L, 54C written
markdown-mode math support enabled
error in polymode-post-command run other hooks: (33) Symbol’s value as variable is void: acm-backend-lsp-filepath
Error in menu-bar-update-hook (imenu-update-menubar): (jsonrpc-error "request id=109 failed:" (jsonrpc-error-message . "Timed out"))
Eval in Emacs: (lsp-bridge--first-start '49402)
Traceback (most recent call last):
  File "/Users/maikol/.emacs.d/.local/straight/repos/lsp-bridge/core/search_file_words.py", line 167, in search_dispatcher
    words = set(re.findall("[\w|-]+", search_content_dict[search_file]))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/__init__.py", line 216, in findall
    return _compile(pattern, flags).findall(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'list'

ERROR:epc:AttributeError("'list' object has no attribute 'split'")
ERROR:epc:Unexpected error
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/epc/handler.py", line 242, in _handle
    reply = handler(uid, *args)
            ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/epc/utils.py", line 51, in new_method
    ret = method(self, *args, **kwds)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/epc/handler.py", line 265, in _handle_call
    return ['return', uid, func(*args)]
                           ^^^^^^^^^^^
  File "/Users/maikol/.emacs.d/.local/straight/build-29.1/lsp-bridge/lsp_bridge.py", line 793, in _do
    getattr(getattr(self, obj_name), name)(*args, **kwargs)
  File "/Users/maikol/.emacs.d/.local/straight/repos/lsp-bridge/core/search_file_words.py", line 83, in change_buffer
    content = rebuild_content_from_diff(self.search_content_dict[buffer_name], start_pos, end_pos, change_text)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maikol/.emacs.d/.local/straight/repos/lsp-bridge/core/utils.py", line 509, in rebuild_content_from_diff
    start_pos = get_position(content, start_line, start_char)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maikol/.emacs.d/.local/straight/repos/lsp-bridge/core/utils.py", line 470, in get_position
    lines = content.split('\n')
            ^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'split'
Eval in Emacs: (lsp-bridge-search-backend--record-items '"search-file-words" '((:key "pas" :icon "search" :label "pas" :displayLabel "pas" :annotation "Search Word" :backend "search-file-words") (:key "podr" :icon "search" :label "podr" :displayLabel "podr" :annotation "Search Word" :backend "search-file-words") (:key "pAGO" :icon "search" :label "pAGO" :displayLabel "pAGO" :annotation "Search Word" :backend "search-file-words") (:key "pude" :icon "search" :label "pude" :displayLabel "pude" :annotation "Search Word" :backend "search-file-words") (:key "para" :icon "search" :label "para" :displayLabel "para" :annotation "Search Word" :backend "search-file-words") (:key "pude" :icon "search" :label "pude" :displayLabel "pude" :annotation "Search Word" :backend "search-file-words") (:key "plan" :icon "search" :label "plan" :displayLabel "plan" :annotation "Search Word" :backend "search-file-words") (:key "pARA" :icon "search" :label "pARA" :displayLabel "pARA" :annotation "Search Word" :backend "search-file-words") (:key "paso" :icon "search" :label "paso" :displayLabel "paso" :annotation "Search Word" :backend "search-file-words") (:key "pure" :icon "search" :label "pure" :displayLabel "pure" :annotation "Search Word" :backend "search-file-words")))

@manateelazycat
Copy link
Owner

how did you install lsp-bridge? git clone?

@maikol-solis
Copy link
Author

I use doom-emacs, so I install it using the package! command.

@manateelazycat
Copy link
Owner

Did you use follow step in README?

(use-package lsp-bridge
:straight '(lsp-bridge :type git :host github :repo "manateelazycat/lsp-bridge"
:files (:defaults ".el" ".py" "acm" "core" "langserver" "multiserver" "resources")
:build (:not compile))
:init
(global-lsp-bridge-mode))

@maikol-solis
Copy link
Author

I copy-pasted the way this PR install lsp-bridge on doom-emacs (doomemacs/doomemacs#7147)

In particular, these lines

https://github.com/skykanin/doomemacs/blob/6bed1672c34b0e984540a44f6cb98bebc620628f/modules/tools/lsp/packages.el#L13-L17

(package! lsp-bridge
 :recipe (:host github
          :repo "manateelazycat/lsp-bridge"
          :files (:defaults "*.py" "acm" "core" "langserver" "multiserver" "resources")))

@manateelazycat
Copy link
Owner

Please use git clone or git submodule, and test with emacs -Q

I think other plugin in doom emacs will conflict with lsp-bridge.

I don't use doom-emacs and package, sorry, I can't help you. :(

@skykanin
Copy link

I copy-pasted the way this PR install lsp-bridge on doom-emacs (doomemacs/doomemacs#7147)

In particular, these lines

https://github.com/skykanin/doomemacs/blob/6bed1672c34b0e984540a44f6cb98bebc620628f/modules/tools/lsp/packages.el#L13-L17

(package! lsp-bridge
 :recipe (:host github
          :repo "manateelazycat/lsp-bridge"
          :files (:defaults "*.py" "acm" "core" "langserver" "multiserver" "resources")))

Downloading the package using package! isn't enough. You need to call global-bridge-lsp-mode in the use-package! config in your config.el file which I did in the PR you copied the code from under modules/tools/lsp/+lsp-bridge.el so something like:

(use-package! lsp-bridge
  :config (global-bridge-lsp-mode))

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

4 participants