Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brackets in links are not concealed #99

Closed
jbarik opened this issue Oct 2, 2021 · 15 comments
Closed

Brackets in links are not concealed #99

jbarik opened this issue Oct 2, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@jbarik
Copy link

jbarik commented Oct 2, 2021

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

@jbarik jbarik added the bug Something isn't working label Oct 2, 2021
@kristijanhusak
Copy link
Member

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

@jbarik
Copy link
Author

jbarik commented Oct 2, 2021

:echo &conceallevel produces the answer 0

@kristijanhusak
Copy link
Member

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

@jbarik
Copy link
Author

jbarik commented Oct 2, 2021

:setlocal conceallevel=2 worked

@kristijanhusak
Copy link
Member

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

@jbarik
Copy link
Author

jbarik commented Oct 2, 2021

echo &concealcursor is empty

@kristijanhusak
Copy link
Member

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
Copy link
Author

jbarik commented Oct 2, 2021

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
Copy link
Member

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

@jbarik
Copy link
Author

jbarik commented Oct 2, 2021

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
Copy link
Member

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
Copy link
Author

jbarik commented Oct 2, 2021

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
Copy link

sethidden commented Nov 17, 2021

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
Copy link
Member

@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
Copy link

For organization's sake - concealed text wrongly contributing to wrapping is reported upstream in neovim under neovim/neovim#14409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants