Open Canfry opened 9 months ago
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.
Ok thank you very much I did it also with a different file!!!
Is there a way to set this just for markdown? Or possible only when the obsidian plugin is loaded?
@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.
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.
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.
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
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?
Is there a way to set conceallevel = 1 to vault files only, without triggering this warning?
I came here searching for exactly this.
I don't want conceallevel
set for all my markdown files -- just the ones affected by obsidian.nvim
.
📚 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!!!