Skip to content

Commit 510afd0

Browse files
authored
feat: configure default enabled state (#17)
* feat: configure default enabled state * docs: update README * fix: change enabled to start_enabled Signed-off-by: Chaz Leong <[email protected]> * docs: update README Signed-off-by: Chaz Leong <[email protected]> --------- Signed-off-by: Chaz Leong <[email protected]>
1 parent 467c135 commit 510afd0

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ by the user.
4949

5050
```lua
5151
require('render-markdown').setup({
52+
-- Configure whether Markdown should be rendered by default or not
53+
start_enabled = true,
5254
-- Capture groups that get pulled from markdown
5355
markdown_query = [[
5456
(atx_heading [

lua/render-markdown/init.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ local M = {}
3434
---@field public checked? string
3535

3636
---@class UserConfig
37+
---@field public start_enabled? boolean
3738
---@field public markdown_query? string
3839
---@field public inline_query? string
3940
---@field public log_level? 'debug'|'error'
@@ -52,6 +53,7 @@ local M = {}
5253
function M.setup(opts)
5354
---@type Config
5455
local default_config = {
56+
start_enabled = true,
5557
markdown_query = [[
5658
(atx_heading [
5759
(atx_h1_marker)
@@ -128,9 +130,10 @@ function M.setup(opts)
128130
latex = '@markup.math',
129131
quote = '@markup.quote',
130132
},
133+
enabled = true,
131134
}
132-
state.enabled = true
133135
state.config = vim.tbl_deep_extend('force', default_config, opts or {})
136+
state.enabled = state.config.start_enabled
134137
state.markdown_query = vim.treesitter.query.parse('markdown', state.config.markdown_query)
135138
state.inline_query = vim.treesitter.query.parse('markdown_inline', state.config.inline_query)
136139

@@ -169,3 +172,4 @@ M.toggle = function()
169172
end
170173

171174
return M
175+

lua/render-markdown/state.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
---@field public checked string
3030

3131
---@class Config
32+
---@field public start_enabled boolean
3233
---@field public markdown_query string
3334
---@field public inline_query string
3435
---@field public log_level 'debug'|'error'

0 commit comments

Comments
 (0)