Skip to content

Commit

Permalink
(all) Update help to highlight code inside lists with tree-sitter on.
Browse files Browse the repository at this point in the history
  • Loading branch information
echasnovski committed Jan 29, 2024
1 parent 3c98c6b commit 5ceb6a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
21 changes: 10 additions & 11 deletions doc/mini-surround.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,17 @@ Specification for input surrounding has a structure of composed pattern
arguments and should return one of:
- Composed pattern. Useful for implementing user input. Example of
simplified variant of input surrounding for function call with
name taken from user prompt:
>
name taken from user prompt: >
function()
local left_edge = vim.pesc(vim.fn.input('Function name: '))
return { string.format('%s+%%b()', left_edge), '^.-%(().*()%)$' }
end
<
- Single region pair (see |MiniSurround-glossary|). Useful to allow
full control over surrounding. Will be taken as is. Example of
returning first and last lines of a buffer:
>
returning first and last lines of a buffer: >
function()
local n_lines = vim.fn.line('$')
return {
Expand All @@ -315,8 +315,8 @@ Specification for input surrounding has a structure of composed pattern
best region pair will be picked in the same manner as with composed
pattern (respecting options `n_lines`, `search_method`, etc.) using
output region (from start of left region to end of right region).
Example using edges of "best" line with display width more than 80:
>
Example using edges of "best" line with display width more than 80: >
function()
local make_line_region_pair = function(n)
local left = { line = n, col = 1 }
Expand All @@ -343,8 +343,8 @@ Specification for input surrounding has a structure of composed pattern
!IMPORTANT NOTE!: it means that output's `from` shouldn't be strictly
to the left of `init` (it will lead to infinite loop). Not allowed as
last item (as it should be pattern with captures).
Example of matching only balanced parenthesis with big enough width:
>
Example of matching only balanced parenthesis with big enough width: >
{
'%b()',
function(s, init)
Expand All @@ -353,7 +353,7 @@ Specification for input surrounding has a structure of composed pattern
end,
'^.().*().$'
}
>
<
More examples:
- See |MiniSurround.gen_spec| for function wrappers to create commonly used
surrounding specifications.
Expand Down Expand Up @@ -769,8 +769,7 @@ Example configuration for function definition textobject with
f = ts_input({ outer = '@call.outer', inner = '@call.inner' }),
}
})
>
<
Notes:
- By default query is done using 'nvim-treesitter' plugin if it is present
(falls back to builtin methods otherwise). This allows for a more
Expand Down
21 changes: 10 additions & 11 deletions lua/mini/surround.lua
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@
--- arguments and should return one of:
--- - Composed pattern. Useful for implementing user input. Example of
--- simplified variant of input surrounding for function call with
--- name taken from user prompt:
--- >
--- name taken from user prompt: >
---
--- function()
--- local left_edge = vim.pesc(vim.fn.input('Function name: '))
--- return { string.format('%s+%%b()', left_edge), '^.-%(().*()%)$' }
--- end
--- <
--- - Single region pair (see |MiniSurround-glossary|). Useful to allow
--- full control over surrounding. Will be taken as is. Example of
--- returning first and last lines of a buffer:
--- >
--- returning first and last lines of a buffer: >
---
--- function()
--- local n_lines = vim.fn.line('$')
--- return {
Expand All @@ -311,8 +311,8 @@
--- best region pair will be picked in the same manner as with composed
--- pattern (respecting options `n_lines`, `search_method`, etc.) using
--- output region (from start of left region to end of right region).
--- Example using edges of "best" line with display width more than 80:
--- >
--- Example using edges of "best" line with display width more than 80: >
---
--- function()
--- local make_line_region_pair = function(n)
--- local left = { line = n, col = 1 }
Expand All @@ -339,8 +339,8 @@
--- !IMPORTANT NOTE!: it means that output's `from` shouldn't be strictly
--- to the left of `init` (it will lead to infinite loop). Not allowed as
--- last item (as it should be pattern with captures).
--- Example of matching only balanced parenthesis with big enough width:
--- >
--- Example of matching only balanced parenthesis with big enough width: >
---
--- {
--- '%b()',
--- function(s, init)
Expand All @@ -349,7 +349,7 @@
--- end,
--- '^.().*().$'
--- }
--- >
--- <
--- More examples:
--- - See |MiniSurround.gen_spec| for function wrappers to create commonly used
--- surrounding specifications.
Expand Down Expand Up @@ -947,8 +947,7 @@ MiniSurround.gen_spec = { input = {}, output = {} }
--- f = ts_input({ outer = '@call.outer', inner = '@call.inner' }),
--- }
--- })
--- >
---
--- <
--- Notes:
--- - By default query is done using 'nvim-treesitter' plugin if it is present
--- (falls back to builtin methods otherwise). This allows for a more
Expand Down

0 comments on commit 5ceb6a1

Please sign in to comment.