obsidian.nvim icon indicating copy to clipboard operation
obsidian.nvim copied to clipboard

Conceallevel

Open Canfry opened this issue 2 years ago • 9 comments

📚 The doc issue

In the doc it's talked about the conceallevel that has to be set to 1 or 2, but no indication on how to set it up, where in the config.... Has it is mentioned in another issue that I've found you detail how to set it up. Would be great to have it explained here too.

Suggest a potential alternative/fix

Add the detailed steps to set up the conceallevel!!!

Canfry avatar Feb 13 '24 14:02 Canfry

There's quite a few different ways that people set their config options. But conceallevel isn't just an Obsidian nvim thing.

local opt = vim.opt

opt.conceallevel = 2

Here's a basic example for how one could set the conceal level. I have options broken into it's own file. But you might have something configured differently.

hatunike avatar Feb 13 '24 15:02 hatunike

Ok thank you very much I did it also with a different file!!!

Canfry avatar Feb 13 '24 16:02 Canfry

Is there a way to set this just for markdown? Or possible only when the obsidian plugin is loaded?

0xForerunner avatar Mar 01 '24 21:03 0xForerunner

@ewoolsey you can try adding this to your config file (init.vim):

augroup obsidian
    autocmd!
    autocmd Filetype markdown set conceallevel=2
augroup END

Doing so will set conceallevel to 2 for markdown files regardless of your global setting.

Edit: I'm not an expert in lua so I'm not 100% sure this applies to init.lua files as well. If not, you need to find its equivalent syntax, but it's certainly doable.

armaninux avatar Mar 03 '24 00:03 armaninux

I was able to put a bandaid over it for me by just adding programs.nixvim.extraConfigLuaPost = "vim.opt.conceallevel = 2";. I'm too lazy to figure out a markdown specific solution (likely what @armaninux had mentioned) but it also fits the bill just on a global level.

natervader avatar Jun 27 '24 03:06 natervader

You make an after/ftplugin/ folder at the root of your config (for ex in Linux ~/.config/nvim/after/ftplugin), then you can make a file per filetype with the filetype as their name. If you want to limit conceal to markdown only, you can create ~/.config/nvim/after/ftplugin/markdown.lua with the following:

vim.opt.conceallevel = 1

It will automatically load that file when you open a markdown file only.

rolzy avatar Aug 17 '24 00:08 rolzy

If anyone looks for a simpler fix, you can just add this to your lua/options.lua file

-- Add concealing when we open markdown files for obsidian.nvim ui
vim.api.nvim_create_autocmd('BufEnter', {
  callback = function (opts)
    if vim.bo[opts.buf].filetype == 'markdown' then
      vim.opt.conceallevel = 2
    end
  end,
})

This is similar to @armaninux suggestion but in plain lua

JanRocketMan avatar Aug 19 '24 20:08 JanRocketMan

I added this

      callbacks = {
        enter_note = function()
          vim.wo.conceallevel = 1
        end,
        leave_note = function()
          vim.wo.conceallevel = 0
        end,
      }

It works as intended, but I get this ugly warning now.

Obsidian additional syntax features require 'conceallevel' to be set to 1 or 2, but you have 'conceallevel' set to '0'.
See https://github.com/epwalsh/obsidian.nvim/issues/286 for more details.
If you don't want Obsidian's additional UI features, you can disable them and suppress this warning by setting 'ui.enable = false' in your Obsidian nvim con
fig.
Press ENTER or type command to continue

I see that this was discussed here https://github.com/epwalsh/obsidian.nvim/issues/286#issuecomment-2048334358

@epwalsh Is there a way to set conceallevel = 1 to vault files only, without triggering this warning?

einarpersson avatar Aug 20 '24 19:08 einarpersson