vim-roam icon indicating copy to clipboard operation
vim-roam copied to clipboard

Creating link from visual mode selection

Open absurdist opened this issue 3 years ago • 0 comments

Hello,

Thank you Jeff.

I'm getting the following error when creating a link from text selected in visual mode:

Error detected while processing function roam#vimwiki#normalize_link_visual:
line    2:
E117: Unknown function: vimwiki#u#get_selection
E15: Invalid expression: vimwiki#u#get_selection()

with vimwiki I can select a number of words and hit enter to create a link and new page

once I install vim-roam I get the above error.

(I'm running nvim in powershell on windows)

For now I'm hacking around the issue:

autoload\roam\vimwiki.vim

" " Normalize link in visual mode Enter keypress
function! roam#vimwiki#normalize_link_visual() abort
  " Get selection content (this isn't a builtin, unfortunately)
  " let visual_selection = vimwiki#u#get_selection()
  " let extension = fnamemodify(trim(visual_selection), ":e")
  " if extension ==? "png" || extension[:2] ==? "tif" || extension ==? "bmp" || extension ==? "jpg" || extension ==? "jpeg"
  "   call s:convert_to_image_link(visual_selection)
  "   return
  " else
    call vimwiki#base#normalize_link(1)
  "endif
endfunction

It looks like that function isn't in base.vim any more https://github.com/vimwiki/vimwiki/blob/master/autoload/vimwiki/base.vim

though it looks like it was part of a fix at one point

https://github.com/vimwiki/vimwiki/commit/ac38bb2f09f49b287ed8f59e0518b56dceadd6cc

From reading the comments, perhaps the normalise functionality is now incorporated into vimwiki?

Kind regards

Mat

absurdist avatar Aug 25 '21 06:08 absurdist