SidOfc / mkdx

A vim plugin that adds some nice extra's for working with markdown documents
https://www.vim.org/scripts/script.php?script_id=5620
MIT License
482 stars 13 forks source link

any way to stop auto-gen of TOC at top of every doc #190

Closed Aneeqasif closed 1 year ago

Aneeqasif commented 1 year ago

OS type:

Vim:

Vim version:

NVIM v0.9.1 Build type: Release LuaJIT 2.1.0-beta3

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

is there any way to stop generation of toc . (each time i open that file again a new toc duplicate is there at top) i donot need toc on every doc. i just want it on demand on some keybind or command etc is there anything for me?

SidOfc commented 1 year ago

Did you take a moment to check out the help file?

:h mkdx-setting-toc-update-on-write for example? If you did, please include what you've tried.

Aneeqasif commented 1 year ago

Yeah i looked at the help tags and i have added alot of things in config and one option was causing this issue so this is fix now

mmirus commented 1 year ago

@Aneeqasif can you share what option was causing this problem for you? This happens to me, as well.

mmirus commented 1 year ago

Hmm, I may have solved this by not lazy loading mkdx only for markdown files. With lazy.nvim:

return {
  "SidOfc/mkdx",
  -- ft = { "markdown" }, -- 👈 I think this was the problem
  config = function()
    vim.g["mkdx#settings"] = {
      highlight = { enable = 1 },
      enter = { shift = 1 },
      links = { external = { enable = 1 } },
      toc = { text = "Table of Contents", update_on_write = 1 },
      fold = { enable = 1 },
      tokens = { strike = "~" },
    }

    -- Unset the gx mapping from mkdx so that we can correctly open URLs in the browser
    vim.keymap.set("n", "<Plug>", "<Plug>(mkdx-gx)")
  end,
}