From a1731c718de7b1946ab104cf04a51a370a45bc1f Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 30 May 2012 21:12:34 +0900 Subject: [PATCH] toggleComment for slim --- autoload/zencoding.vim | 25 +++++++++++++++---------- autoload/zencoding/lang/slim.vim | 8 +++++++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index 85d8823..a495409 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -218,17 +218,22 @@ function! zencoding#getFileType() if type == 'htmldjango' | let type = 'html' | endif if type == 'html.django_template' | let type = 'html' | endif if type == 'scss' | let type = 'css' | endif - if synIDattr(synID(line("."), col("."), 1), "name") =~ '^css' - let type = 'css' + if len(type) == 0 && len(globpath(&rtp, 'autoload/zencoding/lang/'.&ft.'.vim')) + let type = &ft endif - if synIDattr(synID(line("."), col("."), 1), "name") =~ '^html' - let type = 'html' - endif - if synIDattr(synID(line("."), col("."), 1), "name") =~ '^javaScript' - let type = 'javascript' - endif - if len(type) == 0 && synIDattr(synID(line("."), col("."), 1), "name") =~ '^xml' - let type = 'xml' + if type == 'html' + if synIDattr(synID(line("."), col("."), 1), "name") =~ '^css' + let type = 'css' + endif + if synIDattr(synID(line("."), col("."), 1), "name") =~ '^html' + let type = 'html' + endif + if synIDattr(synID(line("."), col("."), 1), "name") =~ '^javaScript' + let type = 'javascript' + endif + if len(type) == 0 && synIDattr(synID(line("."), col("."), 1), "name") =~ '^xml' + let type = 'xml' + endif endif if len(type) == 0 | let type = 'html' | endif return type diff --git a/autoload/zencoding/lang/slim.vim b/autoload/zencoding/lang/slim.vim index 591688b..29abf3d 100644 --- a/autoload/zencoding/lang/slim.vim +++ b/autoload/zencoding/lang/slim.vim @@ -105,5 +105,11 @@ function! zencoding#lang#slim#parseTag(tag) endfunction function! zencoding#lang#slim#toggleComment() - " TODO + let line = getline('.') + let space = matchstr(line, '^\s*') + if line =~ '^\s*/' + call setline('.', space . line[len(space)+1:]) + elseif line =~ '^\s*[a-z]' + call setline('.', space . '/' . line[len(space):]) + endif endfunction