Surround function call in latex #2240
-
Contributing guidelines
Module(s)mini.surround QuestionWhen editing So how would I use mini.surround for this? Maybe a general solution would be that if I provide |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Actually, one way to handle this would be to add a custom surrounding for a "command", like this: require('mini.surround').setup({
custom_surroundings = {
c = {
input = function() return vim.fn.input('Command name: ') end,
output = function()
local name = vim.fn.input('Command name: ')
return { left = '\\' .. name .. '{', right = '}' }
end,
},
},
})Not sure whether I would prefer the more general idea from above, i.e., when the function name contains a bracket, like |
Beta Was this translation helpful? Give feedback.
-
|
'mini.surround' allows buffer-local configuration by setting a My suggestion would be to put the following code (which is an adjusted version of builtin if _G.MiniSurround ~= nil then
vim.b.minisurround_config = {
custom_surroundings = {
f = {
input = { '\\%f[%w_%.][%w_%.]+%b{}', '^.-{().*()}$' },
output = function()
local fun_name = MiniSurround.user_input('Function name')
if fun_name == nil then return nil end
return { left = '\\' .. fun_name .. '{', right = '}' }
end,
},
},
}
end |
Beta Was this translation helpful? Give feedback.
'mini.surround' allows buffer-local configuration by setting a
vim.b.minisurround_configvariable. Its common usage is to customize surroundings per filetype.My suggestion would be to put the following code (which is an adjusted version of builtin
fsurrounding) in the '~/.config/nvim/after/ftplugin/plaintex.lua' (and/or other LaTeX adjacent filetype):