nvim-cmp source for completing markdown links.
cmp-markdown-link requires plenary.nvim to be installed.
Install with favourite package manager.
E.g. plug:
Plug 'dburian/cmp-markdown-link'
Add markdown-link
to your nvim-cmp sources.
Minimal setup:
require'cmp'.setup {
sources = {
{ name = 'markdown-link' },
}
More involved setup:
local function png_or_markdown_files(path)
return string.match(path, '.*%.png') or string.match(path, '.*%.md')
end
require'cmp'.setup {
sources = {
{
name = 'markdown-link',
option = {
reference_link_location = 'top',
searched_depth = 3,
searched_dirs = {
'%:h', --always search the current dir
'~/docs/wiki', --custom path to search as well
},
--only offer links to .png or .md files
search_pattern = png_or_markdown_files,
wiki_base_url = '',
wiki_end_url = '.md',
}
},
}
Your links should always start with wiki_base_url
and end with wiki_end_url
.
Otherwise the link target could become ambiguous. For more info type :help cmp-markdown-link
.
If you want a certain functionality to be implemented/changed, feel free to create issues and PRs. I will address/merge them when I have time.