mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-07 03:04:27 +08:00
calculate 'indentation' from shiftwidth. close #78
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" zencoding.vim
|
" zencoding.vim
|
||||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||||
" Last Change: 03-Jun-2012.
|
" Last Change: 04-Jun-2012.
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -23,6 +23,22 @@ function! zencoding#useFilter(filters, filter)
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#getIndentation(...)
|
||||||
|
if a:0 > 0
|
||||||
|
let type = a:1
|
||||||
|
else
|
||||||
|
let type = zencoding#getFileType()
|
||||||
|
endif
|
||||||
|
if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'indentation')
|
||||||
|
let indent = s:zen_settings[type].indentation
|
||||||
|
elseif has_key(s:zen_settings, 'indentation')
|
||||||
|
let indent = s:zen_settings.indentation
|
||||||
|
else
|
||||||
|
let indent = (&l:expandtab || &l:tabstop != &l:shiftwidth) ? repeat(' ', &l:shiftwidth) : "\t"
|
||||||
|
endif
|
||||||
|
return indent
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! zencoding#isExtends(type, extend)
|
function! zencoding#isExtends(type, extend)
|
||||||
if a:type == a:extend
|
if a:type == a:extend
|
||||||
return 1
|
return 1
|
||||||
@@ -106,11 +122,7 @@ function! zencoding#toString(...)
|
|||||||
let filters = ['html']
|
let filters = ['html']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(s:zen_settings, type) && has_key(s:zen_settings[type], 'indentation')
|
let indent = zencoding#getIndentation(type)
|
||||||
let indent = s:zen_settings[type].indentation
|
|
||||||
else
|
|
||||||
let indent = s:zen_settings.indentation
|
|
||||||
endif
|
|
||||||
let itemno = 0
|
let itemno = 0
|
||||||
let str = ''
|
let str = ''
|
||||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||||
@@ -599,7 +611,6 @@ endfunction
|
|||||||
|
|
||||||
unlet! s:zen_settings
|
unlet! s:zen_settings
|
||||||
let s:zen_settings = {
|
let s:zen_settings = {
|
||||||
\ 'indentation': "\t",
|
|
||||||
\ 'lang': "en",
|
\ 'lang': "en",
|
||||||
\ 'charset': "UTF-8",
|
\ 'charset': "UTF-8",
|
||||||
\ 'css': {
|
\ 'css': {
|
||||||
|
|||||||
@@ -7,12 +7,7 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
|
|||||||
let type = a:type
|
let type = a:type
|
||||||
|
|
||||||
let settings = zencoding#getSettings()
|
let settings = zencoding#getSettings()
|
||||||
|
let indent = zencoding#getIndentation(type)
|
||||||
if has_key(settings[type], 'indentation')
|
|
||||||
let indent = settings[type].indentation
|
|
||||||
else
|
|
||||||
let indent = settings.indentation
|
|
||||||
endif
|
|
||||||
|
|
||||||
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||||
|
|
||||||
|
|||||||
@@ -41,12 +41,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
|||||||
if len(type) == 0 | let type = 'html' | endif
|
if len(type) == 0 | let type = 'html' | endif
|
||||||
|
|
||||||
let settings = zencoding#getSettings()
|
let settings = zencoding#getSettings()
|
||||||
|
let indent = zencoding#getIndentation(type)
|
||||||
if has_key(settings[type], 'indentation')
|
|
||||||
let indent = settings[type].indentation
|
|
||||||
else
|
|
||||||
let indent = settings.indentation
|
|
||||||
endif
|
|
||||||
|
|
||||||
" try 'foo' to (foo-x)
|
" try 'foo' to (foo-x)
|
||||||
let rabbr = zencoding#getExpandos(type, abbr)
|
let rabbr = zencoding#getExpandos(type, abbr)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
if exists('g:user_zen_settings')
|
if exists('g:user_zen_settings')
|
||||||
let s:old_user_zen_settings = g:user_zen_settings
|
let s:old_user_zen_settings = g:user_zen_settings
|
||||||
unlet! g:user_zen_settings
|
let g:user_zen_settings = { 'indentation': "\t" }
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:reload(d)
|
function! s:reload(d)
|
||||||
@@ -97,13 +97,13 @@ function! s:testExpandAbbr()
|
|||||||
unlet! res | let res = zencoding#ExpandWord(query, type, 0)
|
unlet! res | let res = zencoding#ExpandWord(query, type, 0)
|
||||||
endif
|
endif
|
||||||
if stridx(result, '$$$$') != -1
|
if stridx(result, '$$$$') != -1
|
||||||
if res == result
|
if res ==# result
|
||||||
call s:show_ok()
|
call s:show_ok()
|
||||||
else
|
else
|
||||||
call s:show_ng(n+1, result, res)
|
call s:show_ng(n+1, result, res)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if res == result
|
if res ==# result
|
||||||
call s:show_ok()
|
call s:show_ok()
|
||||||
else
|
else
|
||||||
call s:show_ng(n+1, result, res)
|
call s:show_ng(n+1, result, res)
|
||||||
|
|||||||
Reference in New Issue
Block a user