This plugin is inspired by the VS Code plugin: Template String Converted
As soon as this plugin detects you're trying to use template strings (adding ${}) the quotes will be changed to backticks
Before Input After
----------------------------------------
'foo ${|' } `foo ${}|`
'bar $|}' { `bar ${|}`
'idk |{}' $ `idk $|{}`
----------------------------------------
Opposite function, remove backticks when there are no template strings
- Neovim 0.7.0 or later
- nvim-treesitter plugin
- Javascript / Typescript
- JSX
- Vue
- Svelte
- Python
- C#
Example with the default config. If you prefer, you could call the setup function with partial or no config, and the default will be taken
require('template-string').setup({
filetypes = { 'html', 'typescript', 'javascript', 'typescriptreact', 'javascriptreact', 'vue', 'svelte', 'python', 'cs' }, -- filetypes where the plugin is active
jsx_brackets = true, -- must add brackets to JSX attributes
remove_template_string = false, -- remove backticks when there are no template strings
restore_quotes = {
-- quotes used when "remove_template_string" option is enabled
normal = [[']],
jsx = [["]],
},
})
Licensed under the MIT license.