nvim-config

Log | Files | Refs | Submodules | README

commit a500135074559e2b1e821f6d89c3c5325eaed047
parent 003e337468efb613b94659ca2bc782109e9d4419
Author: Thomas Vigouroux <me@vigoux.eu>
Date:   Fri,  1 Mar 2024 13:48:20 +0100

feat(latex): add color surround

Diffstat:
Mafter/ftplugin/tex.lua | 19+++++++++----------
Mafter/queries/latex/textobjects.scm | 5+++++
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua @@ -141,20 +141,19 @@ vim.b.minisurround_config = { return { left = string.format("\\begin{%s}\n", name), right = string.format("\n\\end{%s}", name)} end + }, + c = { + input = surround.gen_spec.input.treesitter { outer = "@color.outer", inner = "@color.inner" }, + output = function() + local name = surround.user_input("Color name") + if not name then return end + + return { left = string.format("\\textcolor{%s}{", name), right = "}"} + end } } } --- -- Wrap the selection in a call --- vis_input_change('<LocalLeader>f', 'Function name: ', preffix_suffix_change(function(input) --- return string.format('\\%s{', input), '}' --- end)) --- --- -- Wrap the selection in an inline environment --- vis_input_change('<LocalLeader>ie', 'Inline env name: ', preffix_suffix_change(function(input) --- return '{\\' .. input, '}' --- end)) --- -- -- Wrap the selection in a color block -- vis_input_change('<LocalLeader>c', 'Color name: ', preffix_suffix_change(function(input) -- return string.format('{\\color{%s}', input), '}' diff --git a/after/queries/latex/textobjects.scm b/after/queries/latex/textobjects.scm @@ -20,3 +20,8 @@ (#make-range! "item.inner" @_ibegin @item.outer)) (generic_command arg: (curly_group (_) @call.inner)) @call.outer + +;; Colored text +((_ (color_reference) @_obegin) + . (curly_group (_) @color.inner) @_oend + (#make-range! "color.outer" @_obegin @_oend))