1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 02:05:40 +08:00

Update lang#php layer (#4226)

This commit is contained in:
Wang Shidong 2021-04-24 16:47:59 +08:00 committed by GitHub
parent dccedde086
commit 23c05a3caa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 123 additions and 14 deletions

View File

@ -10,8 +10,45 @@
""
" @section lang#php, layer-lang-php
" @parentsection layers
" This layer is for PHP development. It proides code completion, syntax
" checking, and jump to definition.
" This layer is for php development, disabled by default, to enable this
" layer, add following snippet to your SpaceVim configuration file.
" >
" [[layers]]
" name = 'lang#php'
" <
"
" @subsection layer options
"
" 1. `php_interpreter`: Set the PHP interpreter, by default, it is `php`
" >
" [[layers]]
" name = 'lang#php'
" php_interpreter = 'path/to/php'
" <
"
" @subsection Key bindings
" >
" Mode Key Function
" ---------------------------------------------
" normal SPC l r run current file
" <
"
" This layer also provides REPL support for php, the key bindings are:
" >
" Key Function
" ---------------------------------------------
" SPC l s i Start a inferior REPL process
" SPC l s b send whole buffer
" SPC l s l send current line
" SPC l s s send selection text
" <
"
if exists('s:php_interpreter')
finish
endif
let s:php_interpreter = 'php'
@ -31,11 +68,12 @@ let s:auto_fix = 0
function! SpaceVim#layers#lang#php#set_variable(var) abort
let s:auto_fix = get(a:var, 'auto_fix', 0)
let s:php_interpreter = get(a:var, 'php_interpreter', s:php_interpreter)
endfunction
function! SpaceVim#layers#lang#php#config() abort
call SpaceVim#plugins#runner#reg_runner('php', 'php %s')
call SpaceVim#plugins#repl#reg('php', ['php', '-a'])
call SpaceVim#plugins#runner#reg_runner('php', s:php_interpreter . ' %s')
call SpaceVim#plugins#repl#reg('php', [s:php_interpreter, '-a'])
call SpaceVim#mapping#space#regesit_lang_mappings('php',
\ function('s:on_ft'))
if SpaceVim#layers#lsp#check_filetype('php')

View File

@ -2806,8 +2806,41 @@ This layer also provides REPL support for pact, the key bindings are:
==============================================================================
LANG#PHP *SpaceVim-layer-lang-php*
This layer is for PHP development. It proides code completion, syntax
checking, and jump to definition.
This layer is for php development, disabled by default, to enable this layer,
add following snippet to your SpaceVim configuration file.
>
[[layers]]
name = 'lang#php'
<
LAYER OPTIONS
1. `php_interpreter`: Set the PHP interpreter, by default, it is `php`
>
[[layers]]
name = 'lang#php'
php_interpreter = 'path/to/php'
<
KEY BINDINGS
>
Mode Key Function
---------------------------------------------
normal SPC l r run current file
<
This layer also provides REPL support for php, the key bindings are:
>
Key Function
---------------------------------------------
SPC l s i Start a inferior REPL process
SPC l s b send whole buffer
SPC l s l send current line
SPC l s s send selection text
<
==============================================================================
LANG#PONY *SpaceVim-layer-lang-pony*

View File

@ -18,6 +18,7 @@ Each of the following sections will be covered:
- [Enable language layer](#enable-language-layer)
- [Code completion](#code-completion)
- [Syntax linting](#syntax-linting)
- [Ctags integration](#ctags-integration)
- [Jump to test file](#jump-to-test-file)
- [running code](#running-code)
- [Code formatting](#code-formatting)
@ -55,6 +56,21 @@ To install psalm, you may need to run:
composer require --dev vimeo/psalm
```
### Ctags integration
The `gtags` layer provides `ctags` integration for your project. It will create the index file for
each of your project. To enable `gtags` layer:
```toml
[[layers]]
name = 'gtags'
```
With this layer, you can jump to method and class definitions easily (using `ctrl + ]` by default).
Read [gtags](../layers/gtags/) layer for more info.
### Jump to test file
To manage the alternate file for a project, you may need to create a `.project_alt.json` file in the root of your
@ -81,8 +97,9 @@ It is running asynchronously, and will not block your Vim.
### Code formatting
The format layer is also enabled by default. With this layer you can use key binding `SPC b f` to format current buffer.
Before using this feature, please install php_beautifier:
The [format](../layers/format/) layer is also enabled by default.
With this layer you can use key binding `SPC b f` to format current buffer.
Before using this feature, please install [php_beautifier](http://phpbeautifier.com/):
```sh
pear install PHP_Beautifier

View File

@ -10,33 +10,41 @@ description: "PHP language support, including code completion, syntax lint and c
- [Description](#description)
- [Features](#features)
- [Install](#install)
- [Layer options](#layer-options)
- [Key bindings](#key-bindings)
- [Jump to definition](#jump-to-definition)
- [Running current script](#running-current-script)
- [Inferior REPL process](#inferior-repl-process)
<!-- vim-markdown-toc -->
## Description
This layer adds PHP language support to SpaceVim.
`lang#php` layer provides PHP language support in SpaceVim.
## Features
- auto-completion
- syntax checking
- code completion (`autocomplete` layer)
- code formatting (`format` layer)
- syntax checking (`checkers` layer)
- goto definition
- reference finder
- lsp support (require [lsp](https://spacevim.org/layers/language-server-protocol/) layer)
- reference finder (`gtags` layer)
- language server protocol support (`lsp` layer)
## Install
To use this configuration layer, update custom configuration file with:
This layer is not enabled by default. To use this layer, you need to add following
snippet into SpaceVim configuration file:
```toml
[[layers]]
name = "lang#php"
```
## Layer options
- `php_interpreter`: Set the PHP interpreter, by default, it is `php`.
## Key bindings
### Jump to definition
@ -49,3 +57,16 @@ To use this configuration layer, update custom configuration file with:
To running a php script, you can press `SPC l r` to run current file without loss focus,
and the result will be shown in a runner buffer.
### Inferior REPL process
Start a `php` inferior REPL process with `SPC l s i`.
Send code to inferior process commands:
| Key Bindings | Descriptions |
| ------------ | ------------------------------------------------ |
| `SPC l s b` | send buffer and keep code buffer focused |
| `SPC l s l` | send line and keep code buffer focused |
| `SPC l s s` | send selection text and keep code buffer focused |