Skip to content

Commit 1081084

Browse files
committed
Update README with syntax overriding snippets.
1 parent 7147336 commit 1081084

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Installation
1010

1111
If you don't have a preferred installation method, [vim-plug] is quick and simple. With [vim-plug installed], add the following to your `vimrc` (if you are a NeoVim user, see the [FAQ page][neovim-faq] for help):
1212

13-
```vimscript
13+
```vim
1414
Plug 'StanAngeloff/php.vim'
1515
```
1616

@@ -59,16 +59,16 @@ Configuration
5959

6060
### Overriding highlighting
6161

62-
Syntax highlighting can be controlled at a fine-grained level allowing you to distinguish groups by overriding defaults. For example, all code in PHP comments is highlighted as `phpComment` by default, however there are groups you can tweak, e.g., how PHPDoc `@tags` appear. There are [several groups you can choose from](syntax-groups).
62+
Syntax highlighting can be controlled at a fine-grained level. For example, all text in PHP comments is highlighted as `phpComment` by default, however there are smaller syntax groups you can tweak, e.g., how PHPDoc `@tags` appear. There are [several syntax groups you can choose from](syntax-groups).
6363

6464
Example: Overriding PHP `@tags` and `$parameters` in comments to appear as a different highlighting group, giving them distinct colouring:
6565

66-
```vimscript
67-
" Put this snippet at the very end of your vimrc file.
66+
```vim
67+
" Put this function at the very end of your vimrc file.
6868
6969
function! PhpSyntaxOverride()
70-
" Put overrides in this function.
71-
hi! link phpDocTags phpDefine
70+
" Put snippet overrides in this function.
71+
hi! link phpDocTags phpDefine
7272
hi! link phpDocParam phpType
7373
endfunction
7474
@@ -78,18 +78,26 @@ augroup phpSyntaxOverride
7878
augroup END
7979
```
8080

81-
You may optionally assign specific colouring to groups in the `PhpSyntaxOverride` function:
81+
#### Snippets
8282

83-
```vimscript
84-
" […]
83+
You may add the code snippets below to your `PhpSyntaxOverride` function (see above for instructions on how to create this function).
8584

86-
function! PhpSyntaxOverride()
87-
" Highlight the backslash in use, extends and implements in grey.
88-
hi phpUseNamespaceSeparator guifg=#808080 guibg=NONE gui=NONE
89-
hi phpClassNamespaceSeparator guifg=#808080 guibg=NONE gui=NONE
90-
endfunction
85+
##### Colourising namespace separator in `use`, `extends` and `implements`
86+
87+
If you wish to highlight the namespace separator `\` differently ([original request](https://github.com/StanAngeloff/php.vim/issues/63)):
88+
89+
```vim
90+
hi phpUseNamespaceSeparator guifg=#808080 guibg=NONE gui=NONE
91+
hi phpClassNamespaceSeparator guifg=#808080 guibg=NONE gui=NONE
92+
```
93+
94+
##### Colourising parentheses
95+
96+
If you wish to highlight `(` and `)` differently ([original request](https://github.com/StanAngeloff/php.vim/issues/31#issuecomment-52879108)):
9197

92-
" […]
98+
```vim
99+
syn match phpParentOnly "[()]" contained containedin=phpParent
100+
hi phpParentOnly guifg=#f08080 guibg=NONE gui=NONE
93101
```
94102

95103
Developing

0 commit comments

Comments
 (0)