add filetype support

This commit is contained in:
Yggdroot
2013-03-05 17:28:40 +08:00
parent 927d494512
commit 2a53c50380
2 changed files with 57 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
" Script Name: indentLine.vim
" Version: 1.0.4
" Last Change: Jan 23, 2013
" Version: 1.0.5
" Last Change: March 5, 2013
" Author: Yggdroot <archofortune@gmail.com>
"
" Description: To show the indent lines
@@ -11,8 +11,8 @@ if !has("conceal") || exists("g:indentLine_loaded")
endif
let g:indentLine_loaded = 1
" | ¦ ┆ │
if !exists("g:indentLine_char")
" | ¦ ┆ │
if &encoding ==? "utf-8"
let g:indentLine_char = "¦"
else
@@ -28,6 +28,14 @@ if !exists("g:indentLine_enabled")
let g:indentLine_enabled = 1
endif
if !exists("g:indentLine_fileType")
let g:indentLine_fileType = "*"
endif
if !exists("g:indentLine_fileTypeExclude")
let g:indentLine_fileTypeExclude = ""
endif
set conceallevel=1
set concealcursor=inc
@@ -59,13 +67,7 @@ endfunction
"{{{1 function! <SID>SetIndentLine()
function! <SID>SetIndentLine()
if !exists("b:indentLine_enabled")
let b:indentLine_enabled = g:indentLine_enabled
if !b:indentLine_enabled
return
endif
endif
let b:indentLine_enabled = 1
let space = &l:shiftwidth
for i in range(space+1, space * g:indentLine_indentLevel + 1, space)
exec 'syn match IndentLine /\(^\s\+\)\@<=\%'.i.'v / containedin=ALL conceal cchar=' . g:indentLine_char
@@ -77,17 +79,23 @@ function! <SID>ResetWidth(...)
if a:0 > 0
let &l:shiftwidth = a:1
endif
if exists("b:indentLine_enabled")
syn clear IndentLine
endif
call <SID>SetIndentLine()
endfunction
"{{{1 function! <SID>IndentLinesToggle()
function! <SID>IndentLinesToggle()
if !exists("b:indentLine_enabled")
let b:indentLine_enabled = 0
endif
if b:indentLine_enabled
let b:indentLine_enabled = 0
syn clear IndentLine
else
let b:indentLine_enabled = 1
call <SID>SetIndentLine()
endif
endfunction
@@ -96,13 +104,28 @@ endfunction
function! <SID>Setup()
if !exists("b:indentLine_set")
let b:indentLine_set = 1
if !empty(filter(split(g:indentLine_fileTypeExclude, ','), 'v:val ==? "*.".expand("%:e:e") || v:val == "*"'))
return
endif
if !exists("b:indentLine_enabled")
let b:indentLine_enabled = g:indentLine_enabled
endif
if b:indentLine_enabled
call <SID>SetIndentLine()
endif
if &ft == ""
call <SID>InitColor()
endif
endif
endfunction
"{{{1 commands
autocmd BufWinEnter * call <SID>Setup()
autocmd BufRead,ColorScheme * call <SID>InitColor()
exec 'autocmd BufWinEnter '.g:indentLine_fileType.' call <SID>Setup()'
exec 'autocmd BufRead,ColorScheme '.g:indentLine_fileType.' call <SID>InitColor()'
command! -nargs=? IndentLinesReset call <SID>ResetWidth(<f-args>)
command! IndentLinesToggle call <SID>IndentLinesToggle()

View File

@@ -27,7 +27,7 @@ g:indentLine_loaded *g:loaded_indentLine*
g:indentLine_char *g:indentLine_char*
Specify a character to be used as indent line.
You also can use other characters:
| ¦ <EFBFBD><EFBFBD>?<3F><>?
| ¦ ┆ │
Default value is "|".
g:indentLine_color_term *g:indentLine_color_term*
@@ -42,13 +42,27 @@ g:indentLine_color_gui *g:indentLine_color_gui*
g:indentLine_indentLevel *g:indentLine_indentLevel*
Specify how much indent level do you want to use for
indentLine. Most program will not has bigger indent level than
20.
Default value is 20.
g:indentLine_enabled
10.
Default value is 10.
g:indentLine_enabled *g:indentLine_enabled*
Specify whether to enable indentLine plugin by default.
If value is not 0, the plugin is on by default, otherwise off.
Default value is 1.
g:indentLine_fileType *g:indentLine_fileType*
This variable specify a list of comma separated file types.
When opening these types of files, the plugin is enabled by
default.
e.g. let g:indentLine_fileType = '*.c,*.h'
Default value is "*" which means all file types is supported.
g:indentLine_fileTypeExclude *g:indentLine_fileTypeExclude*
This variable specify a list of comma separated file types.
When opening these types of files, the plugin is disabled by
default.
e.g. let g:indentLine_fileType = '*.txt,*.sh'
Default value is "" which means no file types is excluded.
==============================================================================
COMMANDS *indentLine-commands*
@@ -75,4 +89,4 @@ NagatoPain
Salman Halim
Christophe
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet
vim:tw=78:ts=8:ft=help:norl