From 9bebd86577afe8d81a738527a46b438eb7e09afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Sat, 30 May 2026 17:35:28 -0300 Subject: [PATCH] feat(client): wire full Vimwiki command-parity surface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register the named :Vimwiki*/:Nuwiki* entry points that previously existed only as mappings or were missing entirely — including RemoveSingleCB/RemoveCBInList, CatUrl, TabMakeDiaryNote, NormalizeLink, Renumber{List,AllLists}, TableAlign, ChangeSymbol(InList), ListToggle, Increment/DecrementListItem, and the DeleteLink/RenameLink/ GenerateTags compat aliases. Both the Vim (vim-lsp/coc) and Neovim client functions are added to back them. Co-Authored-By: Claude Opus 4.7 --- autoload/nuwiki/commands.vim | 40 +++++++++++++++++++++-- ftplugin/vimwiki.vim | 62 ++++++++++++++++++++++++++++++++++++ lua/nuwiki/commands.lua | 28 ++++++++++++++-- 3 files changed, 126 insertions(+), 4 deletions(-) diff --git a/autoload/nuwiki/commands.vim b/autoload/nuwiki/commands.vim index df9c927..70473c4 100644 --- a/autoload/nuwiki/commands.vim +++ b/autoload/nuwiki/commands.vim @@ -363,14 +363,18 @@ endfunction " ===== Diary ===== -function! s:diary_open(cmd_name) abort +function! s:diary_open(cmd_name, ...) abort + let l:open = a:0 >= 1 ? a:1 : 'edit' call s:exec(a:cmd_name, [{ 'uri': s:buf_uri() }], - \ function('s:open_uri_from')) + \ {n -> s:open_uri_from(n, l:open)}) endfunction function! nuwiki#commands#diary_today() abort call s:diary_open('nuwiki.diary.openToday') endfunction +function! nuwiki#commands#diary_today_tab() abort + call s:diary_open('nuwiki.diary.openToday', 'tabedit') +endfunction function! nuwiki#commands#diary_yesterday() abort call s:diary_open('nuwiki.diary.openYesterday') endfunction @@ -646,6 +650,24 @@ function! nuwiki#commands#list_remove_done_all() abort call s:exec('nuwiki.list.removeDone', l:args) endfunction +" `:VimwikiRemoveSingleCB` — strip the checkbox from the current item only. +function! nuwiki#commands#list_remove_checkbox() abort + let l:p = s:cursor_position() + let l:args = [{ 'uri': l:p['textDocument']['uri'], 'position': l:p['position'] }] + call s:exec('nuwiki.list.removeCheckbox', l:args) +endfunction + +" `:VimwikiRemoveCBInList` — strip checkboxes from every item in the list. +function! nuwiki#commands#list_remove_checkbox_in_list() abort + let l:p = s:cursor_position() + let l:args = [{ + \ 'uri': l:p['textDocument']['uri'], + \ 'position': l:p['position'], + \ 'whole_list': v:true, + \ }] + call s:exec('nuwiki.list.removeCheckbox', l:args) +endfunction + function! nuwiki#commands#list_renumber() abort let l:p = s:cursor_position() let l:args = [{ 'uri': l:p['textDocument']['uri'], 'position': l:p['position'] }] @@ -1108,6 +1130,20 @@ function! nuwiki#commands#normalize_link() abort call s:wrap_cword_as_wikilink() endfunction +function! s:echo_url_from(response, ...) abort + let l:result = get(get(a:response, 'response', {}), 'result', '') + if type(l:result) == type('') && l:result !=# '' + echom l:result + endif +endfunction + +" `:VimwikiCatUrl` — echo the `file://` URL of the current page's HTML +" export (the server computes the path from the wiki's html config). +function! nuwiki#commands#cat_url() abort + let l:args = [{ 'uri': s:buf_uri() }] + call s:exec('nuwiki.link.catUrl', l:args, function('s:echo_url_from')) +endfunction + " ===== Name-parity aliases ===== " " The Lua surface and the VimL surface diverged on a handful of names: diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 06c4f13..fc580fa 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -40,6 +40,7 @@ if !has('nvim') command! -buffer VimwikiUISelect call nuwiki#commands#wiki_ui_select() command! -buffer VimwikiDiaryIndex call nuwiki#commands#diary_index() command! -buffer VimwikiMakeDiaryNote call nuwiki#commands#diary_today() + command! -buffer VimwikiTabMakeDiaryNote call nuwiki#commands#diary_today_tab() command! -buffer VimwikiMakeYesterdayDiaryNote call nuwiki#commands#diary_yesterday() command! -buffer VimwikiMakeTomorrowDiaryNote call nuwiki#commands#diary_tomorrow() command! -buffer VimwikiDiaryNextDay call nuwiki#commands#diary_next() @@ -56,12 +57,27 @@ if !has('nvim') command! -buffer -nargs=1 VimwikiGoto call nuwiki#commands#wiki_goto_page() command! -buffer VimwikiDeleteFile call nuwiki#commands#delete_file() + command! -buffer VimwikiDeleteLink call nuwiki#commands#delete_file() command! -buffer VimwikiRenameFile call nuwiki#commands#rename_file() + command! -buffer VimwikiRenameLink call nuwiki#commands#rename_file() command! -buffer VimwikiNextTask call nuwiki#commands#next_task() command! -buffer VimwikiToggleListItem call nuwiki#commands#toggle_list_item() command! -buffer VimwikiToggleRejectedListItem call nuwiki#commands#reject_list_item() + command! -buffer VimwikiListToggle call nuwiki#commands#list_toggle_or_add_checkbox() + command! -buffer VimwikiIncrementListItem call nuwiki#commands#list_cycle_symbol(1) + command! -buffer VimwikiDecrementListItem call nuwiki#commands#list_cycle_symbol(-1) + command! -buffer -nargs=1 VimwikiChangeSymbolTo call nuwiki#commands#list_change_symbol(, 0) + command! -buffer -nargs=1 VimwikiListChangeSymbolI call nuwiki#commands#list_change_symbol(, 0) + command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call nuwiki#commands#list_change_symbol(, 1) command! -buffer VimwikiRemoveDone call nuwiki#commands#list_remove_done() + command! -buffer -range VimwikiRemoveSingleCB call nuwiki#commands#list_remove_checkbox() + command! -buffer VimwikiRemoveCBInList call nuwiki#commands#list_remove_checkbox_in_list() command! -buffer -nargs=? VimwikiListChangeLvl call nuwiki#commands#list_change_lvl() + command! -buffer VimwikiNormalizeLink call nuwiki#commands#normalize_link() + command! -buffer VimwikiRenumberList call nuwiki#commands#list_renumber() + command! -buffer VimwikiRenumberAllLists call nuwiki#commands#list_renumber_all() + command! -buffer VimwikiTableAlignQ call nuwiki#commands#table_align() + command! -buffer VimwikiTableAlignW call nuwiki#commands#table_align() command! -buffer Vimwiki2HTML call nuwiki#commands#export_current() command! -buffer Vimwiki2HTMLBrowse call nuwiki#commands#export_browse() @@ -76,6 +92,7 @@ if !has('nvim') command! -buffer VimwikiRebuildTags call nuwiki#commands#tags_rebuild() command! -buffer -nargs=? VimwikiSearchTags call nuwiki#commands#tags_search() command! -buffer -nargs=? VimwikiGenerateTagLinks call nuwiki#commands#tags_generate_links() + command! -buffer -nargs=? VimwikiGenerateTags call nuwiki#commands#tags_generate_links() " Tables, colorize, and clipboard paste. command! -buffer -nargs=1 VimwikiTable call nuwiki#commands#table_insert() @@ -84,6 +101,7 @@ if !has('nvim') command! -buffer -nargs=1 VimwikiColorize call nuwiki#commands#colorize() command! -buffer VimwikiPasteLink call nuwiki#commands#paste_link() command! -buffer VimwikiPasteUrl call nuwiki#commands#paste_url() + command! -buffer VimwikiCatUrl call nuwiki#commands#cat_url() " :Nuwiki* canonical aliases — Vim side. command! -buffer -count NuwikiIndex call nuwiki#commands#wiki_index() @@ -120,6 +138,7 @@ if !has('nvim') command! -buffer NuwikiPrevLink call nuwiki#commands#link_prev() command! -buffer NuwikiBaddLink call nuwiki#commands#badd_link() command! -buffer NuwikiMakeDiaryNote call nuwiki#commands#diary_today() + command! -buffer NuwikiTabMakeDiaryNote call nuwiki#commands#diary_today_tab() command! -buffer NuwikiMakeYesterdayDiaryNote call nuwiki#commands#diary_yesterday() command! -buffer NuwikiMakeTomorrowDiaryNote call nuwiki#commands#diary_tomorrow() command! -buffer NuwikiDiaryGenerateLinks call nuwiki#commands#diary_generate_index() @@ -130,13 +149,25 @@ if !has('nvim') command! -buffer -bang NuwikiAll2HTML if 0 | call nuwiki#commands#export_all_force() | else | call nuwiki#commands#export_all() | endif command! -buffer NuwikiRemoveDone call nuwiki#commands#list_remove_done() + command! -buffer -range NuwikiRemoveCheckbox call nuwiki#commands#list_remove_checkbox() + command! -buffer NuwikiRemoveCheckboxInList call nuwiki#commands#list_remove_checkbox_in_list() command! -buffer -nargs=? NuwikiListChangeLvl call nuwiki#commands#list_change_lvl() + command! -buffer NuwikiListToggle call nuwiki#commands#list_toggle_or_add_checkbox() + command! -buffer NuwikiIncrementListItem call nuwiki#commands#list_cycle_symbol(1) + command! -buffer NuwikiDecrementListItem call nuwiki#commands#list_cycle_symbol(-1) + command! -buffer -nargs=1 NuwikiChangeSymbol call nuwiki#commands#list_change_symbol(, 0) + command! -buffer -nargs=1 NuwikiChangeSymbolInList call nuwiki#commands#list_change_symbol(, 1) + command! -buffer NuwikiNormalizeLink call nuwiki#commands#normalize_link() + command! -buffer NuwikiRenumberList call nuwiki#commands#list_renumber() + command! -buffer NuwikiRenumberAllLists call nuwiki#commands#list_renumber_all() + command! -buffer NuwikiTableAlign call nuwiki#commands#table_align() command! -buffer -nargs=1 NuwikiTable call nuwiki#commands#table_insert() command! -buffer NuwikiTableMoveColumnLeft call nuwiki#commands#table_move_left() command! -buffer NuwikiTableMoveColumnRight call nuwiki#commands#table_move_right() command! -buffer -nargs=1 NuwikiColorize call nuwiki#commands#colorize() command! -buffer NuwikiPasteLink call nuwiki#commands#paste_link() command! -buffer NuwikiPasteUrl call nuwiki#commands#paste_url() + command! -buffer NuwikiCatUrl call nuwiki#commands#cat_url() " ===== Default key mappings (parity with upstream vimwiki) ===== " @@ -295,6 +326,7 @@ command! -buffer -count VimwikiTabIndex lua require('nuwiki.commands').wiki_ta command! -buffer VimwikiUISelect lua require('nuwiki.commands').wiki_ui_select() command! -buffer VimwikiDiaryIndex lua require('nuwiki.commands').diary_index() command! -buffer VimwikiMakeDiaryNote lua require('nuwiki.commands').diary_today() +command! -buffer VimwikiTabMakeDiaryNote lua require('nuwiki.commands').diary_today_tab() command! -buffer VimwikiMakeYesterdayDiaryNote lua require('nuwiki.commands').diary_yesterday() command! -buffer VimwikiMakeTomorrowDiaryNote lua require('nuwiki.commands').diary_tomorrow() command! -buffer VimwikiDiaryNextDay lua require('nuwiki.commands').diary_next() @@ -317,13 +349,28 @@ command! -buffer -nargs=1 VimwikiSearch lvimgrep // ** command! -buffer -nargs=1 VWS lvimgrep // ** command! -buffer VimwikiDeleteFile lua require('nuwiki.commands').delete_file() +command! -buffer VimwikiDeleteLink lua require('nuwiki.commands').delete_file() command! -buffer VimwikiRenameFile lua require('nuwiki.commands').rename_file() +command! -buffer VimwikiRenameLink lua require('nuwiki.commands').rename_file() command! -buffer VimwikiNextTask lua require('nuwiki.commands').next_task() command! -buffer VimwikiToggleListItem lua require('nuwiki.commands').toggle_list_item() command! -buffer VimwikiToggleRejectedListItem lua require('nuwiki.commands').reject_list_item() +command! -buffer VimwikiListToggle lua require('nuwiki.commands').list_toggle_or_add_checkbox() +command! -buffer VimwikiIncrementListItem lua require('nuwiki.commands').list_cycle_symbol(1) +command! -buffer VimwikiDecrementListItem lua require('nuwiki.commands').list_cycle_symbol(-1) +command! -buffer -nargs=1 VimwikiChangeSymbolTo lua require('nuwiki.commands').list_change_symbol(, false) +command! -buffer -nargs=1 VimwikiListChangeSymbolI lua require('nuwiki.commands').list_change_symbol(, false) +command! -buffer -nargs=1 VimwikiChangeSymbolInListTo lua require('nuwiki.commands').list_change_symbol(, true) command! -buffer VimwikiRemoveDone lua require('nuwiki.commands').list_remove_done() +command! -buffer -range VimwikiRemoveSingleCB lua require('nuwiki.commands').list_remove_checkbox() +command! -buffer VimwikiRemoveCBInList lua require('nuwiki.commands').list_remove_checkbox_in_list() command! -buffer -nargs=? VimwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl() +command! -buffer VimwikiNormalizeLink lua require('nuwiki.commands').normalize_link() +command! -buffer VimwikiRenumberList lua require('nuwiki.commands').list_renumber() +command! -buffer VimwikiRenumberAllLists lua require('nuwiki.commands').list_renumber_all() +command! -buffer VimwikiTableAlignQ lua require('nuwiki.commands').table_align() +command! -buffer VimwikiTableAlignW lua require('nuwiki.commands').table_align() command! -buffer Vimwiki2HTML lua require('nuwiki.commands').export_current() command! -buffer Vimwiki2HTMLBrowse lua require('nuwiki.commands').export_browse() @@ -338,6 +385,7 @@ command! -buffer VimwikiFindOrphans lua require('nuwiki.commands'). command! -buffer VimwikiRebuildTags lua require('nuwiki.commands').tags_rebuild() command! -buffer -nargs=? VimwikiSearchTags lua require('nuwiki.commands').tags_search() command! -buffer -nargs=? VimwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links() +command! -buffer -nargs=? VimwikiGenerateTags lua require('nuwiki.commands').tags_generate_links() " Tables, colorize, and clipboard paste. command! -buffer -nargs=1 VimwikiTable lua require('nuwiki.commands').table_insert() @@ -346,6 +394,7 @@ command! -buffer VimwikiTableMoveColumnRight lua require('nuwiki.commands command! -buffer -nargs=1 VimwikiColorize lua require('nuwiki.commands').colorize() command! -buffer VimwikiPasteLink lua require('nuwiki.commands').paste_link() command! -buffer VimwikiPasteUrl lua require('nuwiki.commands').paste_url() +command! -buffer VimwikiCatUrl lua require('nuwiki.commands').cat_url() " Canonical :Nuwiki* aliases — P10. command! -buffer -count NuwikiIndex lua require('nuwiki.commands').wiki_index(vim.v.count) @@ -384,6 +433,7 @@ command! -buffer NuwikiNextLink lua require('nuwiki.command command! -buffer NuwikiPrevLink lua require('nuwiki.commands').link_prev() command! -buffer NuwikiBaddLink lua require('nuwiki.commands').badd_link() command! -buffer NuwikiMakeDiaryNote lua require('nuwiki.commands').diary_today() +command! -buffer NuwikiTabMakeDiaryNote lua require('nuwiki.commands').diary_today_tab() command! -buffer NuwikiMakeYesterdayDiaryNote lua require('nuwiki.commands').diary_yesterday() command! -buffer NuwikiMakeTomorrowDiaryNote lua require('nuwiki.commands').diary_tomorrow() command! -buffer NuwikiDiaryNextDay lua require('nuwiki.commands').diary_next() @@ -398,13 +448,25 @@ command! -buffer NuwikiVSplitLink vsplit | lua vim.lsp.buf.definition() command! -buffer NuwikiTabnewLink tabnew | lua vim.lsp.buf.definition() command! -buffer NuwikiTabDropLink tabnew | lua vim.lsp.buf.definition() command! -buffer NuwikiRemoveDone lua require('nuwiki.commands').list_remove_done() +command! -buffer -range NuwikiRemoveCheckbox lua require('nuwiki.commands').list_remove_checkbox() +command! -buffer NuwikiRemoveCheckboxInList lua require('nuwiki.commands').list_remove_checkbox_in_list() command! -buffer -nargs=? NuwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl() +command! -buffer NuwikiListToggle lua require('nuwiki.commands').list_toggle_or_add_checkbox() +command! -buffer NuwikiIncrementListItem lua require('nuwiki.commands').list_cycle_symbol(1) +command! -buffer NuwikiDecrementListItem lua require('nuwiki.commands').list_cycle_symbol(-1) +command! -buffer -nargs=1 NuwikiChangeSymbol lua require('nuwiki.commands').list_change_symbol(, false) +command! -buffer -nargs=1 NuwikiChangeSymbolInList lua require('nuwiki.commands').list_change_symbol(, true) +command! -buffer NuwikiNormalizeLink lua require('nuwiki.commands').normalize_link() +command! -buffer NuwikiRenumberList lua require('nuwiki.commands').list_renumber() +command! -buffer NuwikiRenumberAllLists lua require('nuwiki.commands').list_renumber_all() +command! -buffer NuwikiTableAlign lua require('nuwiki.commands').table_align() command! -buffer -nargs=1 NuwikiTable lua require('nuwiki.commands').table_insert() command! -buffer NuwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left() command! -buffer NuwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right() command! -buffer -nargs=1 NuwikiColorize lua require('nuwiki.commands').colorize() command! -buffer NuwikiPasteLink lua require('nuwiki.commands').paste_link() command! -buffer NuwikiPasteUrl lua require('nuwiki.commands').paste_url() +command! -buffer NuwikiCatUrl lua require('nuwiki.commands').cat_url() " Buffer attach: keymaps + text objects + folding. lua require('nuwiki.ftplugin').attach(0) diff --git a/lua/nuwiki/commands.lua b/lua/nuwiki/commands.lua index ceaa737..df101a1 100644 --- a/lua/nuwiki/commands.lua +++ b/lua/nuwiki/commands.lua @@ -284,15 +284,16 @@ end -- ===== Diary ===== -local function _diary_open(cmd_name) +local function _diary_open(cmd_name, tab) return function() exec(cmd_name, uri_args(), function(r) - if r and r.uri then open_uri(r.uri) end + if r and r.uri then open_uri(r.uri, tab) end end) end end M.diary_today = _diary_open('nuwiki.diary.openToday') +M.diary_today_tab = _diary_open('nuwiki.diary.openToday', true) M.diary_yesterday = _diary_open('nuwiki.diary.openYesterday') M.diary_tomorrow = _diary_open('nuwiki.diary.openTomorrow') M.diary_index = _diary_open('nuwiki.diary.openIndex') @@ -481,6 +482,18 @@ function M.list_remove_done_all() exec('nuwiki.list.removeDone', uri_args()) end +-- `:VimwikiRemoveSingleCB` — strip the checkbox from the current item only. +function M.list_remove_checkbox() + exec('nuwiki.list.removeCheckbox', pos_args()) +end + +-- `:VimwikiRemoveCBInList` — strip checkboxes from every item in the list. +function M.list_remove_checkbox_in_list() + local args = pos_args()[1] + args.whole_list = true + exec('nuwiki.list.removeCheckbox', { args }) +end + function M.list_renumber() exec('nuwiki.list.renumber', pos_args()) end @@ -978,4 +991,15 @@ function M.normalize_link() wrap_cword_as_wikilink() end +--- Vimwiki `:VimwikiCatUrl` — echo the `file://` URL of the current +--- page's HTML export. The server computes the path from the wiki's +--- html config; we surface it via `:echo` like upstream. +function M.cat_url() + exec('nuwiki.link.catUrl', uri_args(), function(url) + if type(url) == 'string' and url ~= '' then + vim.api.nvim_echo({ { url } }, false, {}) + end + end) +end + return M