Skip to content

Commit b0fe71f

Browse files
fix: remove ability to configure treesitter queries
## Details Issue: #192 Removes `markdown_query`, `markdown_quote_query`, & `inline_query` from user configuration. Instead these are now hard coded. While having these accessible had some convenience it's really more of a foot gun than anything else and users should really not modify it. For development in some instances it was nice to have, but modifying the hard coded value is not much more difficult. Anyone wanting to modify it probably wants to change functionality in which case they are modifying the code already anyway.
1 parent 35c37ca commit b0fe71f

File tree

9 files changed

+66
-182
lines changed

9 files changed

+66
-182
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ body:
4343
attributes:
4444
label: Healthcheck output
4545
description: Output of :checkhealth render-markdown
46+
render: text
4647
validations:
4748
required: true
4849
- type: textarea
4950
attributes:
5051
label: Plugin configuration
5152
description: Your configuration for this plugin.
53+
render: lua
5254
validations:
5355
required: true
5456
- type: textarea
5557
attributes:
5658
label: Plugin error log
5759
description: Error log (:RenderMarkdown log) if empty put N/A.
60+
render: text
5861
validations:
5962
required: true
6063
- type: checkboxes

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Features
66

77
- chechbox scope highlight [cb90caf](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/cb90caf64951b5b7515def7783b32e73883e374c)
8+
- plus / minus metadata dash rendering [35c37ca](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/35c37ca9f7955f9fa57eaee1c16edb3c80c40462)
89

910
### Bug Fixes
1011

README.md

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -139,63 +139,6 @@ require('render-markdown').setup({
139139
-- lazy: will attempt to stay up to date with LazyVim configuration
140140
-- none: does nothing
141141
preset = 'none',
142-
-- Capture groups that get pulled from markdown
143-
markdown_query = [[
144-
(section) @section
145-
146-
(atx_heading [
147-
(atx_h1_marker)
148-
(atx_h2_marker)
149-
(atx_h3_marker)
150-
(atx_h4_marker)
151-
(atx_h5_marker)
152-
(atx_h6_marker)
153-
] @heading)
154-
(setext_heading) @heading
155-
156-
[
157-
(thematic_break)
158-
(minus_metadata)
159-
(plus_metadata)
160-
] @dash
161-
162-
(fenced_code_block) @code
163-
164-
[
165-
(list_marker_plus)
166-
(list_marker_minus)
167-
(list_marker_star)
168-
] @list_marker
169-
170-
[
171-
(task_list_marker_unchecked)
172-
(task_list_marker_checked)
173-
] @checkbox
174-
175-
(block_quote) @quote
176-
177-
(pipe_table) @table
178-
]],
179-
-- Capture groups that get pulled from quote nodes
180-
markdown_quote_query = [[
181-
[
182-
(block_quote_marker)
183-
(block_continuation)
184-
] @quote_marker
185-
]],
186-
-- Capture groups that get pulled from inline markdown
187-
inline_query = [[
188-
(code_span) @code
189-
190-
(shortcut_link) @shortcut
191-
192-
[
193-
(image)
194-
(email_autolink)
195-
(inline_link)
196-
(full_reference_link)
197-
] @link
198-
]],
199142
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
200143
-- Only intended to be used for plugin development / debugging
201144
log_level = 'error',

doc/render-markdown.txt

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -187,63 +187,6 @@ Default Configuration ~
187187
-- lazy: will attempt to stay up to date with LazyVim configuration
188188
-- none: does nothing
189189
preset = 'none',
190-
-- Capture groups that get pulled from markdown
191-
markdown_query = [[
192-
(section) @section
193-
194-
(atx_heading [
195-
(atx_h1_marker)
196-
(atx_h2_marker)
197-
(atx_h3_marker)
198-
(atx_h4_marker)
199-
(atx_h5_marker)
200-
(atx_h6_marker)
201-
] @heading)
202-
(setext_heading) @heading
203-
204-
[
205-
(thematic_break)
206-
(minus_metadata)
207-
(plus_metadata)
208-
] @dash
209-
210-
(fenced_code_block) @code
211-
212-
[
213-
(list_marker_plus)
214-
(list_marker_minus)
215-
(list_marker_star)
216-
] @list_marker
217-
218-
[
219-
(task_list_marker_unchecked)
220-
(task_list_marker_checked)
221-
] @checkbox
222-
223-
(block_quote) @quote
224-
225-
(pipe_table) @table
226-
]],
227-
-- Capture groups that get pulled from quote nodes
228-
markdown_quote_query = [[
229-
[
230-
(block_quote_marker)
231-
(block_continuation)
232-
] @quote_marker
233-
]],
234-
-- Capture groups that get pulled from inline markdown
235-
inline_query = [[
236-
(code_span) @code
237-
238-
(shortcut_link) @shortcut
239-
240-
[
241-
(image)
242-
(email_autolink)
243-
(inline_link)
244-
(full_reference_link)
245-
] @link
246-
]],
247190
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
248191
-- Only intended to be used for plugin development / debugging
249192
log_level = 'error',

lua/render-markdown/core/treesitter.lua

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,64 @@
11
---@class render.md.TreeSitter
22
local M = {}
33

4+
---@class render.md.treesitter.Queries
5+
M.queries = {
6+
markdown = [[
7+
(section) @section
8+
9+
(atx_heading [
10+
(atx_h1_marker)
11+
(atx_h2_marker)
12+
(atx_h3_marker)
13+
(atx_h4_marker)
14+
(atx_h5_marker)
15+
(atx_h6_marker)
16+
] @heading)
17+
(setext_heading) @heading
18+
19+
[
20+
(thematic_break)
21+
(minus_metadata)
22+
(plus_metadata)
23+
] @dash
24+
25+
(fenced_code_block) @code
26+
27+
[
28+
(list_marker_plus)
29+
(list_marker_minus)
30+
(list_marker_star)
31+
] @list_marker
32+
33+
[
34+
(task_list_marker_unchecked)
35+
(task_list_marker_checked)
36+
] @checkbox
37+
38+
(block_quote) @quote
39+
40+
(pipe_table) @table
41+
]],
42+
markdown_quote = [[
43+
[
44+
(block_quote_marker)
45+
(block_continuation)
46+
] @quote_marker
47+
]],
48+
inline = [[
49+
(code_span) @code
50+
51+
(shortcut_link) @shortcut
52+
53+
[
54+
(image)
55+
(email_autolink)
56+
(inline_link)
57+
(full_reference_link)
58+
] @link
59+
]],
60+
}
61+
462
---@param language string
563
---@param injection render.md.Injection?
664
function M.inject(language, injection)

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local state = require('render-markdown.state')
44
local M = {}
55

66
---@private
7-
M.version = '7.2.6'
7+
M.version = '7.2.7'
88

99
function M.check()
1010
M.start('version')

lua/render-markdown/init.lua

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ local M = {}
187187

188188
---@class (exact) render.md.UserConfig: render.md.UserBufferConfig
189189
---@field public preset? render.md.config.Preset
190-
---@field public markdown_query? string
191-
---@field public markdown_quote_query? string
192-
---@field public inline_query? string
193190
---@field public log_level? render.md.config.LogLevel
194191
---@field public log_runtime? boolean
195192
---@field public file_types? string[]
@@ -214,63 +211,6 @@ M.default_config = {
214211
-- lazy: will attempt to stay up to date with LazyVim configuration
215212
-- none: does nothing
216213
preset = 'none',
217-
-- Capture groups that get pulled from markdown
218-
markdown_query = [[
219-
(section) @section
220-
221-
(atx_heading [
222-
(atx_h1_marker)
223-
(atx_h2_marker)
224-
(atx_h3_marker)
225-
(atx_h4_marker)
226-
(atx_h5_marker)
227-
(atx_h6_marker)
228-
] @heading)
229-
(setext_heading) @heading
230-
231-
[
232-
(thematic_break)
233-
(minus_metadata)
234-
(plus_metadata)
235-
] @dash
236-
237-
(fenced_code_block) @code
238-
239-
[
240-
(list_marker_plus)
241-
(list_marker_minus)
242-
(list_marker_star)
243-
] @list_marker
244-
245-
[
246-
(task_list_marker_unchecked)
247-
(task_list_marker_checked)
248-
] @checkbox
249-
250-
(block_quote) @quote
251-
252-
(pipe_table) @table
253-
]],
254-
-- Capture groups that get pulled from quote nodes
255-
markdown_quote_query = [[
256-
[
257-
(block_quote_marker)
258-
(block_continuation)
259-
] @quote_marker
260-
]],
261-
-- Capture groups that get pulled from inline markdown
262-
inline_query = [[
263-
(code_span) @code
264-
265-
(shortcut_link) @shortcut
266-
267-
[
268-
(image)
269-
(email_autolink)
270-
(inline_link)
271-
(full_reference_link)
272-
] @link
273-
]],
274214
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
275215
-- Only intended to be used for plugin development / debugging
276216
log_level = 'error',

lua/render-markdown/state.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ function M.setup(default_config, user_config)
4848
M.latex = config.latex
4949
M.custom_handlers = config.custom_handlers
5050
vim.schedule(function()
51-
M.markdown_query = vim.treesitter.query.parse('markdown', config.markdown_query)
52-
M.markdown_quote_query = vim.treesitter.query.parse('markdown', config.markdown_quote_query)
53-
M.inline_query = vim.treesitter.query.parse('markdown_inline', config.inline_query)
51+
M.markdown_query = vim.treesitter.query.parse('markdown', treesitter.queries.markdown)
52+
M.markdown_quote_query = vim.treesitter.query.parse('markdown', treesitter.queries.markdown_quote)
53+
M.inline_query = vim.treesitter.query.parse('markdown_inline', treesitter.queries.inline)
5454
end)
5555
log.setup(config.log_level)
5656
for _, language in ipairs(M.file_types) do
@@ -253,7 +253,6 @@ function M.validate()
253253
:type({ 'quote', 'pipe_table', 'callout', 'link', 'sign', 'indent', 'win_options' }, 'table')
254254
:list('render_modes', 'string', 'boolean')
255255
:type('log_runtime', 'boolean')
256-
:type({ 'markdown_query', 'markdown_quote_query', 'inline_query' }, 'string')
257256
:type({ 'injections', 'latex', 'overrides', 'custom_handlers' }, 'table')
258257
:list('file_types', 'string')
259258
:one_of('preset', { 'none', 'lazy', 'obsidian' })

lua/render-markdown/types.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@
157157

158158
---@class (exact) render.md.Config: render.md.BufferConfig
159159
---@field public preset render.md.config.Preset
160-
---@field public markdown_query string
161-
---@field public markdown_quote_query string
162-
---@field public inline_query string
163160
---@field public log_level render.md.config.LogLevel
164161
---@field public log_runtime boolean
165162
---@field public file_types string[]

0 commit comments

Comments
 (0)