From 80ec86e385b0bc00207544111e7a17f41d2060fd Mon Sep 17 00:00:00 2001 From: Dhruva Sagar Date: Tue, 13 May 2014 11:18:42 +0530 Subject: [PATCH] Version 4.4.2 * Updated mappings to be buffer local * Updated mappings to toggle with Table Mode --- CHANGELOG.md | 5 +++ README.md | 2 +- autoload/tablemode.vim | 86 ++++++++++++++++++++++++++++++++++++++---- doc/table-mode.txt | 4 +- plugin/table-mode.vim | 42 --------------------- 5 files changed, 87 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa4da2..bb9f50d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Change Log + +## Version 4.4.2 +* Updated mappings to be buffer local. +* Updated mappings to toggle and function only when table mode is active. + ## Version 4.4.1 * Added syntax for matching tables diff --git a/README.md b/README.md index 62e0bec..faf8f2d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# VIM Table Mode v4.4.1 [![Build Status](https://travis-ci.org/dhruvasagar/vim-table-mode.png?branch=master)](https://travis-ci.org/dhruvasagar/vim-table-mode) +# VIM Table Mode v4.4.2 [![Build Status](https://travis-ci.org/dhruvasagar/vim-table-mode.png?branch=master)](https://travis-ci.org/dhruvasagar/vim-table-mode) An awesome automatic table creator & formatter allowing one to create neat tables as you type. diff --git a/autoload/tablemode.vim b/autoload/tablemode.vim index 15c7e1c..63e6cde 100644 --- a/autoload/tablemode.vim +++ b/autoload/tablemode.vim @@ -33,15 +33,87 @@ function! s:SetBufferOptDefault(opt, val) "{{{2 endfunction function! s:ToggleMapping() "{{{2 - if exists('b:table_mode_active') && b:table_mode_active - call s:SetBufferOptDefault('table_mode_separator_map', g:table_mode_separator) - " '|' is a special character, we need to map instead - if g:table_mode_separator ==# '|' | let b:table_mode_separator_map = '' | endif + 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 - execute "inoremap " . b:table_mode_separator_map . ' ' . - \ b:table_mode_separator_map . ":call tablemode#TableizeInsertMode()a" + if tablemode#IsActive() + execute 'inoremap ' separator_map + \ separator_map . ':call tablemode#TableizeInsertMode()a' + + if !hasmapto('(table-mode-motion-up)', 'n') + nmap { (table-mode-motion-up) + endif + if !hasmapto('(table-mode-motion-down)', 'n') + nmap } (table-mode-motion-down) + endif + if !hasmapto('(table-mode-motion-left)', 'n') + nmap [ (table-mode-motion-left) + endif + if !hasmapto('(table-mode-motion-right)', 'n') + nmap ] (table-mode-motion-right) + endif + if !hasmapto('(table-mode-cell-text-object-a)', 'o') + omap a (table-mode-cell-text-object-a) + endif + if !hasmapto('(table-mode-cell-text-object-i)', 'o') + omap i (table-mode-cell-text-object-i) + endif + if !hasmapto('(table-mode-realign)', 'n') + nmap tr (table-mode-realign) + endif + if !hasmapto('(table-mode-delete-row)', 'n') + nmap tdd (table-mode-delete-row) + endif + if !hasmapto('(table-mode-delete-column)', 'n') + nmap tdc (table-mode-delete-column) + endif + if !hasmapto('(table-mode-add-formula)', 'n') + nmap tfa (table-mode-add-formula) + endif + if !hasmapto('(table-mode-eval-formula)', 'n') + nmap tfe (table-mode-eval-formula) + endif + if !hasmapto('(table-mode-echo-cell)', 'n') + nmap t? (table-mode-echo-cell) + endif else - silent! execute "iunmap " . b:table_mode_separator_map + if !empty(maparg(separator_map, 'i')) + execute "iunmap " . separator_map + endif + if !empty(maparg('{', 'n')) + nunmap { + endif + if !empty(maparg('}', 'n')) + nunmap } + endif + if !empty(maparg('[', 'n')) + nunmap [ + endif + if !empty(maparg(']', 'n')) + nunmap ] + endif + if !empty(maparg('a', 'o')) + ounmap a + endif + if !empty(maparg('i', 'o')) + ounmap i + endif + if !empty(maparg('tdd', 'n')) + nunmap tdd + endif + if !empty(maparg('tdc', 'n')) + nunmap tdc + endif + if !empty(maparg('tfa', 'n')) + nunmap tfa + endif + if !empty(maparg('tfe', 'n')) + nunmap tfe + endif + if !empty(maparg('t?', 'n')) + nunmap t? + endif endif endfunction diff --git a/doc/table-mode.txt b/doc/table-mode.txt index 0373608..77eb5c0 100644 --- a/doc/table-mode.txt +++ b/doc/table-mode.txt @@ -1,7 +1,7 @@ -*table-mode.txt* Table Mode for easy table formatting. v4.4.1 +*table-mode.txt* Table Mode for easy table formatting. v4.4.2 =============================================================================== Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER - VERSION 4.4.1 + VERSION 4.4.2 Author: Dhruva Sagar License: MIT diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim index e30f3a6..8bc0d9d 100644 --- a/plugin/table-mode.vim +++ b/plugin/table-mode.vim @@ -123,48 +123,6 @@ if !hasmapto('(table-mode-tableize-delimiter)') xmap T (table-mode-tableize-delimiter) endif -if !hasmapto('(table-mode-realign)') - nmap tr (table-mode-realign) -endif - -if !hasmapto('(table-mode-motion-up)') - nmap { (table-mode-motion-up) -endif -if !hasmapto('(table-mode-motion-down)') - nmap } (table-mode-motion-down) -endif -if !hasmapto('(table-mode-motion-left)') - nmap [ (table-mode-motion-left) -endif -if !hasmapto('(table-mode-motion-right)') - nmap ] (table-mode-motion-right) -endif - -if !hasmapto('(table-mode-cell-text-object-a)') - omap a (table-mode-cell-text-object-a) -endif -if !hasmapto('(table-mode-cell-text-object-i)') - omap i (table-mode-cell-text-object-i) -endif - -if !hasmapto('(table-mode-delete-row)') - nmap tdd (table-mode-delete-row) -endif -if !hasmapto('(table-mode-delete-column)') - nmap tdc (table-mode-delete-column) -endif - -if !hasmapto('(table-mode-add-formula)') - nmap tfa (table-mode-add-formula) -endif -if !hasmapto('(table-mode-eval-formula)') - nmap tfe (table-mode-eval-formula) -endif - -if !hasmapto('(table-mode-echo-cell)') - nmap t? (table-mode-echo-cell) -endif - " Avoiding side effects {{{1 let &cpo = s:save_cpo