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

Conceallevel #399

Open
Canfry opened this issue Feb 13, 2024 · 9 comments
Open

Conceallevel #399

Canfry opened this issue Feb 13, 2024 · 9 comments
Labels
documentation Improvements or additions to documentation

Comments

@Canfry
Copy link

Canfry commented Feb 13, 2024

📚 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 Canfry added the documentation Improvements or additions to documentation label Feb 13, 2024
@hatunike
Copy link

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.

@Canfry
Copy link
Author

Canfry commented Feb 13, 2024

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

@0xForerunner
Copy link

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

@armaninux
Copy link

armaninux commented Mar 3, 2024

@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.

@natervader
Copy link

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.

@rolzy
Copy link
Contributor

rolzy commented Aug 17, 2024

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.

@JanRocketMan
Copy link

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

@einarpersson
Copy link

einarpersson commented Aug 20, 2024

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 #286 (comment)

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

@keithfancher
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

9 participants