OXY2DEV / markview.nvim

An experimental markdown previewer for Neovim
Apache License 2.0
602 stars 23 forks source link

[Feature Request] Option to only unconceal the current line #25

Open Rizhiy opened 5 days ago

Rizhiy commented 5 days ago

Currently, when I enter insert mode, the whole file changes the conceal level. What would be better is if only the current line changed the level of conceal, or perhaps the current "context", e.g. code block.

kuntau commented 5 days ago

The obsidian style. Would be great if we could have this feature

OXY2DEV commented 5 days ago

Last time I tried it was very VERY buggy.

I am going to try again later to see if I can do something.

kuntau commented 5 days ago

Maybe this feature better suited to be in Neovim core?

OXY2DEV commented 5 days ago

Maybe this feature better suited to be in Neovim core?

Neovim core already has this. You can check it by setting the conceallevel to 2.

The only issue is it doesn't hide virtual text. So things like inline code, link have the same text shown twice.

oonamo commented 4 hours ago

I found a workaround for this, at least for markdown wiki links and md links. I placed this in my after/ftplugin/markdown.lua

vim.api.nvim_create_autocmd("CursorMoved", {
    buffer = vim.api.nvim_get_current_buf(),
    callback = function()
        if vim.fn.mode():sub(1, 1) == "i" then
            return
        end
        local cursor = vim.api.nvim_win_get_cursor(0)
        local line = vim.fn.getline(cursor[1])
        local is_wiki_link = line:match("%[%[.*%]%]")
        if is_wiki_link then
            vim.o.concealcursor = ""
            return
        end
        local is_md_link = line:match("%[.*%]%(.*%)")
        if is_md_link then
            vim.o.concealcursor = ""
            return
        end
        -- local is_todo = line:match("- %[.%]")
        -- if is_todo then
        --  vim.o.concealcursor = ""
        --  return
        -- end
        vim.o.concealcursor = "n"
    end,
})