Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
919aaf7
Fix elseif parameter highlight
shadowwa Oct 27, 2023
ef9b618
Add forelse keyword
shadowwa Oct 27, 2023
6c654e3
capture can be a tag with opening and ending and can contain append= …
shadowwa Oct 27, 2023
7c64dd3
order properties
shadowwa Oct 27, 2023
82395d4
remove duplicate
shadowwa Oct 27, 2023
43a3842
Add missing properties
shadowwa Oct 27, 2023
eff0f96
add missing properties
shadowwa Oct 27, 2023
24cb6e8
add break and continue construct for foreach
shadowwa Oct 27, 2023
e7d499e
Add foreach properties
shadowwa Oct 27, 2023
7e4c3b4
Support {'string'|modifier} syntax
shadowwa Oct 27, 2023
901195e
Support for variables from config file {#variableName#}
shadowwa Oct 27, 2023
b72f6c4
Take into account 'is dev by' and similar operator, dont consider spa…
shadowwa Oct 29, 2023
f8d0f46
parameters can contain single quote
shadowwa Dec 20, 2024
75f0c0d
take into account middle part of if/for/foreach/section
shadowwa Jan 16, 2025
09142f0
fix indentation for elsif and add doc
shadowwa Feb 14, 2025
2ac594e
fix indentation for line following inline tags (html or smarty)
shadowwa Feb 16, 2025
01c8fdd
useless
shadowwa Feb 16, 2025
c22f121
unit tests
shadowwa Feb 28, 2025
875db9a
pipelines
shadowwa Feb 28, 2025
45af780
vint
shadowwa Feb 28, 2025
62587d7
Create dependabot.yml
shadowwa Feb 28, 2025
baffe45
add failing test
shadowwa Mar 1, 2025
49623ec
more test and fix case where file was not initialy indented with want…
shadowwa Mar 1, 2025
c7d9e6b
fix indentation for multiline conditions
shadowwa Mar 2, 2025
8543646
syntax and indent for smarty tags in <script> tags
shadowwa Mar 2, 2025
d289c53
update tests matrix
shadowwa Mar 2, 2025
181c3a3
update docs
shadowwa Mar 2, 2025
89a35a1
add markdown lint in gh workflow
shadowwa Mar 2, 2025
7f86fac
add unit test for filetype detection and comments syntax highlighting
shadowwa Mar 6, 2025
28fa32c
prevent smarty tags highlighting in smarty comments
shadowwa Mar 6, 2025
89c47b8
Allow smarty comment in script html tags
shadowwa Mar 6, 2025
c289e7a
document additional useful plugins
shadowwa Mar 6, 2025
aa09c12
Bump DavidAnson/markdownlint-cli2-action from 19 to 20
dependabot[bot] May 19, 2025
94de25c
Bump actions/setup-python from 5 to 6
dependabot[bot] Sep 8, 2025
b940480
Merge pull request #1 from shadowwa/dependabot/github_actions/DavidAn…
shadowwa Oct 4, 2025
cdd1b93
Bump actions/checkout from 4 to 6
dependabot[bot] Nov 24, 2025
dc47fa2
Bump DavidAnson/markdownlint-cli2-action from 20 to 21
dependabot[bot] Nov 24, 2025
68eb9f1
Merge pull request #4 from shadowwa/dependabot/github_actions/actions…
shadowwa Nov 24, 2025
5976d9e
Merge pull request #5 from shadowwa/dependabot/github_actions/DavidAn…
shadowwa Nov 24, 2025
5ff86ab
Merge pull request #3 from shadowwa/dependabot/github_actions/actions…
shadowwa Nov 30, 2025
9e7fb04
Bump DavidAnson/markdownlint-cli2-action from 21 to 22
dependabot[bot] Dec 15, 2025
e2bd71e
Merge pull request #6 from shadowwa/dependabot/github_actions/DavidAn…
shadowwa Dec 15, 2025
70528d1
Bump DavidAnson/markdownlint-cli2-action from 22 to 23
dependabot[bot] Mar 30, 2026
819d355
Merge pull request #7 from shadowwa/dependabot/github_actions/DavidAn…
shadowwa Mar 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
69 changes: 69 additions & 0 deletions .github/workflows/vader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Tests on vim and neovim

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
lint:
name: Lint code with Vint and shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# There exists a vint github action but it can't install the alpha
# version. vint has not been moving since 2020 and we need to use the
# alpha release since it fixed some things wrt the latest stable release.
- uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install vint
run: pip install --pre vim-vint
- name: Lint vimscript files
run: vint --warning --enable-neovim ./ftdetect ./ftplugin ./indent ./syntax
- uses: lunarmodules/luacheck@v1
- name: Lint shell scripts
uses: ludeeus/action-shellcheck@master
- name: Lint Markdown files
uses: DavidAnson/markdownlint-cli2-action@v23

tests:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
# bullseye: vim 8.2.2434 neovim 0.4.4
# bookworm: vim 9.0.1378 neovim 0.7.2
# trixie: vim 9.1.0496 neovim 0.9.5
# jammy: vim 8.2.3995 neovim 0.6.1
# mantic: vim 9.0.1672 neovim 0.7.2
# noble: vim 9.1.0016 neovim 0.9.5 <- vim version currently used by github action as vim-stable
# mageia 9: vim 9.1.071 neovim 0.9.5
# mageia cauldron: vim 9.1.1122 neovim 0.10.4
# neovim < 0.9.0 segfaut on github action (even the one installed from apt)
editor: ["vim-v8.0.0000", "vim-v8.2.2434", "vim-v9.1.1122", "nvim-v0.9.0", "nvim-v0.9.5", "nvim-v0.10.4"]

steps:
- uses: actions/checkout@v6
- name: get editor name
env:
EDITORVERSION: ${{matrix.editor}}
id: split
run: |
echo "SELECTEDEDITOR=${EDITORVERSION%%-*}" >> $GITHUB_ENV
echo "SELECTEDVERSION=${EDITORVERSION##*-}" >> $GITHUB_ENV
- name: Setup ${{ matrix.editor }}
uses: rhysd/action-setup-vim@v1
id: vim
with:
neovim: ${{ env.SELECTEDEDITOR == 'nvim' }}
version: ${{ env.SELECTEDVERSION }}
- name: Run Vader unit tests
run: |
TESTVIM=${{ env.SELECTEDEDITOR }}
export TESTVIM
./test/run-tests.sh
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# test
/vader.vim
\#*\#
/.vim/
/.vimrc
## Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
## Session
Session.vim
Sessionx.vim
## Temporary
.netrwhist
*~
## Persistent undo
[._]*.un~
## Auto-generated tag files
tags
GTAGS
GRTAGS
GPATH
137 changes: 118 additions & 19 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Smarty plugin for Vim

This plugin provides syntax highlighting, indenting and general filetype settings for the Smarty templating language.
This plugin provides syntax highlighting, indenting and general filetype
settings for the Smarty templating language.

This is a fork of [Vim Script #1798](http://www.vim.org/scripts/script.php?script_id=1798)
(see the original README below).
Expand All @@ -9,28 +10,126 @@ This is a fork of [Vim Script #1798](http://www.vim.org/scripts/script.php?scrip

The following (probably incomplete) list of enhancements are provided:

* Various improvements throughout the syntax handling.
* `{php}…{/php}` blocks are delegated to PHP syntax.
* `filetype` is set to "smarty" for `*.tpl` files.
* syntax is based on HTML filetype.
* matchit (jumping between tags via `%`) is configured for Smarty tags
(`{foo}` .. `{/foo}`), and based on the html setup.
* line endings have been converted to unix fileformat (to prevent
parse errors on Linux/Mac).
* Smarter indenting, handling PHP blocks and delegating to HTML (includes
JavaScript).
* Various improvements throughout the syntax handling.
* `{php}…{/php}` blocks are delegated to PHP syntax.
* `filetype` is set to "smarty" for `*.tpl` files.
* syntax is based on HTML filetype.
* matchit (jumping between tags via `%`) is configured for Smarty tags
(`{foo}` .. `{/foo}`), and based on the html setup.
* line endings have been converted to unix fileformat (to prevent
parse errors on Linux/Mac).
* Smarter indenting, handling PHP blocks and delegating to HTML (includes
JavaScript).
* Syntax updated to Smarty5
* add doc for variable configuration
* unit tests

## Installation

If you use [Vundle](https://github.com/gmarik/vundle), add the following lines
to your `~/.vimrc`:

```vim
Plugin 'shadowwa/smarty.vim'
```

Then run inside Vim:

```vim
:so ~/.vimrc
:PluginInstall
```

If you use [Pathogen](https://github.com/tpope/vim-pathogen), do this:

```sh
cd ~/.vim/bundle
git clone https://github.com/shadowwa/smarty.vim.git
```

For [vim-plug](https://github.com/junegunn/vim-plug) users:

```vim
Plug 'shadowwa/smarty.vim'
```

in your `.vimrc` or `init.vim`, then restart Vim and run `:PlugInstall`.

## Variables

### indenting

When this variable is set, the indentation is done on html tags and smarty
tags otherwise smarty tags are not indented

```vim
let g:smarty_indent_block = 1
```

```smarty
<div>
<span>
{if $test}
{$variable}
{/if}
</span>
</div>
```

```vim
let g:smarty_indent_block = 0
```

```smarty
<div>
<span>
{if $test}
{$variable}
{/if}
</span>
</div>
```

### Verbose mode for debugging

```vim
let g:smarty_indent_verbose = 1
```

## Testing

Testing is based on vader.vim testing framework, see:
<https://github.com/junegunn/vader.vim> . To run full test suit use
`./test/run-tests.sh`, this will also download vader.vim plugin to project's
folder.

## About Smarty
[Smarty](http://www.smarty.net/) is a PHP template language.

## About this fork
I am not using Smarty that much (anymore), but wanted to get these enhancements
published, for others to pick them up.
[Smarty](https://smarty-php.github.io/smarty/stable/) is a PHP template language.

[Pull requests](https://github.com/shadowwa/smarty.vim) are welcome, of course.

## Additional useful plugins

[Pull requests](https://github.com/blueyed/smarty.vim) are welcome, of course.
* [vim-textobj-smarty](https://github.com/kana/vim-textobj-smarty/) add textobj
for smarty, allowing to work on loop and conditional code with `*ak` and on
content only with `*ik` ([vim-textobj-user](https://github.com/kana/vim-textobj-user)
is also required)
* [vim-snippets](https://github.com/honza/vim-snippets) is a library of
snippets for multiple languages, including Smarty. Works with:
* [snipmate](https://github.com/garbas/vim-snipmate),
* [ultisnips](https://github.com/SirVer/ultisnips) or
* [coc-snippets](https://github.com/neoclide/coc-snippets) if you are using [coc](https://github.com/neoclide/coc.nvim)
* [coc-smarty](https://github.com/shadowwa/coc-smarty) is an extension for [coc](https://github.com/neoclide/coc.nvim),
a test of using [coc-html](https://github.com/neoclide/coc-html) with code
from [vscode-smarty](https://github.com/ssigwart/vscode-smarty)

## Original README

# Original README
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1798
This is a mirror of <http://www.vim.org/scripts/script.php?script_id=1798>

A friend and I found that there were no acceptable vim syntax files for smarty, so we took the only one we could find and added everything from the smarty documentation (http://smarty.php.net/manual/en) to it. If nothing else, this is a very good start on a complete smarty syntax file. We have even used vimtip #498 to use autocomplete with this syntax and so far it seems to work well.
A friend and I found that there were no acceptable vim syntax files for smarty,
so we took the only one we could find and added everything from the smarty
documentation (<http://smarty.php.net/manual/en>) to it. If nothing else,
this is a very good start on a complete smarty syntax file. We have even used
vimtip #498 to use autocomplete with this syntax and so far it seems to work well.
76 changes: 76 additions & 0 deletions doc/smarty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
*smarty.txt* Syntax highlighting

This plugin provides syntax highlighting, indenting and general filetype
settings for the Smarty templating language.
https://smarty-php.github.io/.

The following (probably incomplete) list of enhancements are provided:

* Various improvements throughout the syntax handling.
* `{php}…{/php}` blocks are delegated to PHP syntax.
* `filetype` is set to "smarty" for `*.tpl` files.
* syntax is based on HTML filetype.
* matchit (jumping between tags via `%`) is configured for Smarty tags
(`{foo}` .. `{/foo}`), and based on the html setup.
* line endings have been converted to unix fileformat (to prevent parse
errors on Linux/Mac).
* Smarter indenting, handling PHP blocks and delegating to HTML (includes
JavaScript).
* Syntax updated to Smarty5
* add doc for variable configuration
* unit tests

==============================================================================
VARIABLES *smarty-variables*

Put these variables into your vimrc. The provided examples also indicate the
default values, as long as no "Default:" section is given.

|g:smarty_indent_block|
|g:smarty_indent_verbose|

------------------------------------------------------------------------------
*g:smarty_indent_block*
When this variable is set, the indentation is done on html tags and smarty
tags otherwise smarty tags are not indented

>vim
let g:smarty_indent_block = 1
<
>smarty
<div>
<span>
{if $test}
{$variable}
{/if}
</span>
</div>
<

>vim
let g:smarty_indent_block = 0
<
>smarty
<div>
<span>
{if $test}
{$variable}
{/if}
</span>
</div>
<
------------------------------------------------------------------------------
*g:smarty_indent_verbose*
>vim
let g:smarty_indent_verbose = 1
<
Verbose mode for debugging

==============================================================================
ABOUT *smarty-about*

Grab the latest version or report a bug on GitHub:

https://github.com/shadowwa/smarty.vim

vim:tw=78:et:ft=help:norl:
1 change: 1 addition & 0 deletions ftdetect/smarty.vim
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
" vint: -ProhibitAutocmdWithNoGroup
au BufRead,BufNewFile *.tpl if &ft == '' | setfiletype smarty | endif
22 changes: 13 additions & 9 deletions ftplugin/smarty.vim
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
if exists("b:did_ftplugin") | finish | endif
if exists('b:did_ftplugin') | finish | endif

" Use HTML template ftplugins.
runtime! ftplugin/html.vim

" Append to b:match_words to match smarty tags ("{foo}..{/foo}")
if exists("loaded_matchit")
if exists("b:match_words")
let b:match_words .= ','
else
let b:match_words = ''
endif
let b:match_words .= '{\@<=\([^/][^ \t}]*\)[^}]*\%(}\|$\):{\@<=/\1}'
let b:match_words .= ',{:},\[:\],(:)'
if exists('loaded_matchit')
if exists('b:match_words')
let b:match_words .= ','
else
let b:match_words = ''
endif
let b:match_words .= '{\@<=if:{\@<=elseif:{\@<=else}:{\@<=/if},'
let b:match_words .= '{\@<=foreach :{\@<=foreachelse}:{\@<=break}:{\@<=continue}:{\@<=/foreach},'
let b:match_words .= '{\@<=for :{\@<=forelse}:{\@<=/for},'
let b:match_words .= '{\@<=section :{\@<=sectionelse:{\@<=/section},'
let b:match_words .= '{\@<=\([^/][^ \t}]*\)[^}]*\%(}\|$\):{\@<=/\1}'
let b:match_words .= ',{:},\[:\],(:)'
endif
Loading