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

Externally provided lua-language-server is not recognized #4688

Open
2 of 3 tasks
starptr opened this issue Jan 17, 2025 · 0 comments
Open
2 of 3 tasks

Externally provided lua-language-server is not recognized #4688

starptr opened this issue Jan 17, 2025 · 0 comments
Labels

Comments

@starptr
Copy link

starptr commented Jan 17, 2025

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

After setting the lsp-clients-lua-language-server-bin to my local copy of the lua-language-server, manually starting lsp-mode with M-x lsp prints in the minibuffer:

LSP :: The following servers support current file but automatic download is disabled: lua-language-server copilot-ls
(If you have already installed the server check *lsp-log*).

and there is no lsp-log buffer. I've also disabled lua-roblox-language-server, emmy-lua, and semgrep-ls.

Steps to reproduce

Based on kickstart emacs.

In short, this configuration does:

  1. Disable automatic server downloads
  2. Disable the lua-roblox-language-server, emmy-lua, and semgrep-ls clients
  3. Do NOT automatically start lsp-mode
  4. Set the lsp-clients-lua-language-server-bin after envrc loads the environment
  • I checked manually using describe-variable that this variable is correctly set before starting lsp-mode

Then, do these steps:

  1. Open a Lua file, which has an associated envrc that adds lua-language-server to PATH
  2. Run M-x lsp

The configuration:

    (use-package lsp-mode
      :custom
      (lsp-completion-provider :none) ;; we use Corfu!
      :init
      (defun kickstart/lsp-mode-setup-completion ()
        (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
              '(flex))) ;; Configure flex (corfu)
      ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
      (setq lsp-keymap-prefix "C-l l")
      (setq lsp-enable-suggest-server-download nil) ;; Do not offer to automatically install LSPs at runtime
      (setq lsp-disabled-clients '(lua-roblox-language-server emmy-lua semgrep-ls))
      ;(setq lsp-log-io t)
      (defun cyanide/lsp-mode/set-lua ()
    	"Run before initializing the LS"
    	(progn
    	  (setq lsp-clients-lua-language-server-bin (executable-find "lua-language-server"))
    	  ))
      ;:config
      ;(lsp-register-client
      ;  (make-lsp-client
      ;   :new-connection (lsp-stdio-connection "lua-language-server")
      ;   ;:major-modes '(lua-mode)
      ;   :activation-fn (lsp-activate-on "lua")
      ;   :priority 0
      ;   :server-id 'lua-language-server)
      ;  )

      ;; To Disable features https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/
      :hook (;; Automatic Language Modes
             ;(prog-mode . lsp-deferred)
    		 ;(lsp-before-initialize . cyanide/lsp-mode/set-lua)
    		 ;(lsp-before-open . cyanide/lsp-mode/set-lua)
    		 ;(envrc-after-export . lsp-restart-workspace)
             ;; Which-key integration
             (lsp-mode . lsp-enable-which-key-integration)
             ;; Corfu
             (lsp-completion-mode . kickstart/lsp-mode-setup-completion)
             ;; Envrc
    	     (envrc-mode . cyanide/lsp-mode/set-lua)
    	     )
      :commands (lsp lsp-deferred))
    ;; optionally
    (use-package lsp-ui
      :commands lsp-ui-mode)

Expected behavior

Lsp-mode should find lua-language-server through the lsp-clients-lua-language-server-bin variable and correctly start the language server.

Which Language Server did you use?

lua-language-server

OS

MacOS

Error callstack

There's no error

Anything else?

This seems to be a common problem for users who provide their own lsp server locally, either by adding it to the PATH in the emacs environment or through direnv. Perhaps this workflow should be supported and standardized.

@starptr starptr added the bug label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant