From 65df0fb91fb7c8fb6c72466cb0fb78c914c5133c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Oct 2020 20:38:50 +0200 Subject: [PATCH] nvim: Remove pencil to fix relative cursor movement Cursor movement works better for soft-wrapped prose files now: When just using j/k to move vertically, the cursor will jump between the different parts of a single wrapped line. That means you can easily move anywhere you want on your lines, exactly as it's shown to you. If, however, prefixing your j/k move with a number to move a relative number of lines, it will no longer take wrapping into account. That means you can not jump instantly to *any* part of a wrapped lines, however on the other hand the relative line numbers on the side never lie now: You will jump exactly as many lines as are shown on the side. This is a tradeoff I am happily willing to make. Additionally had to remove vim-pencil to get the movement to work, but since it did not provide any visible pros anymore, this should not be a big issue. --- nvim/.config/nvim/after/plugin/prose.vim | 2 -- nvim/.config/nvim/init.vim | 1 - nvim/.config/nvim/maps.vim | 17 +++++++++++------ nvim/.config/nvim/plugin/vim-pandoc.vim | 3 +++ nvim/.config/nvim/plugin/vim-pencil.vim | 4 ---- 5 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 nvim/.config/nvim/plugin/vim-pencil.vim diff --git a/nvim/.config/nvim/after/plugin/prose.vim b/nvim/.config/nvim/after/plugin/prose.vim index c4dd1a6..b0c512d 100644 --- a/nvim/.config/nvim/after/plugin/prose.vim +++ b/nvim/.config/nvim/after/plugin/prose.vim @@ -1,9 +1,7 @@ " PROSE: function to automatically enables markdown plugins for md & txt files function! s:Prose() - call plug#load('vim-pencil') call plug#load('goyo.vim') call plug#load('limelight.vim') - call pencil#init() " PLUGIN: vim-textobj-sentence " enable extended sentence textobject use on md and plaintext files call textobj#sentence#init() diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 74ef82c..f9573d9 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -77,7 +77,6 @@ Plug 'kana/vim-textobj-user' Plug 'reedes/vim-textobj-sentence' " extends the capabilities of sentence detection " and allows you to jump to the *end* of this or last sentence. -Plug 'reedes/vim-pencil', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' } " provide md convenience functions like hard/softwrap Plug 'junegunn/goyo.vim', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' } " provide distraction free writing Plug 'junegunn/limelight.vim', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' } " provide even distraction free-er writing (lowlight paragraphs) " Language Integration diff --git a/nvim/.config/nvim/maps.vim b/nvim/.config/nvim/maps.vim index 1cc7ccb..550c716 100644 --- a/nvim/.config/nvim/maps.vim +++ b/nvim/.config/nvim/maps.vim @@ -29,6 +29,13 @@ nnoremap Q @ nnoremap H ^ nnoremap L $ +" when in softwrapped files, allow moving through the visible lines with j/k +" but when prepending a number jump *exactly* as many lines, wrapped or not +" This makes relative linenumbers much more useful in prose docs since they +" are always exactly correct +nnoremap k (v:count == 0 ? 'gk' : 'k') +nnoremap j (v:count == 0 ? 'gj' : 'j') + " move around between matching brackets with tab nnoremap % nnoremap % @@ -254,12 +261,10 @@ vnoremap zt "ky:ThesaurusQueryReplace k " o to open the resulting document (mostly for pdfs) " po to comPile *and* open a doc " and all the same in uppercase for verbose output -nnoremap pp :DocCompile -nnoremap PP :DocCompile! -nnoremap po :DocCompileOpen -nnoremap PO :DocCompileOpen! -nnoremap o :DocOpen -nnoremap O :DocOpen! +nnoremap dp :DocCompile +nnoremap dP :DocCompile! +nnoremap do :DocOpen +nnoremap dO :DocOpen! " PLUGIN: easy-align " Start interactive EasyAlign in visual mode (e.g. vipga) diff --git a/nvim/.config/nvim/plugin/vim-pandoc.vim b/nvim/.config/nvim/plugin/vim-pandoc.vim index c217927..faf946e 100644 --- a/nvim/.config/nvim/plugin/vim-pandoc.vim +++ b/nvim/.config/nvim/plugin/vim-pandoc.vim @@ -5,6 +5,9 @@ let g:pandoc#filetypes#pandoc_markdown = 1 let g:pandoc#filetypes#handled = [ "extra", "latex", "markdown", "pandoc", "rst", "textile" ] " disable all default keymaps let g:pandoc#keyboard#use_default_mappings=0 +" needs to be set for wrapping and unwrapping of lines to work when doing j/k +" or gj/gk respectively, to allow precise relative cursor jumping +let g:pandoc#keyboard#display_motions=0 let g:pandoc#hypertext#use_default_mappings=0 " if there's a pdf and an html or similar, open the pdf let g:pandoc#command#prefer_pdf=1 diff --git a/nvim/.config/nvim/plugin/vim-pencil.vim b/nvim/.config/nvim/plugin/vim-pencil.vim deleted file mode 100644 index 097427e..0000000 --- a/nvim/.config/nvim/plugin/vim-pencil.vim +++ /dev/null @@ -1,4 +0,0 @@ -" PLUGIN: vim-pencil -" set default wrap mode to hard - TODO test which mode works better for -" me, it seems hardmode has trouble with markdown lists (see issue #31) -let g:pencil#wrapModeDefault = 'soft' " default is 'hard'