jceb / vim-orgmode

Text outlining and task management for Vim based on Emacs' Org-Mode
http://www.vim.org/scripts/script.php?script_id=3642
Other
3.1k stars 266 forks source link

Links no longer visible #371

Closed yamsu closed 1 year ago

yamsu commented 2 years ago

After the recent merge it seems that links are no longer visible

The following is not visible in normal mode, but appears as usual in insert mode

[[link]] Text   => Text
[[link][Description]] Text => Text
yamsu commented 2 years ago

Quick work around is to disable conceal in

<plugin_folder>/vim-orgmode/ftplugin/org.vim

Comment out the following line (line 30)

setlocal conceallevel=2 concealcursor=nc
seflue commented 1 year ago

I can confirm this problem. The workaround expands the links completely, which is actually very noisy. Any news on this?

seflue commented 1 year ago

After doing some debugging, I actually found the source of the problem: If someone is using a plugin, which already shortens links in orgmode-style (like org.vim or vim-polyglot, the links vanish. My solution: In <plugin_folder>/vim-orgmode/syntax/org.vim introduce a new global variable at the beginning:

if !exists("g:conceal_org_hyperlinks")
    let g:vim_orgmode_conceal_hyperlinks=1
endif

And then around line 276 wrap the whole highlighting code in an if clause:

" Hyperlinks: {{{1
if (g:vim_orgmode_conceal_hyperlinks == 1)
  syntax match hyperlink    "\[\{2}[^][]*\(\]\[[^][]*\)\?\]\{2}" contains=hyperlinkBracketsLeft,hyperlinkURL,hyperlinkBracketsRight containedin=ALL
  if (s:conceal_aggressively == 1)
      syntax match hyperlinkBracketsLeft    contained "\[\{2}#\?"     conceal
  else
      syntax match hyperlinkBracketsLeft    contained "\[\{2}"     conceal
  endif
  syntax match hyperlinkURL                 contained "[^][]*\]\[" conceal
  syntax match hyperlinkBracketsRight   contained "\]\{2}"     conceal
  hi def link hyperlink Underlined
endif

Now I am able to disable the vim-orgmode link concealing & highlighting with the following line in my .vimrc:

let g:vim_orgmode_conceal_hyperlinks=0
seflue commented 1 year ago

For vim-polyglot you also have the option, to disable a certain filetype plugin, e.g.

let g:polyglot_disabled = ['org']
yamsu commented 1 year ago

@seflue thanks for solving this. The following works!

For vim-polyglot you also have the option, to disable a certain filetype plugin, e.g.

let g:polyglot_disabled = ['org']

However, It would be great to put in a pull request for the orgmode_conceal_hyperlinks option.