From 95d79cd39a97daf3bc32b891abff366403802b2b Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 20 May 2019 18:18:48 +0200 Subject: [PATCH 1/9] add basic wiki and zettel structure --- .config/nvim/init.vim | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 3ee22fa..e6c5555 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -79,7 +79,7 @@ Plug 'junegunn/limelight.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " pr Plug 'rhysd/vim-grammarous', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " integrate vim with languagetool for grammar checking (needs java8) " Note-Taking Workflow -Plug 'fcpg/vim-waikiki' +Plug 'lervag/wiki.vim' Plug 'michal-h21/vim-zettel' " For async completion @@ -141,6 +141,7 @@ function! Prose() " PLUGIN: vim-textobj-sentence " enable extended sentence textobject use on md and plaintext files call textobj#sentence#init() + " hide the markdown cruft set conceallevel=3 endfunction " enable syntax highlighting for codeblocks WITHIN markdown @@ -151,6 +152,24 @@ autocmd FileType markdown,txt call Prose() " or invoke it manually by writing :Prose command! -nargs=0 Prose call Prose() +" PLUGIN: wiki.vim +let g:wiki_root = '~/projects/vim-notes' +" filetypes to automatically enable the plugin for, seems to take file endings +" rather than vim ft +let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki'] +let g:wiki_link_extension = '.md' +let g:wiki_link_target_type = 'md' + +" PLUGIN: vim-zettel +" gives nice short format of YYMMDDHHMM +let g:zettel_format = "%y%m%d%H%M" +" disable the standard key mappings of the plugin +let g:zettel_default_mappings = 0 +augroup filetype_vimwiki + autocmd! + autocmd FileType markdown xmap z ZettelNewSelectedMap +augroup END + " 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) From 54e31a85acbc4b8a3281196dbc83741f9d4d440e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 20 May 2019 22:21:53 +0200 Subject: [PATCH 2/9] add uppercasing in vim --- .config/nvim/init.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index e6c5555..8a79965 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -323,6 +323,10 @@ map V :vsp ~/.config/nvim/init.vim " since u undoes, would it not make sense that U redoes? nnoremap U +" when in insertion mode, C-u uppercases the current word, C-l lowercases it, +inoremap gUiw`]a +inoremap guiw`]a + " get rid of the help message popping up when I miss esc and hit F1 nnoremap inoremap @@ -340,6 +344,7 @@ nnoremap t :vsp . nnoremap T :tabedit . " save current buffer with Ctrl-s +" TODO do I need this? I reflexively use :w nnoremap :w " open/close NERDtree with leader-e From d3cc983eff21f5db20c262613bb0990d75e177ff Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 21 May 2019 13:44:44 +0200 Subject: [PATCH 3/9] add common vim bindings * set up beggining/end of line with H/L * set surround current word/visually selected word with " * set text expansion for @@ marty.oehme@gmail.com - email * set text expansion for ccopy - copyright notice * set common typos autocorrection --- .config/nvim/init.vim | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 8a79965..69d69b7 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -312,13 +312,15 @@ nnoremap % nnoremap % " select the whole buffer with -a -map a ggVG +nnoremap a ggVG " quickly edit vimrc with leader+V -map V :vsp ~/.config/nvim/init.vim +nnoremap V :vsp $MYVIMRC " automatically source the vimrc file whenever it is saved (causes slowdown " when done in MANY successions) " au BufWritePost init.vim so ~/.config/nvim/init.vim +" source vimrc with keystroke combination +nnoremap VV :source $MYVIMRC " since u undoes, would it not make sense that U redoes? nnoremap U @@ -338,15 +340,11 @@ nnoremap W :%s/\s\+$//:let @/='' " automatically on saving " autocmd BufWritePre * :%s/\s\+$//e -" 'open new tab' with leader-t (opens new buffer and switches to it) +" 'open new buffer' with leader-t (opens new buffer and switches to it) " open actual new tab with leader-T nnoremap t :vsp . nnoremap T :tabedit . -" save current buffer with Ctrl-s -" TODO do I need this? I reflexively use :w -nnoremap :w - " open/close NERDtree with leader-e " whatever method tree has been opened by, leader-e closes it again nnoremap e :NERDTreeToggle From eb955beba1c5758bdbc4189064b2904e9d01d614 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 7 Jun 2019 10:49:52 +0200 Subject: [PATCH 4/9] Change wiki root to Nextcloud notes --- .config/nvim/init.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 69d69b7..6866411 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -153,7 +153,7 @@ autocmd FileType markdown,txt call Prose() command! -nargs=0 Prose call Prose() " PLUGIN: wiki.vim -let g:wiki_root = '~/projects/vim-notes' +let g:wiki_root = '~/Nextcloud/Notes/' " filetypes to automatically enable the plugin for, seems to take file endings " rather than vim ft let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki'] From f7b304966ccbb8e96f82b182be7b1517d3c9b3ca Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 11 Jun 2019 14:55:55 +0200 Subject: [PATCH 5/9] Add full-text search to notes Adds full-text search with CtrlSF vim plugin. Activated via wf, to spell wiki-find (mirrors ww for wiki-index). Optimizations can certainly be done. --- .config/nvim/init.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 6866411..d178ee3 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -56,6 +56,7 @@ Plug 'reedes/vim-textobj-sentence' " extends the capabilities of sentence detect Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " show a directory listing within vim Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } " show git status in nerdtree for files and dirs Plug 'Yggdroot/LeaderF', { 'on': ['Leaderf', 'LeaderfFile', 'LeaderfBuffer'], 'do': './install.sh' } " fuzzy matcher, apparently faster than fzf, ctrlp, unit, denite +Plug 'dyng/ctrlsf.vim' " Language Integration Plug 'sheerun/vim-polyglot' " syntax plugins for almost every language @@ -357,6 +358,20 @@ nnoremap E :NERDTreeFind nnoremap f :LeaderfFile nnoremap F :LeaderfBuffer +function! SearchWiki() + let l:curpath=getcwd() + :execute(":cd " . g:wiki_root) + let l:texttofind=input("Search in Notes: ") + :execute(":CtrlSF " . l:texttofind) + :CtrlSFFocus + :execute(":cd " . l:curpath) +endfunction + +" search in wiki with ctrlsf +nnoremap wf :execute(":call SearchWiki()") +nnoremap CtrlSFPrompt +vnoremap CtrlSFVwordPath + " Mostly dealing with Prose writing from here on out " Format current Paragraph (esp useful in prose writing) nnoremap q gqap From abccdc7a627d8e2f8185d1dd590515a76eb86511 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Jun 2019 13:32:38 +0200 Subject: [PATCH 6/9] Remove obsolete vim-zettel configuration --- .config/nvim/init.vim | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index d178ee3..bd6f27d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -81,7 +81,6 @@ Plug 'rhysd/vim-grammarous', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " inte " Note-Taking Workflow Plug 'lervag/wiki.vim' -Plug 'michal-h21/vim-zettel' " For async completion Plug 'Shougo/deoplete.nvim', { 'on': [] } " automatic suggestions, can also perhaps be changed for newer plugs @@ -161,16 +160,6 @@ let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki'] let g:wiki_link_extension = '.md' let g:wiki_link_target_type = 'md' -" PLUGIN: vim-zettel -" gives nice short format of YYMMDDHHMM -let g:zettel_format = "%y%m%d%H%M" -" disable the standard key mappings of the plugin -let g:zettel_default_mappings = 0 -augroup filetype_vimwiki - autocmd! - autocmd FileType markdown xmap z ZettelNewSelectedMap -augroup END - " 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) From 6298daeca261a0ce1aa86b3f84a7f738bd47a517 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Jun 2019 14:18:46 +0200 Subject: [PATCH 7/9] Add configurable wiki root directory Can be set through environment variable WIKIROOT. By default points to ~/Nextcloud/Notes/ but is kept configurable for each computer. Will be picked up by vim wiki plugin to enable wiki functionality for the respective directory. --- .config/nvim/init.vim | 6 +++++- .config/shell/rc.d/set-wiki-root.sh | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .config/shell/rc.d/set-wiki-root.sh diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index bd6f27d..7c8073d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -153,7 +153,11 @@ autocmd FileType markdown,txt call Prose() command! -nargs=0 Prose call Prose() " PLUGIN: wiki.vim -let g:wiki_root = '~/Nextcloud/Notes/' +if $WIKIROOT ==? "" + let g:wiki_root = '~/Nextcloud/Notes/' +else + let g:wiki_root = $WIKIROOT +endif " filetypes to automatically enable the plugin for, seems to take file endings " rather than vim ft let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki'] diff --git a/.config/shell/rc.d/set-wiki-root.sh b/.config/shell/rc.d/set-wiki-root.sh new file mode 100644 index 0000000..3e9d535 --- /dev/null +++ b/.config/shell/rc.d/set-wiki-root.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# set wiki root to nextcloud notes folder, +# will be picked up by vim wiki plugin as root +export WIKIROOT='~/Nextcloud/Notes/' From f06ab7804edbf2baff672d310d8a5a9be8b7f526 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Jun 2019 14:22:28 +0200 Subject: [PATCH 8/9] Remove subset of vim wiki default mappings Only keep some of the default vimwiki mappings, since the rest I don't really need (currently) and they interfere with some other operations I intend to map (e.g. wf should fuzzysearch wiki but will toggle a link when overwritten by the defaults). --- .config/nvim/init.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 7c8073d..08f251c 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -163,6 +163,18 @@ endif let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki'] let g:wiki_link_extension = '.md' let g:wiki_link_target_type = 'md' +let g:wiki_mappings_use_defaults = 0 +let g:wiki_mappings_global = { + \ '(wiki-index)' : 'ww', + \ '(wiki-reload)' : 'wx', + \ '(wiki-page-rename)' : 'wr', + \ '(wiki-link-open)' : '', + \ '(wiki-link-open-split)' : '', + \ '(wiki-link-return)' : '', + \ '(wiki-link-next)' : '', + \ '(wiki-link-prev)' : '', + \ '(wiki-graph-find-backlinks)' : 'wb', + \} " PLUGIN: vim-pencil " set default wrap mode to hard - TODO test which mode works better for From 6557b8dce0bac27cffdef1298b5eab1ff1e0c17a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Jun 2019 14:24:38 +0200 Subject: [PATCH 9/9] Add quick fuzzy note search to wiki Use wf from anywhere to fuzzysearch a phrase over the notes. If no initial input is given loads all files into the interactive fuzzysearch. Use wF to load a more detailed, full-screen windows (via CtrlSF) which allows direct editing of results and more. --- .config/nvim/init.vim | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 08f251c..a8b24a3 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -372,9 +372,23 @@ function! SearchWiki() :execute(":cd " . l:curpath) endfunction -" search in wiki with ctrlsf -nnoremap wf :execute(":call SearchWiki()") -nnoremap CtrlSFPrompt +function! RgWiki() + let l:curpath=getcwd() + :execute(":cd " . g:wiki_root) + let l:texttofind=input("Search Notes: ") + if l:texttofind ==? "" + :execute(":Leaderf rg") + else + :execute(":Leaderf rg -e " . l:texttofind ) + endif + :execute(":cd " . l:curpath) +endfunction + +" search in wiki with ctrlsf, in fullscreen window +nnoremap wF :execute(":call SearchWiki()") +" fuzzy search wiki with leaderf +nnoremap wf :execute(":call RgWiki()") +nnoremap :execute(":Leaderf rg -e *") vnoremap CtrlSFVwordPath " Mostly dealing with Prose writing from here on out