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

Change php-language-server to Serenata or Phpactor #537

Open
Sasanidas opened this issue Sep 11, 2020 · 8 comments
Open

Change php-language-server to Serenata or Phpactor #537

Sasanidas opened this issue Sep 11, 2020 · 8 comments

Comments

@Sasanidas
Copy link

For now, seems like that still php-language-server it is not maintained, a couple of moths ago I open this pull request to add Serenata(another php lsp server) to lsp-mode, so I'm proposing here to change the php language server for Serenata or maybe the new Phpactor language server.

I have already the phpactor eglot basic configuration working, so I can just clean it a little and it may just work fine.
Also point out this issue, that indicates the state of the php-language-server.

Regards.

@pablobc-mx
Copy link

I also have a basic config with Serenata, but as I've never done any serious PHP development until now and haven't used Phpactor I can't judge which is the better tool between the two.
Still, I found Serenata to be pretty lacking OOTB, compared to other language servers, so maybe Phpactor is better.
I also wonder if php-support should be included at all in eglot, since php-mode is only available in MELPA. phps-mode is on ELPA, so maybe eglot should use that by default.

@Sasanidas
Copy link
Author

I also have a basic config with Serenata, but as I've never done any serious PHP development until now and haven't used Phpactor I can't judge which is the better tool between the two.
Still, I found Serenata to be pretty lacking OOTB, compared to other language servers, so maybe Phpactor is better.
I also wonder if php-support should be included at all in eglot, since php-mode is only available in MELPA. phps-mode is on ELPA, so maybe eglot should use that by default.

Phpactor have more features than Serenata, and it seems like the indexing time and performance is in general better.
There is a little catch, there is a "bug" that I wasn't been able to solve either with lsp-mode or eglot, which is the hover feature, that display basically a "bad message", it is not a big deal for me, specially with eglot that you can easily disable it, but still, something to take account on, and another minor inconvenience is that code actions doesn't work at all, I didn't investigate this issue so, don't know why really happens.

In regard of the php-mode, I'm agree, the ELPA phps-mode is getting better, and the semantic integration seems pretty promising, but php-mode is more popular, so I think that it is not a bad idea to support both.

Also, in the (I hope) not so distance future, Phpactor would include some refactoring features, which are a great tool to have in Emacs.

@nemethf
Copy link
Collaborator

nemethf commented May 18, 2021

Eglot nowadays supports both php-mode and phps-mode.

I'm afraid João is not a big fan of this idea, but instead of changing the default server, can you just follow the example in #688 and support every one of them?

@joaotavora
Copy link
Owner

@nemeth what exactly is the idea?

Eglot supports any LSP server, the question here is what server to suggest as the default 0-config one. For that, I'm usually content with having Eglot suggest whatever the majority of people seem to indicate as the most stable, functional server. But it is fairly easy to change he suggestion to another one with a one-at-most-two-liner in your .emacs, so I don't think adding code to suggest more than one server is a priority right now.

That said, if you can come up with a 10-20 loc solution to this we can look at it.

@nemethf
Copy link
Collaborator

nemethf commented May 21, 2021

@nemethf what exactly is the idea?

Eglot supports any LSP server, the question here is what server to suggest as the default 0-config one. For that, I'm usually content with having Eglot suggest whatever the majority of people seem to indicate as the most stable, functional server. But it is fairly easy to change he suggestion to another one with a one-at-most-two-liner in your .emacs, so I don't think adding code to suggest more than one server is a priority right now.

Currently, Eglot works out-of-the-box with the most popular server for a particular major-mode. It would be nice if Eglot cloud support multiple popular servers out-of-the-box. I don't see any theoretical differences between the two cases.

That said, if you can come up with a 10-20 loc solution to this we can look at it.

Well, I gave it a try, but I'm unable to write it the way I want. Here is what I currently have:

(setq eglot-server-programs
      '((python-mode . (eglot-compound-server :alternatives
                                              (("pyls")
                                               ("pylsp"))))))

(defclass eglot-compound-server (eglot-lsp-server)
  ((alternatives :initarg :alternatives)))

(cl-defmethod initialize-instance :before ((server eglot-compound-server) &rest slots)
  (let ((alternatives (plist-get (car slots) :alternatives))
	;; eglot--connect uses lots of `setf's instead of initargs
	;; like: (setf (eglot--project server) project)
	;; so nickname, project-root are not available here
	(readable-name "nickname")
        cmd)
    ;; Use cl-loop instead?
    (dolist (alt (reverse alternatives))
      (when (executable-find (car alt))
        (setq cmd alt)))
    (when (not cmd)
      (setq cmd (car alternatives)))
    (message "cmd: %s" cmd)
    ;; This doesn't set the slot's value :(
    (setf (jsonrpc--process server)
	  (make-process
           :name readable-name
           :command cmd
           :connection-type 'pipe
           :coding 'utf-8-emacs-unix
           :noquery t
           :stderr (get-buffer-create
                    (format "*%s stderr*" readable-name))
           :file-handler t))))

@joaotavora
Copy link
Owner

Well, I gave it a try, but I'm unable to write it the way I want. Here is what I currently have:

I actually like this solution since it doesn't need new syntax in eglot-server-programs. So modulo eglot-compound-server 's implementation (and maybealso the name), it's a decent approach. The only problem I see is Eglot's statements of I guess you want to run xxx but I can't find it in PATH which wouldn't work here. Not very important anyway.

@joaotavora
Copy link
Owner

So modulo eglot-compound-server 's implementation (and maybealso the name), it's a decent approach. The only problem I see is Eglot's statements of I guess you want to run xxx but I can't find it in PATH which wouldn't work here. Not very important anyway.

Actually never mind that last comment, this seems to be much easier to implement:

(defun eglot-alternatives (alternatives)
  (lambda (&optional interactive)
    (cl-loop for a in alternatives
             for a = (if (listp a) a (list a))
             when (executable-find (car a)) return a)))

(add-to-list 'eglot-server-programs
             `(python-mode . ,(eglot-alternatives '("pyls" "pylsp"))))

Do you see any drawback in this?

joaotavora added a commit that referenced this issue May 22, 2021
* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): use it.
joaotavora added a commit that referenced this issue May 22, 2021
Also per #537.

* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it.  Use clangd and pylsp.

* NEWS.md: Mention feature.

* README.md (Connecting to a server): Mention pylsp and clangd.
@nemethf
Copy link
Collaborator

nemethf commented May 26, 2021

Do you see any drawback in this?

No. The version on master is quite nice and concise. Thanks.

@Sasanidas, @pablobc-mx: if you provide start commands for the new php servers, this issue can proceed. A pull request adding eglot-alternatives would be even better. See

eglot/eglot.el

Lines 119 to 120 in a5b7b7d

(python-mode
. ,(eglot-alternatives '("pyls" "pylsp")))

@skangas skangas changed the title Change php-language-server Change php-language-server to Serenata or Phpactor Jan 9, 2022
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 18, 2022
…e mode

Also per joaotavora/eglot#537.

* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it.  Use clangd and pylsp.

* NEWS.md: Mention feature.

* README.md (Connecting to a server): Mention pylsp and clangd.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
…e mode

Also per joaotavora/eglot#537.

* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it.  Use clangd and pylsp.

* NEWS.md: Mention feature.

* README.md (Connecting to a server): Mention pylsp and clangd.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
Also per #537.

* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it.  Use clangd and pylsp.

* NEWS.md: Mention feature.

* README.md (Connecting to a server): Mention pylsp and clangd.

#688: joaotavora/eglot#688
#537: joaotavora/eglot#537
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Oct 12, 2022
Also per joaotavora/eglot#537.

* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it.  Use clangd and pylsp.

* NEWS.md: Mention feature.

* README.md (Connecting to a server): Mention pylsp and clangd.

GitHub-reference: fix joaotavora/eglot#688
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants