From 1c0aa32806e097a2a0c30b760ae4cad481e758c6 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Fri, 8 Oct 2021 13:50:04 +0300 Subject: nvim: ported wiki functions --- .config/nvim/after/plugin/autocmds.vim | 2 ++ .config/nvim/after/plugin/functions.vim | 28 ++++++++++++++++++++++++++++ .config/nvim/after/plugin/tabular_extra.vim | 14 ++++++++++++++ .config/nvim/lua/mappings.lua | 21 +++++++++++++++++++-- .config/nvim/lua/plugin_settings.lua | 16 +++++++++------- 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 .config/nvim/after/plugin/autocmds.vim create mode 100644 .config/nvim/after/plugin/functions.vim create mode 100644 .config/nvim/after/plugin/tabular_extra.vim (limited to '.config/nvim') diff --git a/.config/nvim/after/plugin/autocmds.vim b/.config/nvim/after/plugin/autocmds.vim new file mode 100644 index 0000000..ae55046 --- /dev/null +++ b/.config/nvim/after/plugin/autocmds.vim @@ -0,0 +1,2 @@ +" I don't know how to port this yet +autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif diff --git a/.config/nvim/after/plugin/functions.vim b/.config/nvim/after/plugin/functions.vim new file mode 100644 index 0000000..87a1072 --- /dev/null +++ b/.config/nvim/after/plugin/functions.vim @@ -0,0 +1,28 @@ +" Will learn to port promise +function! CreateNote() + py3 import uuid + exe "e! " . fnameescape("~/nextcloud/personal_wiki/text/box/" . py3eval('str(uuid.uuid4())[:6]') . ".wiki") + let l:text="= up =\n\n= down =\n\n= keywords =\n\n" + put =l:text + norm gg +endfunction + +function! CreatePaper(citekey) + exe "e! " . fnameescape("~/nextcloud/personal_wiki/text/papers/" . a:citekey . ".wiki") + + let l:timestap="%date " . strftime("%F") + let l:text="= Came From =\n\n= Takeaways =\n\n= Might Go To =\n\n" + + put! =l:timestap + put =l:text +endfunction + +function! CreateReference(citekey) + exe "e! " . fnameescape("~/nextcloud/personal_wiki/text/reference/" . a:citekey . ".wiki") + + let l:timestap="%date " . strftime("%F") + let l:text="= Literature Notes =\n\n= Citation =\n\n" + + put! =l:timestap + put =l:text +endfunction diff --git a/.config/nvim/after/plugin/tabular_extra.vim b/.config/nvim/after/plugin/tabular_extra.vim new file mode 100644 index 0000000..28713ca --- /dev/null +++ b/.config/nvim/after/plugin/tabular_extra.vim @@ -0,0 +1,14 @@ +" after/plugin/my_tabular_commands.vim +" Provides extra :Tabularize commands + +if !exists(':Tabularize') + finish " Give up here; the Tabular plugin musn't have been loaded +endif + +nmap t= :Tabularize /= +vmap t= :Tabularize /= +nmap t: :Tabularize /:\zs +vmap t: :Tabularize /:\zs + +AddTabularPattern first_comma /^[^,]*\zs,/r0c0l0 +AddTabularPattern first_colon /^[^:]*\zs:/r0c0l0 diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index fe59a99..f27ac1b 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -84,6 +84,18 @@ map('n', 'cd', ':cd %:p:h:pwd') -- press \g and start writing prose map('n', 'g', ':Goyo') +-- call CreatePaper on word below cursor +map('n', 'np', 'gewi[[/papers/Ea]]bb:call CreatePaper(expand(""))') + +-- link paper +map('n', 'lp', 'gewi[[/papers/Ea]]') + +-- call CreateReference on word below cursor +map('n', 'nr', ':call CreateReference(expand(""))') + +-- create a new note +map('n', 'nn', ':call CreateNote()') + -- plug mappings {{{1 -- -- mappings should not be noremap @@ -101,8 +113,8 @@ plugmap('n', '`', 'Sneak_S') plugmap('n', "'", '`') -- use the special yoink paste that rotates -plugmap('n', 'p', '(YoinkPaste_p)') -plugmap('n', 'P', '(YoinkPaste_P)') +plugmap('n', 'p', '(YoinkPaste_p)') +plugmap('n', 'P', '(YoinkPaste_P)') -- substitute from yank plugmap('n', 'ys', '(SubversiveSubstitute)') @@ -128,4 +140,9 @@ plugmap('i', '', '(fzf-complete-word)') plugmap('i', '', '(fzf-complete-path)') plugmap('i', '', '(fzf-complete-line)') +-- checkmarks on vimwiki +plugmap('n', 'v', 'VimwikiToggleListItem') +-- add/increase header level +plugmap('n', 'a', 'VimwikiAddHeaderLevel') + -- 1}}} -- diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index b10a002..4e28726 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -101,13 +101,6 @@ g.UltiSnipsExpandTrigger = "" g.UltiSnipsEnableSnipMate = "1" -- }}} UltiSnips -- --- float preview -g["float_preview#docked"] = 0 - --- highlight on yank -cmd('highlight HighlightedyankRegion cterm=reverse gui=reverse') -g.highlightedyank_highlight_duration = 200 - -- beacon {{{ -- g.beacon_size = 100 g.beacon_shrink = 1 @@ -124,3 +117,12 @@ g.slime_paste_file = "/home/yigit/.slime_paste" g.vimtex_view_method = 'zathura' g.vimtex_quickfix_mode = 0 -- }}} vimtex -- + +vim.g.polyglot_disabled={'latex', 'tex'} + +-- float preview +g["float_preview#docked"] = 0 + +-- highlight on yank +cmd('highlight HighlightedyankRegion cterm=reverse gui=reverse') +g.highlightedyank_highlight_duration = 200 -- cgit v1.2.3-70-g09d2