From e453870dee420db8b42caf1778205c0e1d642119 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Mon, 3 Jul 2023 10:37:41 +0200 Subject: [PATCH] add nvim table mode --- home/.config/nvim/main.vim | 7 +++++-- home/.config/nvim/nvim-table-mode.vim | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 home/.config/nvim/nvim-table-mode.vim diff --git a/home/.config/nvim/main.vim b/home/.config/nvim/main.vim index c16a279..4dfe442 100644 --- a/home/.config/nvim/main.vim +++ b/home/.config/nvim/main.vim @@ -19,7 +19,8 @@ set completeopt=menuone,noinsert,noselect " Set completeopt to have a better completion experience" set completeopt=menuone,noinsert,noselect -" load nvim-tree stuff + +" load plugins from extra files runtime nvim-tree.vim call plug#begin() @@ -35,6 +36,7 @@ Plug 'numToStr/FTerm.nvim' " floating terminal, toggle with Plug 'kdheepak/lazygit.nvim' Plug 'nvim-lualine/lualine.nvim' " nicer status line Plug 'goolord/alpha-nvim' +Plug 'dhruvasagar/vim-table-mode' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } @@ -45,6 +47,8 @@ runtime markdownpreview.vim call plug#end() +" load plugins from extra files +runtime nvim-table-mode.vim " no default mappings for vim smoothie (fancy scrolling) let g:smoothie_no_default_mappings = 1 @@ -132,7 +136,6 @@ inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" " slime (sends stuff to other programs, like ipython) let g:slime_target = "neovim" - "------------------------------------------------------ lua << END require('alpha').setup(require('alpha.themes.startify').config) diff --git a/home/.config/nvim/nvim-table-mode.vim b/home/.config/nvim/nvim-table-mode.vim new file mode 100644 index 0000000..5ccbe8e --- /dev/null +++ b/home/.config/nvim/nvim-table-mode.vim @@ -0,0 +1,15 @@ + +" Tip: You can use the following to quickly enable / disable table mode in insert mode by using || or __: +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' : '__'