jalvesaq / zotcite

Neovim plugin for integration with Zotero
GNU General Public License v3.0
159 stars 13 forks source link

Is there a way to change the conceallevel? #66

Closed tdyoshida closed 9 months ago

tdyoshida commented 9 months ago

Hi! I just started using this plugin, and so far I feel like this is what I've been looking for. One problem I have is the conceallevel. It looks like the conceallevel is set to 2 by zotcite, which works fine for markdown.

However, it also changes my Rmarkdown file to hide the chunk delimiters (```{r} and ```). It still shows the chunk label, but the end of the chunk delimiter is completely hidden.

For Rmarkdown, I'd prefer to set the conceallevel to 0. I created rmd.lua (vim.opt.conceallevel = 0) in ~/.config/ftplugin or tried to setup autocmd, but looks like the zotcite's setting overrides them. Now I set keymaps to change between conceallevels, which work okay, but not ideal. Is there a way to accomplish this automatically?

I appreciate your help!

jalvesaq commented 9 months ago

Chunk delimiters are not hidden here. Do you have any additional syntax plugin installed?

tdyoshida commented 9 months ago

Thanks for your quick response!

I do use nvim-treesitter, and pictures below show the difference by enabling/disabling treesitter and zotcite.

zotcite: enabled; treesitter: enabled

with_zotcite_with_treesitter

zotcite: enabled; treesitter: disabled

with_zotcite_without_treesitter

zotcite: disabled; treesitter: enabled

without_zotcite_with_treesitter

zotcite: enabled; treesitter: enabled; conceallevel=0

with_zotcite_with_treesitter_conceallevel0

You can see that (zotcite: disabled; treesitter: enabled) and (zotcite: enabled; treesitter: enabled; conceallevel=0) look the same, and this is what I'd like. Of course disabling zotcite is not an option, but I do want to keep treesitter too...

Sorry for bothering you for non-essential matter, but I appreciate your help!

jalvesaq commented 9 months ago

I guessed that you were using vim-pandoc-syntax. I didn't install it, but looking at its code, it seems that adding "inlinecode" to its conceal blacklist was necessary to avoid hiding backticks. Anyway, the option below should make zotcite set conceallevel as you want:

let zotcite_conceallevel = 0
tdyoshida commented 9 months ago

I do not use vim-pandoc-syntax. I install markdown and markdown-inline for treesitter, but simply disabling them did not solve the problem...

Anyway, I created an autocmd with zotcite_conceallevel, and it works perfeclty! Thank you so much!

jalvesaq commented 9 months ago

Treesitter's syntax highlight was disabled in my init.lua for both r and markdown:

require("nvim-treesitter.configs").setup({
    ensure_installed = { "c", "lua", "vim", "vimdoc", "python" },
    sync_install = true,
    highlight = {
        enable = true,
        disable = { "r", "markdown", "vimdoc" },
    },
    indent = { enable = true,
        disable = { "r", "markdown" },
    },
})

But if I remove "markdown" from the disable list, I can replicate the issue.

tdyoshida commented 9 months ago

I'm sorry what I wrote in the previous post was incorrect. Disabling markdown in treesitter does make the chunk delimiters to be visible. Personally I prefer enabling markdown highlights, and I'll stick to use zotcite_conceallevel option for Rmd files. Thanks!

jalvesaq commented 9 months ago

Thanks for the feedback. I'm closing the issue...

jalvesaq commented 8 months ago

Now I'm understanding a bit more about how tree-sitter works. You may try to avoid the concealing of code block delimiters by creating the following file:

~/.config/nvim/queries/markdown/highlights.scm:

;; Undo conceal of language name
(fenced_code_block
  (info_string (language) @none
  (#set! noconceal)))