Skip to content

Commit d7d793b

Browse files
Make filetypes configurable
1 parent 07685a1 commit d7d793b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ require('render-markdown').setup({
6464
(pipe_table_row) @table_row
6565
]]
6666
),
67+
-- Filetypes this plugin will run on
68+
file_types = { 'markdown' },
6769
-- vim modes that will show a rendered view of the markdown file, all other
6870
-- modes will be uneffected by this plugin
6971
render_modes = { 'n', 'c' },

lua/render-markdown/init.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ local M = {}
1919

2020
---@class UserConfig
2121
---@field public query? Query
22+
---@field public file_types? string[]
2223
---@field public render_modes? string[]
2324
---@field public headings? string[]
2425
---@field public bullet? string
@@ -49,6 +50,7 @@ function M.setup(opts)
4950
(pipe_table_row) @table_row
5051
]]
5152
),
53+
file_types = { 'markdown' },
5254
render_modes = { 'n', 'c' },
5355
headings = { '󰲡', '󰲣', '󰲥', '󰲧', '󰲩', '󰲫' },
5456
bullet = '',
@@ -84,17 +86,17 @@ function M.setup(opts)
8486
'TextChanged',
8587
'WinResized',
8688
}, {
87-
group = vim.api.nvim_create_augroup('Markdown', { clear = true }),
89+
group = vim.api.nvim_create_augroup('RenderMarkdown', { clear = true }),
8890
callback = function()
8991
vim.schedule(M.refresh)
9092
end,
9193
})
9294
end
9395

94-
M.namespace = vim.api.nvim_create_namespace('markdown.nvim')
96+
M.namespace = vim.api.nvim_create_namespace('render-markdown.nvim')
9597

9698
M.refresh = function()
97-
if vim.bo.filetype ~= 'markdown' then
99+
if not vim.tbl_contains(state.config.file_types, vim.bo.filetype) then
98100
return
99101
end
100102

lua/render-markdown/state.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
---@class Config
1616
---@field public query Query
17+
---@field public file_types string[]
1718
---@field public render_modes string[]
1819
---@field public headings string[]
1920
---@field public bullet string

0 commit comments

Comments
 (0)