From e573b3020c032400eed60b649a2cbf55266e6bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 30 Jun 2016 16:03:25 +0200 Subject: Add current configurations from old repository --- vim/bundle/vim-table-mode/plugin/table-mode.vim | 132 ++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 vim/bundle/vim-table-mode/plugin/table-mode.vim (limited to 'vim/bundle/vim-table-mode/plugin/table-mode.vim') diff --git a/vim/bundle/vim-table-mode/plugin/table-mode.vim b/vim/bundle/vim-table-mode/plugin/table-mode.vim new file mode 100644 index 0000000..3e78186 --- /dev/null +++ b/vim/bundle/vim-table-mode/plugin/table-mode.vim @@ -0,0 +1,132 @@ +" Finish if already loaded {{{1 +if exists('g:loaded_table_mode') + finish +endif +let g:loaded_table_mode = 1 + +" Avoiding side effects {{{1 +let s:save_cpo = &cpo +set cpo&vim + +function! s:SetGlobalOptDefault(opt, val) "{{{1 + if !exists('g:' . a:opt) + let g:{a:opt} = a:val + endif +endfunction + +" Set Global Defaults {{{1 +call s:SetGlobalOptDefault('table_mode_corner', '+') +call s:SetGlobalOptDefault('table_mode_verbose', 0) +call s:SetGlobalOptDefault('table_mode_separator', '|') +call s:SetGlobalOptDefault('table_mode_fillchar', '-') +call s:SetGlobalOptDefault('table_mode_header_fillchar', '-') +call s:SetGlobalOptDefault('table_mode_map_prefix', 't') +call s:SetGlobalOptDefault('table_mode_toggle_map', 'm') +call s:SetGlobalOptDefault('table_mode_always_active', 0) +call s:SetGlobalOptDefault('table_mode_delimiter', ',') +call s:SetGlobalOptDefault('table_mode_corner_corner', '|') +call s:SetGlobalOptDefault('table_mode_align_char', ':') +call s:SetGlobalOptDefault('table_mode_disable_mappings', 0) + +call s:SetGlobalOptDefault('table_mode_motion_up_map', '{') +call s:SetGlobalOptDefault('table_mode_motion_down_map', '}') +call s:SetGlobalOptDefault('table_mode_motion_left_map', '[') +call s:SetGlobalOptDefault('table_mode_motion_right_map', ']') + +call s:SetGlobalOptDefault('table_mode_cell_text_object_a_map', 'a') +call s:SetGlobalOptDefault('table_mode_cell_text_object_i_map', 'i') + +call s:SetGlobalOptDefault('table_mode_realign_map', 'tr') +call s:SetGlobalOptDefault('table_mode_delete_row_map', 'tdd') +call s:SetGlobalOptDefault('table_mode_delete_column_map', 'tdc') +call s:SetGlobalOptDefault('table_mode_add_formula_map', 'tfa') +call s:SetGlobalOptDefault('table_mode_eval_formula_map', 'tfe') +call s:SetGlobalOptDefault('table_mode_echo_cell_map', 't?') +call s:SetGlobalOptDefault('table_mode_sort_map', 'ts') + +function! s:TableEchoCell() "{{{1 + if tablemode#table#IsRow('.') + echomsg '$' . tablemode#spreadsheet#RowNr('.') . ',' . tablemode#spreadsheet#ColumnNr('.') + endif +endfunction + +augroup TableMode + au! + + autocmd Syntax * if tablemode#IsActive() | call tablemode#SyntaxEnable() | endif +augroup END + +" Define Commands & Mappings {{{1 +if !g:table_mode_always_active "{{{2 + exec "nnoremap " . 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 +endif +" }}}2 + +command! -nargs=? -range Tableize ,call tablemode#TableizeRange() +command! -nargs=? -bang TableSort call tablemode#spreadsheet#Sort(0, ) +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' + +nnoremap (table-mode-tableize) :Tableize +xnoremap (table-mode-tableize) :Tableize +xnoremap (table-mode-tableize-delimiter) :call tablemode#TableizeByDelimiter() + +nnoremap (table-mode-realign) :call tablemode#table#Realign('.') + +nnoremap (table-mode-motion-up) :call tablemode#spreadsheet#cell#Motion('k') +nnoremap (table-mode-motion-down) :call tablemode#spreadsheet#cell#Motion('j') +nnoremap (table-mode-motion-left) :call tablemode#spreadsheet#cell#Motion('h') +nnoremap (table-mode-motion-right) :call tablemode#spreadsheet#cell#Motion('l') + +onoremap (table-mode-cell-text-object-a) :call tablemode#spreadsheet#cell#TextObject(0) +onoremap (table-mode-cell-text-object-i) :call tablemode#spreadsheet#cell#TextObject(1) +xnoremap (table-mode-cell-text-object-a) :call tablemode#spreadsheet#cell#TextObject(0) +xnoremap (table-mode-cell-text-object-i) :call tablemode#spreadsheet#cell#TextObject(1) + +nnoremap (table-mode-delete-row) :call tablemode#spreadsheet#DeleteRow() +nnoremap (table-mode-delete-column) :call tablemode#spreadsheet#DeleteColumn() + +nnoremap (table-mode-add-formula) :call tablemode#spreadsheet#formula#Add() +nnoremap (table-mode-eval-formula) :call tablemode#spreadsheet#formula#EvaluateFormulaLine() + +nnoremap (table-mode-echo-cell) :call TableEchoCell() + +nnoremap (table-mode-sort) :call tablemode#spreadsheet#Sort('') + +if !hasmapto('(table-mode-tableize)') + exec "nmap " . g:table_mode_map_prefix . "t (table-mode-tableize)" + exec "xmap " . g:table_mode_map_prefix . "t (table-mode-tableize)" +endif + +if !hasmapto('(table-mode-tableize-delimiter)') + xmap T (table-mode-tableize-delimiter) +endif + +augroup TableMode "{{{1 + au! + + autocmd User TableModeEnabled call tablemode#logger#log('Table Mode Enabled') + autocmd User TableModeDisabled call tablemode#logger#log('Table Mode Disabled') +augroup END +" Avoiding side effects {{{1 +let &cpo = s:save_cpo + +" ModeLine {{{ +" vim: sw=2 sts=2 fdl=0 fdm=marker -- cgit v1.2.3