From b2bbdc7aa18b93ea8c2471b7045ad9c4ea5b7af3 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 4 Jul 2023 19:37:39 +0200 Subject: [PATCH] table mode --- conf-only.sh | 1 + home/.config/nvim/main.vim | 5 ++++- home/.config/nvim/table-mode.vim | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 conf-only.sh create mode 100644 home/.config/nvim/table-mode.vim diff --git a/conf-only.sh b/conf-only.sh new file mode 100755 index 0000000..b9f6224 --- /dev/null +++ b/conf-only.sh @@ -0,0 +1 @@ +cp -r $(pwd)/home/.config ~ diff --git a/home/.config/nvim/main.vim b/home/.config/nvim/main.vim index c924fce..96a33bf 100644 --- a/home/.config/nvim/main.vim +++ b/home/.config/nvim/main.vim @@ -19,7 +19,7 @@ set completeopt=menuone,noinsert,noselect " Set completeopt to have a better completion experience" set completeopt=menuone,noinsert,noselect -" load nvim-tree stuff +" load extra stuff runtime nvim-tree.vim call plug#begin() @@ -40,10 +40,13 @@ Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } Plug 'nanotee/zoxide.vim' Plug 'jpalardy/vim-slime', { 'for': 'python' } Plug 'hanschen/vim-ipython-cell', { 'for': 'python' } +Plug 'dhruvasagar/vim-table-mode' runtime markdownpreview.vim call plug#end() +" load extra stuff +runtime table-mode.vim " no default mappings for vim smoothie (fancy scrolling) let g:smoothie_no_default_mappings = 1 diff --git a/home/.config/nvim/table-mode.vim b/home/.config/nvim/table-mode.vim new file mode 100644 index 0000000..bf25d32 --- /dev/null +++ b/home/.config/nvim/table-mode.vim @@ -0,0 +1,13 @@ +function! s:isAtStartOfLine(mapping) + let text_before_cursor = getline('.')[0 : col('.')-1] + let mapping_pattern = '\V' . escape(a:mapping, '\') + let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') + return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') +endfunction + +inoreabbrev + \ isAtStartOfLine('\|\|') ? + \ ':TableModeEnable' : '' +inoreabbrev __ + \ isAtStartOfLine('__') ? + \ ':silent! TableModeDisable' : '__'