ymich9963/mdnotes.nvim

github github
note-taking
stars 2
issues 0
subscribers 0
forks 0
CREATED

UPDATED


mdnotes.nvim

Markdown Notes (mdnotes or Mdn) aims to improve the Neovim Markdown note-taking experience by providing features like better Wikilink support, adding/removing hyperlinks to images/files/URLs, file history, asset management, referencing, backlinks, and formatting. All this without relying on any LSP but using one is recommended.

Read the documentation with :h mdnotes.txt.

Features

  • Open hyperlinks to files and URLs with :Mdn open.
  • Set your index file and go there with :Mdn home.
  • Set your journal file and go there with :Mdn journal.
  • Open Wikilinks ([[link]] or [[link#Section]]) with :Mdn open_wikilink.
  • Toggle hyperlinks with :Mdn toggle_hyperlink which pastes your copied hyperlink over the selected text or removes it.
  • Show backlinks of the current file with :Mdn show_backlinks or to show the backlinks of a Wikilink by hovering over the link and executing the same command.
  • Implements an outliner mode by doing :Mdn toggle_outliner. Make sure to exit afterwards by re-toggling.
  • Insert an image or file from clipboard using :Mdn insert_image or :Mdn insert_file which creates the appropriate link and copies or moves the image to your assets folder. Requires xclip or wl-clipboard for Linux.
  • Supports Windows eccentricities.
  • Use :Mdn cleanup_unused_assets to easily cleanup assets that you no longer use.
  • Can go backwards and forwards in notes history by using :Mdn go_back and :Mdn go_forward.
  • Toggle the appropriate formatting with :Mdn bold/italic/inline_code/strikethrough_toggle.
  • Rename link references and the file itself using :Mdn rename_link_references.
  • Quickly insert the date using :Mdn insert_date (in a customiseable format) when using your journal.

Setup

{
    "ymich9963/mdnotes.nvim",
    opts = {
        assets_path = "assets",     -- your assets path for assets related commands
        index_file = "MAIN.md",     -- your index file for :Mdn home
        journal_file = "JOURNAL.md",-- your journal file for :Mdn journal
    }
}

Default Config

{
    index_file = "",
    journal_file = "",
    assets_path = "",
    insert_file_behaviour = "copy", -- "copy" or "move" files when inserting from clipboard
    overwrite_behaviour = "error",  -- "overwrite" or "error" when finding assset file conflicts
    open_behaviour = "buffer",      -- "buffer" or "tab" to open when following links
    date_format = "%a %d %b %Y"     -- date format based on :h strftime()
}

Recommendations

I've listed some recommended keymaps and settings below for a great experience with mdnotes. They are not applied by default and therefore have to be mapped manually. All suggestions here should ideally be in an after/ftplugin/markdown.lua file so that they are specific to Markdown files.

Keymaps

Here are some recommended keymaps for mdnotes,

    vim.keymap.set("n", "gf", ":Mdn open_wikilink<CR>", { desc = "Open markdown file from Wikilink" })
    vim.keymap.set({"v", "n"}, "<C-K>", ":Mdn hyperlink_toggle<CR>", { desc = "Toggle hyperlink" })
    vim.keymap.set("n", "<Left>", ":Mdn go_back<CR>", { desc = "Go to back to previously visited Markdown buffer" })
    vim.keymap.set("n", "<Right>", ":Mdn go_forward<CR>", { desc = "Go to next visited Markdown buffer" })
    vim.keymap.set({"v", "n"}, "<C-B>", ":Mdn bold_toggle<CR>", { desc = "Toggle bold formatting" })
    vim.keymap.set({"v", "n"}, "<C-I>", ":Mdn italics_toggle<CR>", { desc = "Toggle italics formatting" })

If you really like outliner mode and want to indent entire blocks then these remaps are very helpful,

vim.keymap.set("v", "<", "<gv", { desc = "Indent left and reselect" }) -- Better indenting in visual mode
vim.keymap.set("v", ">", ">gv", { desc = "Indent right and reselect" })

Settings

If you are on Windows then setting this option will allow you to use the build in <C-x> <C-f> file completion,

vim.opt.isfname:remove('[', ']') -- To enable path completion on Windows <C-x> <C-f>

These other two settings are for enabling wrapping only in Markdown files, and to disable the LSP diagnostics if they annoy you.

vim.wo.wrap = true -- Enable wrap for current .md window
vim.diagnostic.enable(false, { bufnr = 0 }) -- Disable diagnostics for current .md buffer

LSPs

The main reason I started this project was dissatisfaction with MD LSPs at the time, and I really wanted to use Neovim as my notes editor. It is recommended to use LSPs with mdnotes since I'm trying to work with the LSPs and to not try to create something from scratch. So far certain LSP features haven't been working for me fully, but I do recommend markdown-oxide and marksman.

Other Cool Markdown-related Plugins