Releasing v2.2.1

- Fixes #5. We now have the ability to invoke table mode within inline
  comments. Works for both instant table creation and table conversion
  for csv data. Uses 'commentstring' option of vim to identify comments,
  so it should work for most filetypes as long as 'commentstring' option
  has been set. This is usually done appropriately in filetype plugins.
This commit is contained in:
Dhruva Sagar
2013-04-08 19:47:38 +05:30
parent c6609fd67d
commit a5e2584347
4 changed files with 35 additions and 9 deletions

View File

@@ -1,4 +1,10 @@
# Change Log
## Version 2.2.1
* Added feature to allow Table-Mode to work within comments. Uses
'commentstring' option of vim to identify comments, so it should work for
most filetypes as long as 'commentstring' option has been set. This is
usually done appropriately in filetype plugins.
## Version 2.2
* Improved :Tableize to now accept a {pattern} just like :Tabular to match the
delimiter.

View File

@@ -4,7 +4,7 @@
" Author: Dhruva Sagar <http://dhruvasagar.com/>
" License: MIT (http://www.opensource.org/licenses/MIT)
" Website: http://github.com/dhruvasagar/vim-table-mode
" Version: 2.2
" Version: 2.2.1
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
" uses a small amount of code from it.

View File

@@ -4,7 +4,7 @@
" Author: Dhruva Sagar <http://dhruvasagar.com/>
" License: MIT (http://www.opensource.org/licenses/MIT)
" Website: http://github.com/dhruvasagar/vim-table-mode
" Version: 2.2
" Version: 2.2.1
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
" uses a small amount of code from it.
@@ -40,6 +40,16 @@ function! s:CountSeparator(line, separator) "{{{2
endfunction
" }}}2
function! s:GetCommentStart() "{{{2
return split(substitute(&commentstring, '%s', ' ', 'g'))[0]
endfunction
" }}}2
function! s:StartExpr() "{{{2
return '^\s*\(' . s:GetCommentStart() . '\)\?\s*\ze'
endfunction
" }}}2
function! s:IsTableModeActive() "{{{2
if g:table_mode_always_active | return 1 | endif
@@ -70,7 +80,7 @@ endfunction
function! s:UpdateLineBorder(line) "{{{2
let cline = a:line
let hf = '^\s*' . g:table_mode_corner . '[' . g:table_mode_corner . ' ' .
let hf = s:StartExpr() . g:table_mode_corner . '[' . g:table_mode_corner . ' ' .
\ g:table_mode_fillchar . ']*' . g:table_mode_corner . '\?\s*$'
let curr_line_count = s:CountSeparator(cline, g:table_mode_separator)
@@ -79,8 +89,13 @@ function! s:UpdateLineBorder(line) "{{{2
if curr_line_count > prev_line_count
silent! execute 'normal! kA' . repeat(g:table_mode_corner, curr_line_count - prev_line_count) . "\<Esc>j"
endif
else
if getline(cline) =~# s:StartExpr()
let indent = matchstr(getline(cline), s:StartExpr())
call append(cline-1, indent . repeat(g:table_mode_corner, curr_line_count))
else
call append(cline-1, repeat(g:table_mode_corner, curr_line_count))
endif
let cline = a:line + 1 " because of the append, the current line moved down
endif
@@ -89,9 +104,14 @@ function! s:UpdateLineBorder(line) "{{{2
if curr_line_count > next_line_count
silent! execute 'normal! jA' . repeat(g:table_mode_corner, curr_line_count - next_line_count) . "\<Esc>k"
end
else
if getline(cline) =~# s:StartExpr()
let indent = matchstr(getline(cline), s:StartExpr())
call append(cline, indent . repeat(g:table_mode_corner, curr_line_count))
else
call append(cline, repeat(g:table_mode_corner, curr_line_count))
endif
endif
endfunction
" }}}2
@@ -113,7 +133,7 @@ endfunction
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
let delim = g:table_mode_delimiter
if a:0 | let delim = a:1 | endif
silent! execute a:line . 's/^\s*\zs\ze.\|' . delim . '\|$/' .
silent! execute a:line . 's/' . s:StartExpr() . '\zs\ze.\|' . delim . '\|$/' .
\ g:table_mode_separator . '/g'
endfunction
" }}}2
@@ -132,7 +152,7 @@ endfunction
" Public API {{{1
function! tablemode#TableizeInsertMode() "{{{2
if s:IsTableModeActive() && getline('.') =~# ('^\s*' . g:table_mode_separator)
if s:IsTableModeActive() && getline('.') =~# (s:StartExpr() . g:table_mode_separator)
let column = s:Strlen(substitute(getline('.')[0:col('.')], '[^' . g:table_mode_separator . ']', '', 'g'))
let position = s:Strlen(matchstr(getline('.')[0:col('.')], '.*' . g:table_mode_separator . '\s*\zs.*'))
if g:table_mode_border | call s:UpdateLineBorder(line('.')) | endif

View File

@@ -1,7 +1,7 @@
*table-mode.txt* Table Mode for easy table formatting. v2.2
*table-mode.txt* Table Mode for easy table formatting. v2.2.1
===============================================================================
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
VERSION 2.2
VERSION 2.2.1
Author: Dhruva Sagar <http://dhruvasagar.com/>
License: MIT <http://opensource.org/licenses/MIT/>