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

DoomEmacs Python Lsp not loading properly #7786

Open
4 tasks done
TirtharajPramanik opened this issue Apr 1, 2024 · 3 comments
Open
4 tasks done

DoomEmacs Python Lsp not loading properly #7786

TirtharajPramanik opened this issue Apr 1, 2024 · 3 comments
Labels
invalid Unactionable, unrelated, inappropriate, or a pilot error

Comments

@TirtharajPramanik
Copy link

TirtharajPramanik commented Apr 1, 2024

I confirm that...

  • I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.
  • I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.
  • The issue can be reproduced on the latest available commit of Doom.
  • The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. (Unstable versions end in .50, .60, or .9x)

Expected behavior

I’ve enabled lsp-mode and the python +lsp language support.

Current behavior

However, when I open a Python file, I encounter the following warning:

Error (python-mode-local-vars-hook): Error running hook "lsp!" because: (void-function lsp-deferred)

Additionally, I see the message:

File local-variables error: (doom-hook-error python-mode-local-vars-hook lsp! (void-function lsp-deferred))

Steps to reproduce

  1. enable lsp & (python +lsp).
  2. open a file with .py extension.

System Information

I’m using Emacs 29 with native-comp on MacOS Sonoma.

@TirtharajPramanik TirtharajPramanik added is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet labels Apr 1, 2024
@TirtharajPramanik
Copy link
Author

I’m new to Emacs. Could you review this change and let me know if it might cause any issues? Should I create a pull request?

Solution:

Modify file: ~/.config/emacs/modules/lang/python/config.el line: 24

--- 24|    (add-hook 'python-mode-local-vars-hook #'lsp! 'append)
+++ 24|    (after! lsp!(add-hook 'python-mode-local-vars-hook #'lsp! 'append))

The (after! lsp!(...)) construct ensures that the hook is executed only after lsp-mode has been fully loaded.

Explanation:

In DoomEmacs, the lsp-deferred function, located in the file ~/.config/emacs/modules/tools/lsp/autoload/common.el at line 9 is used to lazily load lsp-mode.

By adding (after! lsp!(...)), we wait for lsp-mode to be available before executing the hook.
This prevents the “void-function lsp-deferred” error.

@hlissner
Copy link
Member

hlissner commented Apr 1, 2024

Errors about missing lsp-* functions usually mean you've forgotten to enable the :tools lsp module (or you forgot to run doom sync afterwards?). You did not include your M-x doom/info in your system information, so I can't say for sure.

The (after! lsp!(...)) construct ensures that the hook is executed only after lsp-mode has been fully loaded.

This is incorrect. That ensures that the enclosed code never runs at all, because lsp! is not a valid package.

@hlissner hlissner added invalid Unactionable, unrelated, inappropriate, or a pilot error and removed is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet labels Apr 1, 2024
@TirtharajPramanik
Copy link
Author

generated  Apr 05, 2024 22:21:46
system     MacOS 14.4.1 Darwin 23.4.0 arm64 ns
emacs      29.3 EMACSDIR=~/.config/emacs/
           EMACS=/opt/homebrew/Cellar/emacs-plus@29/29.3/Emacs.app/Contents/MacOS/Emacs
doom       3.0.0-pre PROFILE=_@0 HEAD -> master, origin/master, origin/HEAD ea4792ccd
           2024-04-01 13:47:12 -0400 ~/.config/doom/
shell      /bin/zsh
features   ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY
           KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
           TREE_SITTER WEBP XIM ZLIB
traits     gui daemon server-running envvar-file custom-file
custom     tool-bar-mode size-indication-mode column-number-mode blink-cursor-mode
           magit-todos-insert-after connection-local-criteria-alist
           connection-local-profile-alist
modules    :config use-package :completion company vertico :ui doom doom-dashboard
           hl-todo modeline ophints (popup +defaults) (vc-gutter +pretty)
           vi-tilde-fringe workspaces :editor (evil +everywhere) file-templates fold
           (format +onsave) snippets :emacs dired electric undo vc :term vterm
           :checkers syntax :tools (eval +overlay) lookup (lsp +peek) magit :os macos
           :lang emacs-lisp markdown org (python +lsp +pyright) sh :config (default
           +bindings +smartparens)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Unactionable, unrelated, inappropriate, or a pilot error
Projects
Status: Need info
Development

No branches or pull requests

2 participants