From 8dcdfad1eeea68856a25338f13c808af1038866f Mon Sep 17 00:00:00 2001 From: Benjamin Mundt Date: Thu, 29 Apr 2021 14:15:48 -0400 Subject: [PATCH 1/3] Define separator map in one place as a global; add separator map target for separators other than | --- autoload/tablemode.vim | 10 +++------- plugin/table-mode.vim | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/autoload/tablemode.vim b/autoload/tablemode.vim index 302d2b9..07ab643 100644 --- a/autoload/tablemode.vim +++ b/autoload/tablemode.vim @@ -22,13 +22,9 @@ function! s:UnMap(map, mode) "{{{2 endfunction function! s:ToggleMapping() "{{{2 - let separator_map = g:table_mode_separator - " '|' is a special character, we need to map instead - if g:table_mode_separator ==# '|' | let separator_map = '' | endif - if !g:table_mode_disable_mappings if tablemode#IsActive() - call s:Map('(table-mode-tableize)', separator_map, 'i') + call s:Map('(table-mode-tableize)', g:table_mode_separator_map, 'i') call s:Map('(table-mode-motion-up)', g:table_mode_motion_up_map, 'n') call s:Map('(table-mode-motion-down)', g:table_mode_motion_down_map, 'n') call s:Map('(table-mode-motion-left)', g:table_mode_motion_left_map, 'n') @@ -47,7 +43,7 @@ function! s:ToggleMapping() "{{{2 call s:Map('(table-mode-echo-cell)', g:table_mode_echo_cell_map, 'n') call s:Map('(table-mode-sort)', g:table_mode_sort_map, 'n') else - call s:UnMap(separator_map, 'i') + call s:UnMap(g:table_mode_separator_map, 'i') call s:UnMap(g:table_mode_motion_up_map, 'n') call s:UnMap(g:table_mode_motion_down_map, 'n') call s:UnMap(g:table_mode_motion_left_map, 'n') @@ -207,7 +203,7 @@ endfunction function! tablemode#TableizeRange(...) range "{{{2 let lnum = a:firstline let total = (a:lastline - a:firstline + 1) - echom total + " echom total let cntr = 1 while cntr <= total call s:Tableizeline(lnum, a:1) diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim index 5a0166e..c55be27 100644 --- a/plugin/table-mode.vim +++ b/plugin/table-mode.vim @@ -18,6 +18,13 @@ endfunction call s:SetGlobalOptDefault('table_mode_corner', '+') call s:SetGlobalOptDefault('table_mode_verbose', 1) call s:SetGlobalOptDefault('table_mode_separator', '|') +" '|' is a special character, we need to map instead +" the character to map from +let g:table_mode_separator_map = get(g:, 'table_mode_separator_map', g:table_mode_separator) +if g:table_mode_separator_map ==# '|' | let g:table_mode_separator_map = '' | endif +" the character to map to (when inserting the separator) +let g:table_mode_separator_map_target = g:table_mode_separator +if g:table_mode_separator_map_target ==# '|' | let g:table_mode_separator_map_target = '' | endif call s:SetGlobalOptDefault('table_mode_escaped_separator_regex', '\V\C\\\@1" g:table_mode_map_prefix . g:table_mode_toggle_map ":call tablemode#Toggle()" command! -nargs=0 TableModeToggle call tablemode#Toggle() command! -nargs=0 TableModeEnable call tablemode#Enable() command! -nargs=0 TableModeDisable call tablemode#Disable() else - let table_mode_separator_map = g:table_mode_separator - " '|' is a special character, we need to map instead - if g:table_mode_separator ==# '|' | let table_mode_separator_map = '' | endif - - execute "inoremap " . table_mode_separator_map . ' ' . - \ table_mode_separator_map . ":call tablemode#TableizeInsertMode()a" - unlet table_mode_separator_map + execute "inoremap " . g:table_mode_separator_map . ' ' . + \ g:table_mode_separator_map_target . ":call tablemode#TableizeInsertMode()a" endif " }}}2 @@ -84,9 +87,7 @@ command! TableAddFormula call tablemode#spreadsheet#formula#Add() command! TableModeRealign call tablemode#table#Realign('.') command! TableEvalFormulaLine call tablemode#spreadsheet#formula#EvaluateFormulaLine() -" '|' is a special character, we need to map instead -if g:table_mode_separator ==# '|' | let separator_map = '' | endif -execute 'inoremap (table-mode-tableize)' separator_map . ':call tablemode#TableizeInsertMode()a' +execute 'inoremap (table-mode-tableize)' g:table_mode_separator_map . ':call tablemode#TableizeInsertMode()a' nnoremap (table-mode-tableize) :Tableize xnoremap (table-mode-tableize) :Tableize From 88b9c85af3daa58b5cf1589c0a2b5e950fb7e962 Mon Sep 17 00:00:00 2001 From: Dhruva Sagar Date: Wed, 5 May 2021 22:21:42 +0530 Subject: [PATCH 2/3] Update doc and fixed specs --- doc/table-mode.txt | 7 ++++++- t/config/options.vim | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/table-mode.txt b/doc/table-mode.txt index b810254..3f48988 100644 --- a/doc/table-mode.txt +++ b/doc/table-mode.txt @@ -147,6 +147,7 @@ Overview: |table-mode-verbose| ............ Notify when Enabled/Disabled. |table-mode-corner| ............. Set corner character. |table-mode-separator| .......... Set separator character. + |table-mode-separator-map| ...... Set separator mapping. |table-mode-fillchar| ........... Set table border fillchar character. |table-mode-header-fillchar| .... Set table header border fillchar character. |table-mode-map-prefix| ......... Set prefix for table mode commands. @@ -209,6 +210,11 @@ g:table_mode_separator *table-mode-separator* This option also defines the trigger to be used to start creating a table row in insert mode. +g:table_mode_separator_map *table-mode-separator-map* + Use this option to define the mapping to be used for the table separator. > + let g:table_mode_separator_map = '' +< + g:table_mode_fillchar *table-mode-fillchar* Use this option to define the table border fill character: > let g:table_mode_fillchar = '-' @@ -530,4 +536,3 @@ REPORT ISSUES *table-mode-report-issues* If you discover any issues, please report them at http://github.com/dhruvasagar/vim-table-mode/issues. - vim:tw=78:ts=8:ft=help:norl:ai:et diff --git a/t/config/options.vim b/t/config/options.vim index 990c399..c822f7f 100644 --- a/t/config/options.vim +++ b/t/config/options.vim @@ -1,5 +1,6 @@ let g:table_mode_corner = '+' let g:table_mode_separator = '|' +let g:table_mode_separator_map = '' let g:table_mode_escaped_separator_regex = '\V\C\\\@1 Date: Wed, 5 May 2021 22:27:01 +0530 Subject: [PATCH 3/3] Bump ruby version for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e5f5e55..465e83d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: ruby rvm: - - 2.5.3 + - 3.0.0 script: rake ci