Skip to content

Commit 353e445

Browse files
Add support for mini.icons, prefer when available
# Details mini.icons seems to support a wider range of language icons than nvim-web-devicons. Add logic to prefer icons from mini.icons when available, otherwise continue using nvim-web-devicons. Update documentation and tests accordingly.
1 parent 770f7a1 commit 353e445

File tree

8 files changed

+33
-23
lines changed

8 files changed

+33
-23
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ Plugin to improve viewing Markdown files in Neovim
3737
Used to parse `markdown` files
3838
- [latex](https://github.com/latex-lsp/tree-sitter-latex) (Optional):
3939
Used to get `LaTeX` blocks from `markdown` files
40-
- [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) (Optional):
41-
Used for icon above code blocks
40+
- Icon provider plugin (Optional): Used for icon above code blocks
41+
- [mini.icons](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-icons.md)
42+
- [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons)
4243
- System dependencies:
4344
- [pylatexenc](https://pypi.org/project/pylatexenc/) (Optional):
4445
Used to transform `LaTeX` strings to appropriate unicode using `latex2text`
@@ -51,10 +52,9 @@ Plugin to improve viewing Markdown files in Neovim
5152
{
5253
'MeanderingProgrammer/markdown.nvim',
5354
name = 'render-markdown', -- Only needed if you have another plugin named markdown.nvim
54-
dependencies = {
55-
'nvim-treesitter/nvim-treesitter', -- Mandatory
56-
'nvim-tree/nvim-web-devicons', -- Optional but recommended
57-
},
55+
dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite
56+
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
57+
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
5858
config = function()
5959
require('render-markdown').setup({})
6060
end,
@@ -67,8 +67,10 @@ Plugin to improve viewing Markdown files in Neovim
6767
use({
6868
'MeanderingProgrammer/markdown.nvim',
6969
as = 'render-markdown', -- Only needed if you have another plugin named markdown.nvim
70-
after = { 'nvim-treesitter' }, -- Mandatory
71-
requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- Optional but recommended
70+
after = { 'nvim-treesitter' },
71+
requires = { 'echasnovski/mini.nvim', opt = true }, -- if you use the mini.nvim suite
72+
-- requires = { 'echasnovski/mini.icons', opt = true }, -- if you use standalone mini plugins
73+
-- requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- if you prefer nvim-web-devicons
7274
config = function()
7375
require('render-markdown').setup({})
7476
end,

demo/callout.gif

8.05 KB
Loading

demo/heading_code.gif

24 KB
Loading

doc/render-markdown.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ Plugin to improve viewing Markdown files in Neovim
5858
Used to parse `markdown` files
5959
- latex <https://github.com/latex-lsp/tree-sitter-latex> (Optional):
6060
Used to get `LaTeX` blocks from `markdown` files
61-
- nvim-web-devicons <https://github.com/nvim-tree/nvim-web-devicons> (Optional):
62-
Used for icon above code blocks
61+
- Icon provider plugin (Optional): Used for icon above code blocks
62+
- mini.icons <https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-icons.md>
63+
- nvim-web-devicons <https://github.com/nvim-tree/nvim-web-devicons>
6364
- System dependencies:
6465
- pylatexenc <https://pypi.org/project/pylatexenc/> (Optional):
6566
Used to transform `LaTeX` strings to appropriate unicode using `latex2text`
@@ -75,10 +76,9 @@ LAZY.NVIM *render-markdown-install-lazy.nvim*
7576
{
7677
'MeanderingProgrammer/markdown.nvim',
7778
name = 'render-markdown', -- Only needed if you have another plugin named markdown.nvim
78-
dependencies = {
79-
'nvim-treesitter/nvim-treesitter', -- Mandatory
80-
'nvim-tree/nvim-web-devicons', -- Optional but recommended
81-
},
79+
dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite
80+
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
81+
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
8282
config = function()
8383
require('render-markdown').setup({})
8484
end,
@@ -92,8 +92,10 @@ PACKER.NVIM *render-markdown-install-packer.nvim*
9292
use({
9393
'MeanderingProgrammer/markdown.nvim',
9494
as = 'render-markdown', -- Only needed if you have another plugin named markdown.nvim
95-
after = { 'nvim-treesitter' }, -- Mandatory
96-
requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- Optional but recommended
95+
after = { 'nvim-treesitter' },
96+
requires = { 'echasnovski/mini.nvim', opt = true }, -- if you use the mini.nvim suite
97+
-- requires = { 'echasnovski/mini.icons', opt = true }, -- if you use standalone mini plugins
98+
-- requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- if you prefer nvim-web-devicons
9799
config = function()
98100
require('render-markdown').setup({})
99101
end,

lua/render-markdown/icons.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
local ok, devicons = pcall(require, 'nvim-web-devicons')
1+
local has_mini_icons, mini_icons = pcall(require, 'mini.icons')
2+
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
23

34
local M = {}
45

56
---@param language string
67
---@return string?
78
---@return string?
89
M.get = function(language)
9-
if ok then
10+
if has_mini_icons then
11+
---@diagnostic disable-next-line: return-type-mismatch
12+
return mini_icons.get('filetype', language)
13+
elseif has_devicons then
1014
return devicons.get_icon_by_filetype(language)
1115
else
1216
return nil, nil

tests/callout_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async_tests.describe('callout.md', function()
107107
{
108108
row = { tip_start + 4 },
109109
col = { 5 },
110-
virt_text = { { ' lua', { 'DevIconLua', 'ColorColumn' } } },
110+
virt_text = { { '󰢱 lua', { 'MiniIconsAzure', 'ColorColumn' } } },
111111
virt_text_pos = 'inline',
112112
},
113113
{

tests/heading_code_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async_tests.describe('heading_code.md', function()
6262
{
6363
row = { 10 },
6464
col = { 3 },
65-
virt_text = { { ' python', { 'DevIconPy', 'ColorColumn' } } },
65+
virt_text = { { '󰌠 python', { 'MiniIconsYellow', 'ColorColumn' } } },
6666
virt_text_pos = 'inline',
6767
},
6868
})

tests/minimal.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---@param path_name string
2-
---@param plugin_name string
2+
---@param plugin_name string?
33
local function source_plugin(path_name, plugin_name)
44
local data_path = vim.fn.stdpath('data')
55
assert(type(data_path) == 'string')
66
local plugin_path = vim.fs.find(path_name, { path = data_path })
77
vim.opt.rtp:prepend(unpack(plugin_path))
8-
vim.cmd.runtime('plugin/' .. plugin_name)
8+
if plugin_name ~= nil then
9+
vim.cmd.runtime('plugin/' .. plugin_name)
10+
end
911
end
1012

1113
---@param required_parsers string[]
@@ -22,7 +24,7 @@ end
2224
vim.opt.rtp:prepend('.')
2325
source_plugin('plenary.nvim', 'plenary.vim')
2426
source_plugin('nvim-treesitter', 'nvim-treesitter.lua')
25-
source_plugin('nvim-web-devicons', 'nvim-web-devicons.vim')
27+
source_plugin('mini.nvim', nil)
2628

2729
-- https://github.com/ThePrimeagen/refactoring.nvim/blob/master/scripts/minimal.vim
2830
ensure_installed({ 'markdown', 'markdown_inline', 'latex' })

0 commit comments

Comments
 (0)