Created
September 6, 2023 12:35
-
-
Save titouancreach/7a30acb1e2f43955d8e6ef92e72beba1 to your computer and use it in GitHub Desktop.
interpolated string C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"InsertCharPre", | |
{ | |
pattern = { "*.cs" }, | |
--- @param opts AutoCmdCallbackOpts | |
--- @return nil | |
callback = function(opts) | |
-- Only run if f-string escape character is typed | |
if vim.v.char ~= "{" then return end | |
-- Get node and return early if not in a string | |
local node = vim.treesitter.get_node() | |
if not node then return end | |
if node:type() ~= "string_literal" then node = node:parent() end | |
if not node or node:type() ~= "string_literal" then return end | |
local row, col, _, _ = vim.treesitter.get_node_range(node) | |
vim.api.nvim_input("<Esc>m'" .. row + 1 .. "gg" .. col + 1 .. "|i$<Esc>`'la") | |
end | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment