Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Tree-sitter based major mode for editing PHP codes

License

NotificationsYou must be signed in to change notification settings

emacs-php/php-ts-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Tree-sitter based major mode for editing PHP codes.

Note

This package is based on Emacs 29's built-intreesit andc-ts-common features.
php-ts-mode has been tested withv0.21.1 oftree-sitter-php.

How to install

If you haven't installed Tree-sitter yet, please readHow to Get Started with Tree-Sitter - Mastering Emacs. At this point, Tree-sitter may be too early for those who cannot compile and install it themselves. You will end up recompiling it with every future update oftree-sitter-php.

Package can be installed by running the following command.

M-x package-vc-install [RET] https://github.com/emacs-php/php-ts-mode

Configuration

Example configuration that you can put in your.emacs file

;; Enable variables highlighting(customize-set-variable 'treesit-font-lock-level 4)(add-hook 'php-ts-mode-hook (lambda ()      ;; Use spaces for indent      (setq-local indent-tabs-mode nil)))

Grammer installation

If you don't already havephp-ts-mode installed, please evaluate the Lisp code below.

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

RunningM-x treesit-install-language-grammar [RET] php will compile and install the latesttree-sitter-php.

Settings

Syntax highlighting

Inphp-ts-mode, syntax elements are classified as follows.

  • Level 1:commentdefinitionpreprocessor
  • Level 2:keywordstringtype
  • Level 3:functionconstantlabel
  • Level 4:bracketdelimiteroperatorvariablesthis

By default, up toLevel 3 will be highlighted.

How to develop

  1. Chekouttree-sitter-php to your computer.
  2. Domake install

Copyright

This code is currently based onjava-ts-mode.

Copyright (C) 2022-2023 Free Software Foundation, Inc.Copyright (C) 2023 Friends of Emacs-PHP development

This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.

You should have received a copy of the GNU General Public Licensealong with this program. If not, seehttps://www.gnu.org/licenses/.

There are plans to transfer this project to GNU Emacs, so if you haven't assigned a copyright to the FSF yet, please refer to theOrg-mode contribute guide and send me an email!

About

A Tree-sitter based major mode for editing PHP codes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp