├── ftdetect └── play2.vim ├── test ├── conf │ ├── application.conf │ └── routes └── app │ └── views │ ├── main.scala.html │ └── index.scala.html ├── syntax ├── play2-conf.vim ├── play2-text.vim ├── play2-routes.vim └── play2-html.vim ├── indent └── play2-html.vim └── README.md /ftdetect/play2.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.scala.html set filetype=html syntax=play2-html 2 | au BufRead,BufNewFile *.scala.txt set filetype=txt syntax=play2-text 3 | au BufRead,BufNewFile */conf/\(*\|\)routes set filetype=play2-routes 4 | au BufRead,BufNewFile */conf/*.conf setf play2-conf 5 | au BufRead,BufNewFile plugins.sbt set filetype=scala 6 | 7 | -------------------------------------------------------------------------------- /test/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | application.secret="QfpRx>t9dXh:=NsantZ8jDssuBIJ=jerv=aUjjeZ45U3rB>lTsPWS1c?7[YJogMH" 6 | 7 | # Database configuration 8 | # ~~~~~ 9 | db.default.driver=org.h2.Driver 10 | db.default.url="jdbc:h2:mem:play" 11 | db.default.user=sa 12 | db.default.password= 13 | 14 | # Logger 15 | # ~~~~~ 16 | logger=ERROR 17 | logger.play=INFO 18 | logger.application=DEBUG 19 | -------------------------------------------------------------------------------- /test/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @********************* 14 | * This is a comment * 15 | *********************@ 16 | @content 17 | 18 | @if(level == "success") { 19 |

20 | @body("green") 21 |

22 | } 23 | 24 | @if(level == "warning") { 25 |

26 | @body("orange") 27 |

28 | } 29 | 30 | @if(level == "error") { 31 |

32 | @body("red") 33 |

34 | } 35 | 36 | @for((foo, number) <- fooList.view.zipWithIndex) { 37 |
@(foo) is number @number
38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /syntax/play2-conf.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Play framework 2 - the conf file 3 | " Maintainer: Gaëtan Renaudeau 4 | " URL: http://github.com/gre/play2vim 5 | " Last Change: 2011 Dec 12 6 | " Fork From: conf.vim 7 | 8 | " Quit when a (custom) syntax file was already loaded 9 | if exists("b:current_syntax") 10 | finish 11 | endif 12 | 13 | syn match confComment "^#.*" 14 | syn match confComment "\s#.*"ms=s+1 15 | syn region confString start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline 16 | syn region confString start=+'+ skip=+\\\\\|\\'+ end=+'+ oneline 17 | 18 | syn match confKey "^[^=#]\+="me=e-1 19 | syn match confValue "=.*$"ms=s+1 contains=confString,confComment 20 | 21 | " Define the default highlighting. 22 | " For version 5.7 and earlier: only when not done already 23 | " For version 5.8 and later: only when an item doesn't have highlighting yet 24 | if version >= 508 || !exists("did_play2conf_syn_inits") 25 | if version < 508 26 | let did_play2conf_syn_inits = 1 27 | command -nargs=+ HiLink hi link 28 | else 29 | command -nargs=+ HiLink hi def link 30 | endif 31 | 32 | HiLink confComment Comment 33 | HiLink confString String 34 | HiLink confKey Identifier 35 | HiLink confValue Special 36 | 37 | delcommand HiLink 38 | endif 39 | 40 | let b:current_syntax = "play2-conf" 41 | 42 | " vim: ts=8 sw=2 43 | -------------------------------------------------------------------------------- /test/conf/routes: -------------------------------------------------------------------------------- 1 | # Routes 2 | # This file defines all application routes (Higher priority routes first) 3 | # ~~~~ 4 | 5 | GET / controllers.Application.index 6 | GET /computers controllers.Application.list(p:Int ?= 0, s:Int ?= 2, f ?= "") 7 | GET /computers/:id controllers.Application.get(id:Long) 8 | GET /assets/*file controllers.Assets.at(path="/public", file) 9 | 10 | # Tasks 11 | GET /projects/:project/tasks controllers.Tasks.index(project: Long) 12 | POST /projects/:project/tasks controllers.Tasks.add(project: Long, folder: String) 13 | PUT /tasks/:task controllers.Tasks.update(task: Long) 14 | DELETE /tasks/:task controllers.Tasks.delete(task: Long) 15 | 16 | POST /tasks/folder controllers.Tasks.addFolder 17 | DELETE /projects/:project/tasks/folder controllers.Tasks.deleteFolder(project: Long, folder: String) 18 | PUT /project/:project/tasks/folder controllers.Tasks.renameFolder(project: Long, folder: String) 19 | 20 | # special cases 21 | GET / controllers.Application.show(page = "home") 22 | GET /:page controllers.Application.show(page) 23 | GET /clients controllers.Clients.list(page: Int ?= 1) 24 | GET /clients/$id<[0-9]+> controllers.Clients.show(id: Long) 25 | -------------------------------------------------------------------------------- /indent/play2-html.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language: play2-html 3 | " Maintainer: alswl 4 | " Last Change: 2012/07/25 5 | 6 | if exists("b:did_indent") 7 | finish 8 | endif 9 | let b:did_indent = 1 10 | runtime! indent/html.vim 11 | runtime! indent/html5.vim 12 | 13 | setlocal autoindent sw=4 noet 14 | setlocal indentexpr=GetPlay2HtmlIndent() 15 | setlocal indentkeys=*,}, 16 | 17 | let s:tags = ['if', 'list', 'else', 'elseif', 'cache', 'form', 'ifError', 'ifErros', 'ifnot', 'errors'] 18 | 19 | " Only define the function once. 20 | if exists("*GetPlay2HtmlIndent") 21 | finish 22 | endif 23 | 24 | function! GetPlay2HtmlIndent() 25 | let lnum = prevnonblank(v:lnum-1) 26 | if lnum == 0 27 | return 0 28 | endif 29 | let line = substitute(getline(lnum),'\s\+$','','') 30 | let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') 31 | let lastcol = strlen(line) 32 | let line = substitute(line,'^\s\+','','') 33 | let indent = indent(lnum) 34 | let cindent = indent(v:lnum) 35 | 36 | let increase_tags_re = '' 37 | let increase_tags = [] 38 | let decrease_tags_re = '' 39 | let decrease_tags = [] 40 | for i in s:tags 41 | call add(increase_tags, '^\s*#{\s*' . i) 42 | call add(decrease_tags, '^\s*#{\s*/' . i) 43 | endfor 44 | let increase_tags_re = join(increase_tags, '\|') 45 | let decrease_tags_re = join(decrease_tags, '\|') 46 | 47 | if line =~ increase_tags_re 48 | return indent + &sw 49 | elseif cline =~ decrease_tags_re 50 | return indent - &sw 51 | else 52 | return HtmlIndentGet(v:lnum) 53 | endif 54 | endfunction 55 | 56 | 57 | " vim:set sw=2 et: 58 | -------------------------------------------------------------------------------- /test/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(project:Project, tasks: Seq[Task], team: Seq[User]) 2 | 3 | @* 4 | * This is a random code from a Play20 sample app 5 | *@ 6 | 7 | @main { 8 | @@escapedAtSign @@ 9 |
10 |
11 |

@project.folder

12 |

@project.name

13 |
14 |
15 |
Project's team
16 |
17 |
18 |

Team mates

19 |
20 | @team.map { user => 21 |
22 |
@user.name (@user.email)
23 |
Action
24 |
25 | } 26 |
27 |

Add a team mate

28 |
29 | @User.findAll.diff(team).map { user => 30 |
31 |
@user.name (@user.email)
32 |
Action
33 |
34 | } 35 |
36 |
37 |
38 |
39 |
40 |
41 | @tasks.groupBy(_.folder).map { 42 | case (folder, tasks) => { 43 | @views.html.tasks.folder(folder, tasks) 44 | } 45 | } 46 | New folder 47 |
48 | } 49 | 50 | -------------------------------------------------------------------------------- /syntax/play2-text.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Play2 Text scala template 3 | " Maintainer: Gaëtan Renaudeau 4 | " URL: http://github.com/gre/play2vim 5 | " Last change: 2011 December 14 6 | 7 | if version < 600 8 | syntax clear 9 | elseif exists("b:current_syntax") 10 | finish 11 | endif 12 | 13 | syn include @scala syntax/scala.vim 14 | 15 | syn match phExprIdentifier "#" nextgroup=phExpr 16 | syn match phExprIdentifier "@" nextgroup=phExpr 17 | syn match phExprIdentifier /@[A-Za-z0-9._]\+/ nextgroup=phExpr 18 | syn match phExprIdentifier /@[A-Za-z0-9._]\+\s\+match\s*/ nextgroup=phExpr 19 | syn region phComment start=/^\s*\*{/ end=/}\*\s*$/ 20 | syn region phComment start=/@[*]/ end=/[*]@/ 21 | syn match phOverrided "@@" 22 | 23 | syn region phExpr matchgroup=phExprIdentifier start="(" end=")" contains=@scala,phExpr contained nextgroup=phExpr 24 | syn region phExpr matchgroup=phExprIdentifier start="{" end="}" contains=@scala,phExpr contained nextgroup=phExpr 25 | syn region phExpr matchgroup=phExprIdentifier start="\[" end="\]" contains=@scala,phExpr contained nextgroup=phExpr 26 | 27 | " Define the default highlighting. 28 | " For version 5.7 and earlier: only when not done already 29 | " For version 5.8 and later: only when an item doesn't have highlighting yet 30 | if version >= 508 || !exists("did_play2text_syn_inits") 31 | if version < 508 32 | let did_play2text_syn_inits = 1 33 | command -nargs=+ HiLink hi link 34 | else 35 | command -nargs=+ HiLink hi def link 36 | endif 37 | 38 | HiLink phExprIdentifier Identifier 39 | HiLink phComment Comment 40 | HiLink phOverrided Default 41 | 42 | delcommand HiLink 43 | endif 44 | 45 | let b:current_syntax = "play2-text" 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | play2vim 2 | ======== 3 | A vim plugin for Play framework 2.0. 4 | 5 | Install 6 | --- 7 | 8 | **Using [pathogen](https://github.com/tpope/vim-pathogen)**: 9 | ``` 10 | cd .vim/bundle 11 | git clone https://github.com/gre/play2vim.git 12 | ``` 13 | 14 | **Using [Vundle](https://github.com/VundleVim/Vundle.vim)**: 15 | 16 | Add the following line to your `.vimrc`: 17 | ``` 18 | Plugin 'gre/play2vim' 19 | ``` 20 | After that, run `:PluginInstall` in vim 21 | 22 | Or 23 | 24 | From your terminal, run `vim +PluginInstall +qall` 25 | 26 | 27 | Recommended plugins 28 | ------------------- 29 | * [vim-scala](http://github.com/derekwyatt/vim-scala) (http://github.com/derekwyatt/vim-scala) 30 | * [html5.vim](http://github.com/othree/html5.vim) (http://github.com/othree/html5.vim) 31 | 32 | What's in the box? 33 | ------------------ 34 | * `conf/routes` syntax color 35 | * `conf/application.conf` syntax color 36 | * `*.scala.html` syntax color 37 | 38 | ![screenshot](http://i.imgur.com/EjuRK.png) 39 | 40 | More will come soon. 41 | 42 | I would be happy to accept any contributions to this project. 43 | 44 | 45 | Licence 46 | ======= 47 | This software is licensed under the Apache 2 license, quoted below. 48 | 49 | Copyright 2011 Gaëtan Renaudeau 50 | 51 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 52 | 53 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 54 | -------------------------------------------------------------------------------- /syntax/play2-routes.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Play framework 2 - the routes file 3 | " Maintainer: Gaëtan Renaudeau 4 | " URL: http://github.com/gre/play2vim 5 | " Last Change: 2011 Dec 12 6 | 7 | " For version 5.x: Clear all syntax items 8 | " For version 6.x: Quit when a syntax file was already loaded 9 | if version < 600 10 | syntax clear 11 | elseif exists("b:current_syntax") 12 | finish 13 | endif 14 | 15 | syn match routesRegexp "<[^>]\+>" 16 | syn match routesParam /[:*][A-Za-z0-9]\+/ 17 | syn match routesParam /\($[A-Za-z0-9]\+\)<[^>]\+>/ contains=routesRegexp 18 | 19 | syn include @scala syntax/scala.vim 20 | 21 | syn region routesActionArgs matchgroup=routesAction start="(" end=")" contains=@scala contained oneline 22 | syn region routesString start=+"+ end=+"+ oneline 23 | 24 | syn keyword routesHttpMethod GET PUT PATCH POST DELETE HEAD OPTIONS contained 25 | syn region routesMethod start="^" end=/\s/ contains=routesHttpMethod nextgroup=routesPath skipwhite oneline 26 | syn region routesPath start="/" end=/\s/ contains=routesParam nextgroup=routesAction skipwhite oneline 27 | syn region routesAction start=/[a-zA-Z]\+\./ end="$" contains=routesActionArgs skipwhite oneline 28 | syn match routesComment "#.*" contains=routesComment 29 | 30 | " Define the default highlighting. 31 | " For version 5.7 and earlier: only when not done already 32 | " For version 5.8 and later: only when an item doesn't have highlighting yet 33 | if version >= 508 || !exists("did_play2routes_syn_inits") 34 | if version < 508 35 | let did_play2routes_syn_inits = 1 36 | command -nargs=+ HiLink hi link 37 | else 38 | command -nargs=+ HiLink hi def link 39 | endif 40 | 41 | HiLink routesHttpMethod Statement 42 | HiLink routesRegexp Statement 43 | HiLink routesPath Special 44 | HiLink routesAction Underlined 45 | HiLink routesParam Identifier 46 | HiLink routesComment Comment 47 | HiLink routesString String 48 | 49 | delcommand HiLink 50 | endif 51 | 52 | let b:current_syntax = "play2-routes" 53 | 54 | -------------------------------------------------------------------------------- /syntax/play2-html.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Play2 HTML scala template 3 | " Maintainer: Gaëtan Renaudeau 4 | " URL: http://github.com/gre/play2vim 5 | " Last change: 2011 December 14 6 | 7 | if version < 600 8 | syntax clear 9 | elseif exists("b:current_syntax") 10 | finish 11 | endif 12 | 13 | " Source HTML syntax 14 | if version < 600 15 | source :p:h/html.vim 16 | source :p:h/html/html5.vim 17 | else 18 | runtime! syntax/html.vim 19 | runtime! syntax/html/html5.vim 20 | endif 21 | unlet b:current_syntax 22 | 23 | syn include @scala syntax/scala.vim 24 | 25 | syn match phExprIdentifier "#" nextgroup=phExpr 26 | syn match phExprIdentifier "@" nextgroup=phExpr 27 | syn match phExprIdentifier /@[A-Za-z0-9._]\+/ nextgroup=phExpr 28 | syn region phComment start=/^\s*\*{/ end=/}\*\s*$/ 29 | syn region phComment start=/@[*]/ end=/[*]@/ 30 | syn match phOverrided "@@" 31 | 32 | syn region phExpr matchgroup=phExprIdentifier start="(" end=")" contains=@scala,phExpr contained nextgroup=phExpr 33 | syn region phExpr matchgroup=phExprIdentifier start="{" end="}" contains=@scala,phExpr contained nextgroup=phExpr 34 | syn region phExpr matchgroup=phExprIdentifier start="\[" end="\]" contains=@scala,phExpr contained nextgroup=phExpr 35 | syn region htmlTag start=+<[^/%]+ end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster,phExpr 36 | 37 | " Define the default highlighting. 38 | " For version 5.7 and earlier: only when not done already 39 | " For version 5.8 and later: only when an item doesn't have highlighting yet 40 | if version >= 508 || !exists("did_play2html_syn_inits") 41 | if version < 508 42 | let did_play2html_syn_inits = 1 43 | command -nargs=+ HiLink hi link 44 | else 45 | command -nargs=+ HiLink hi def link 46 | endif 47 | 48 | HiLink phExprIdentifier Identifier 49 | HiLink phComment Comment 50 | HiLink phOverrided Default 51 | 52 | delcommand HiLink 53 | endif 54 | 55 | let b:current_syntax = "play2-html" 56 | --------------------------------------------------------------------------------