nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
3.03k stars 134 forks source link

Brackets in links are not concealed #99

Closed jbarik closed 3 years ago

jbarik commented 3 years ago

Are you using "tree-sitter" branch?

No

Describe the bug

org_link_issue

As shown in the above message, for links the brackets are not hidden. Am I missing some setting. My minimal init.vim to reproduce the issue

init.vim

function! PackagerInit() abort
packadd vim-packager
call packager#init()
call packager#add('kristijanhusak/orgmode.nvim')
endfunction

command! PackagerInstall call PackagerInit() | call packager#install()
command! -bang PackagerUpdate call PackagerInit() | call packager#update({ 'force_hooks': '' })
command! PackagerClean call PackagerInit() | call packager#clean()
command! PackagerStatus call PackagerInit() | call packager#status()

lua << EOF
require('orgmode').setup({
org_hide_leading_stars = true
})
EOF

Steps to reproduce

My org file contnts: [[test]] [[test][link to test]]

Expected behavior

The brackets should be hidden

Emacs functionality

No response

Screenshots and recordings

org_link_issue

OS / Distro

Ubuntu 20.04.3 LTS

Neovim version/commit

NVIM v0.5.0-dev+1372-g056c464e8

Additional context

No response

kristijanhusak commented 3 years ago

what's your conceallevel (:echo &conceallevel) while you're in the org buffer?

jbarik commented 3 years ago

:echo &conceallevel produces the answer 0

kristijanhusak commented 3 years ago

try doing :setlocal conceallevel=2 while in org buffer and see if it works then.

jbarik commented 3 years ago

:setlocal conceallevel=2 worked

kristijanhusak commented 3 years ago

Ok, and what about the output of echo &concealcursor ?

jbarik commented 3 years ago

echo &concealcursor is empty

kristijanhusak commented 3 years ago

Ok. You need to add set conceallevel=2 to your vimrc. If you want to have concealing only for org, add it to autocmd:

autocmd FileType org setlocal conceallevel=2
jbarik commented 3 years ago

Thanks a lot. with conceallevel=2 the issue is solved, but I am seeing one more behaviour. the moment my cursor is on the line containing the link it gets exapnded. I would like it to be expanded when I am in insert mode - I am switching from vim-orgmode, where that was the behaviour. Can I change some setting to get my desired behaviour.

kristijanhusak commented 3 years ago

Yes, add also setlocal concealcursor=nc to the autocmd.

jbarik commented 3 years ago

Sorry to bother again. I see that even with conceallevel=2, the brackets are not hidden when it is inside a heading Screenshot from 2021-10-02 15-19-30

kristijanhusak commented 3 years ago

Links in headline are not supported because of similar issue like this. You should use tree-sitter branch with experimental highlighting enabled if you want this.

jbarik commented 3 years ago

Good to know that tree-sitter branch will fix this. For now, I replaced the line

"syntax match org_hyperlink "[{2}[^][](][[^][])\?]{2}" contains=org_hyperlinkBracketsLeft,org_hyperlinkURL,org_hyperlinkBracketsRight"

in org.vim file to

"syntax match org_hyperlink "[{2}[^][](][[^][])\?]{2}" contains=org_hyperlinkBracketsLeft,org_hyperlinkURL,org_hyperlinkBracketsRight containedin=OrgHeadlineLevel1,OrgHeadlineLevel2,OrgHeadlineLevel3,OrgHeadlineLevel4,OrgHeadlineLevel5"

With this I think it'll work for 5 levels of heading and I can live with that till tree-sitter branch becomes the main.

Thanks for your effort.

sethidden commented 2 years ago

There seems to be an issue with line wrapping if the link URL is very long image image

This is with disable = {'org'} in Treesitter as I saw the notice that concealing in TS is unsupported. Should I open a separate issue?

Though it's possible to do setlocal nowrap to avoid this, but this can sometimes make :tags: :help orgmode-org_set_tags_command show off-screen in a small split

EDIT: Thought I'd post the lua version of the augroup that includes all of the 3 fixes posted in above posts: In your init.lua (if you use init.vim just copy the stuff between [[ ]] (exclusive))

vim.api.nvim_exec(
[[
  function! SetOrgSets()
    setlocal conceallevel=2
    setlocal concealcursor=nc
    setlocal nowrap
  endfunction
  autocmd FileType org call SetOrgSets()
]],
true)
kristijanhusak commented 2 years ago

@sethidden I don't think this can be fixed. It's just how concealing works in Vim. Try doing set conceallevel=0 and see how it really looks in the background. There is no way to control this behavior. As you said, nowrap should do the trick.

sethidden commented 2 years ago

For organization's sake - concealed text wrongly contributing to wrapping is reported upstream in neovim under https://github.com/neovim/neovim/issues/14409