emacs-php / php-ts-mode

A Tree-sitter based major mode for editing PHP codes
GNU General Public License v3.0
17 stars 8 forks source link

completion-at-point not working with 'php-ts-mode' #63

Closed otrocodigo closed 4 months ago

otrocodigo commented 4 months ago

I have a basic startup file, I just install tree-sitter-php and load php-ts-mode.

;; init.el
(load-theme 'wombat)

(setq treesit-language-source-alist
      '((php "https://github.com/tree-sitter/tree-sitter-php" "master" "php/src")))

(mapc #'treesit-install-language-grammar '(php))

(add-to-list 'load-path (concat user-emacs-directory "php-ts-mode"))
(require 'php-ts-mode)

I open a *.php file and activate eglot with phpactor as lsp.

I position on some method and call completion-at-point but I don't get any suggestions.

I repeat the steps with php-mode (not tree-sitter) and if I get suggestions.

completion-at-point on php-mode

I tried with another lsp client like lsp-mode or lsp server like intelephense and the same thing happens: it works fine with php-mode but not with php-ts-mode.


GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) of 2023-09-11, modified by Debian

piotrkwiecinski commented 4 months ago

@otrocodigo the update to eglot to enable php-ts-mode was just recently added to emacs-29 branch https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68870. It wasn't available in the build from 2023-09-11.

You should try adding in meantime:

(require 'eglot)
(add-to-list 'eglot-server-programs
             '(php-ts-mode . ("phpactor" "language-server")))

For lsp-mode:

(require 'lsp-mode)
(add-to-list 'lsp-language-id-configuration '(php-ts-mode . "php"))

or use a melpa version of the lsp package from feb or later https://github.com/emacs-lsp/lsp-mode/pull/4318

otrocodigo commented 4 months ago

Thank @piotrkwiecinski . I compiled version 30.0.50 and it seems to work fine php-ts-mode + eglot