unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Questions Regarding LSP Mode For Emacs
@ 2022-01-11 18:26 Samuel Banya
  2022-01-11 19:03 ` Samuel Banya
  2022-01-11 19:27 ` Óscar Fuentes
  0 siblings, 2 replies; 3+ messages in thread
From: Samuel Banya @ 2022-01-11 18:26 UTC (permalink / raw)
  To: Emanuel Berg

Hey there,

I have been trying to incorporate LSP Mode for Emacs to work both on my Linux computers, and my work based Macbook Pro.

The problem is that I don't really see any of the related modes actually working, so I'm wondering if anyone could provide some related advice on how to set up LSP mode easily.

*NOTE: *
 * I wanted to stick all of the language servers into the '~/.emacs.d/' based directory since I don't want to have to search all over for them on a given machine to see if there are any issues.
*
*
*This is a portion of my Emacs config on this topic, the entire config can be found here, '*https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d/configuration.org*':*
*** Add 'lsp-mode' for better autocompletion for many programming languages (python, ruby, java, C++)
#+begin_src emacs-lisp
  (use-package lsp-mode
    :ensure t
    ;; Taken from this page:
    ;; https://www.mattduck.com/lsp-python-getting-started.html
    :hook
    ;; List of modes taken from here:
    ;; https://kb.iu.edu/d/acyg
    ((js-mode
      js-jsx-mode
      typescript-mode
      web-mode
      python-mode
      ruby-mode
      C++-mode
      java-mode
      php-mode
      elixir-mode
      go-mode
      csharp-mode))
    :config
    ;; Set 'lsp-idle-delay' to 0.5 seconds for quick autocompletion
    (setq lsp-idle-delay 0.5)
    ;; Set the 'lsp-server-install-dir' variable so that lsp servers are installed in ~/.emacs.d: 
    (setq lsp-server-install-dir (concat user-emacs-directory "lsp-servers")))
#+end_src

*CONTINUED:*
 * The most specific example of it not working is with 'java' based files on the Macbook for example:

*- This is to fix this error message when opening up a Java file in Emacs with 'lsp-mode':*
#+begin_src text
LSP :: There are no language servers supporting current mode `java-mode' registered with `lsp-mode'.
This issue might be caused by:
1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'.
2. The language server that you expect to run is not configured to run for major mode `java-mode'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'.
3. `lsp-mode' doesn't have any integration for the language behind `java-mode'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').
Quit
#+end_src
- <2021-11-10 Wed 13:50>: Did this just now, but its complaining with this error:
#+begin_src text
File mode specification error: (error Autoloading file /Users/samuelbanya/.emacs.d/elpa/lsp-java-20211109.632/dap-java.elc failed to define function lsp-java)
#+end_src

*CONTINUED:*
 * If anyone could provide advice on this, I would appreciate it :)
 * My main goal would be to somehow get the following languages supported by LSP:
   * Python
   * Ruby
   * JS
   * Typescript
   * Bash

Thanks,

Sam


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions Regarding LSP Mode For Emacs
  2022-01-11 18:26 Questions Regarding LSP Mode For Emacs Samuel Banya
@ 2022-01-11 19:03 ` Samuel Banya
  2022-01-11 19:27 ` Óscar Fuentes
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Banya @ 2022-01-11 19:03 UTC (permalink / raw)
  To: Emanuel Berg

I have since tried to go through the System Crafters video on the topic ("https://www.youtube.com/watch?v=E-NAM9U5JYE").

I have modified my config afterwards as well (https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d/configuration.org), specifically these sections:
`*** Add 'lsp-mode' for better autocompletion for many programming languages (python, ruby, java, C++)`
`*** Add 'typescript-mode' for Typescript support for 'lsp-mode'`
`*** Add 'company' Mode for auto-completion in conjunction with 'lsp-mode'`
`*** Add 'company-box-mode' to have a better looking 'company' mode`
`*** Add 'lsp-java' for Java auto-completion`

On Tue, Jan 11, 2022, at 1:26 PM, Samuel Banya wrote:
> Hey there,
> 
> I have been trying to incorporate LSP Mode for Emacs to work both on my Linux computers, and my work based Macbook Pro.
> 
> The problem is that I don't really see any of the related modes actually working, so I'm wondering if anyone could provide some related advice on how to set up LSP mode easily.
> 
> *NOTE: *
> * I wanted to stick all of the language servers into the '~/.emacs.d/' based directory since I don't want to have to search all over for them on a given machine to see if there are any issues.
> *
> *
> *This is a portion of my Emacs config on this topic, the entire config can be found here, '*https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d/configuration.org*':*
> *** Add 'lsp-mode' for better autocompletion for many programming languages (python, ruby, java, C++)
> #+begin_src emacs-lisp
>   (use-package lsp-mode
>     :ensure t
>     ;; Taken from this page:
>     ;; https://www.mattduck.com/lsp-python-getting-started.html
>     :hook
>     ;; List of modes taken from here:
>     ;; https://kb.iu.edu/d/acyg
>     ((js-mode
>       js-jsx-mode
>       typescript-mode
>       web-mode
>       python-mode
>       ruby-mode
>       C++-mode
>       java-mode
>       php-mode
>       elixir-mode
>       go-mode
>       csharp-mode))
>     :config
>     ;; Set 'lsp-idle-delay' to 0.5 seconds for quick autocompletion
>     (setq lsp-idle-delay 0.5)
>     ;; Set the 'lsp-server-install-dir' variable so that lsp servers are installed in ~/.emacs.d: 
>     (setq lsp-server-install-dir (concat user-emacs-directory "lsp-servers")))
> #+end_src
> 
> *CONTINUED:*
> * The most specific example of it not working is with 'java' based files on the Macbook for example:
> 
> *- This is to fix this error message when opening up a Java file in Emacs with 'lsp-mode':*
> #+begin_src text
> LSP :: There are no language servers supporting current mode `java-mode' registered with `lsp-mode'.
> This issue might be caused by:
> 1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'.
> 2. The language server that you expect to run is not configured to run for major mode `java-mode'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'.
> 3. `lsp-mode' doesn't have any integration for the language behind `java-mode'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
> 4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
> 5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').
> Quit
> #+end_src
> - <2021-11-10 Wed 13:50>: Did this just now, but its complaining with this error:
> #+begin_src text
> File mode specification error: (error Autoloading file /Users/samuelbanya/.emacs.d/elpa/lsp-java-20211109.632/dap-java.elc failed to define function lsp-java)
> #+end_src
> 
> *CONTINUED:*
> * If anyone could provide advice on this, I would appreciate it :)
> * My main goal would be to somehow get the following languages supported by LSP:
>    * Python
>    * Ruby
>    * JS
>    * Typescript
>    * Bash
> 
> Thanks,
> 
> Sam
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions Regarding LSP Mode For Emacs
  2022-01-11 18:26 Questions Regarding LSP Mode For Emacs Samuel Banya
  2022-01-11 19:03 ` Samuel Banya
@ 2022-01-11 19:27 ` Óscar Fuentes
  1 sibling, 0 replies; 3+ messages in thread
From: Óscar Fuentes @ 2022-01-11 19:27 UTC (permalink / raw)
  To: help-gnu-emacs

"Samuel Banya" <sbanya@fastmail.com> writes:

> I have been trying to incorporate LSP Mode for Emacs to work both on
> my Linux computers, and my work based Macbook Pro.
>
> The problem is that I don't really see any of the related modes
> actually working, so I'm wondering if anyone could provide some
> related advice on how to set up LSP mode easily.

> #+begin_src emacs-lisp
>   (use-package lsp-mode
>     :ensure t
>     ;; Taken from this page:
>     ;; https://www.mattduck.com/lsp-python-getting-started.html
>     :hook
>     ;; List of modes taken from here:
>     ;; https://kb.iu.edu/d/acyg
>     ((js-mode
>       js-jsx-mode
>       typescript-mode
>       web-mode
>       python-mode
>       ruby-mode
>       C++-mode
>       java-mode
>       php-mode
>       elixir-mode
>       go-mode
>       csharp-mode))
>     :config
>     ;; Set 'lsp-idle-delay' to 0.5 seconds for quick autocompletion
>     (setq lsp-idle-delay 0.5)
>     ;; Set the 'lsp-server-install-dir' variable so that lsp servers are installed in ~/.emacs.d: 
>     (setq lsp-server-install-dir (concat user-emacs-directory "lsp-servers")))
> #+end_src

I think your use-package is wrong. lsp-mode has an specific entry point
and use-package needs to be told about that fact. See
https://emacs-lsp.github.io/lsp-mode/page/installation/#use-package

I also suggest trying with something simpler than Java to see check that
lsp-mode works. Python looks like a good candidate.

Also ensure the language server is correctly installed. Follow the link
at the end of that page for instructions.

In this case, copy-&-pasting random code from the 'net is not a good
approach. Lsp-mode is well documented, you will save time by following
its instructions.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-11 19:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-11 18:26 Questions Regarding LSP Mode For Emacs Samuel Banya
2022-01-11 19:03 ` Samuel Banya
2022-01-11 19:27 ` Óscar Fuentes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).