LuaSnip
LuaSnip copied to clipboard
`pascalcase` transformation does not work
As mentioned in https://github.com/L3MON4D3/LuaSnip/issues/569 I am creating a separate issue for not working pascalcase transformation.
Snippet:
"Built Value Type File": {
"prefix": "bvtf",
"body": [
"import 'package:built_collection/built_collection.dart';",
"import 'package:built_value/built_value.dart';",
"",
"part '$TM_FILENAME_BASE.g.dart';",
"",
"abstract class ${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/} implements Built<${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}, ${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}Builder> {",
" ${2}",
"",
" ${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}._();",
" factory ${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}([void Function(${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}Builder) updates]) = _$${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/};",
"}"
],
"description": "Built Value Type File whose name corresponds to the file name"
},
Output:
import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
part 'order_notes_state.g.dart';
abstract class order_notes_state implements Built<order_notes_state, order_notes_stateBuilder> {
order_notes_state._();
factory order_notes_state([void Function(order_notes_stateBuilder) updates]) = _$order_notes_state;
}
pascalcase transformation seem to be still ignored.
Where is that transformation name coming from? If it's a Textmate thing, maybe we are missing more and will be nice to have all of them (or at many as we can).
These are Visual Studio Code snippets. Here is the full grammar: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar
So Vscode implements transformations out of their own specification :man_facepalming: , Microsoft :tm:
We can (should I think, compatibility and all that) just replicate these
Hey I faced the same issue (with dart snippets as well btw) Looks like luasnip uses old version of vscode engine (pascalcase supports from vscode 1.58+) if you try your snippet inside real vscode it works perfectly. For example LunarVim docs setup suggest 1.11.0 which is definitely too low =(
Hi! Yeah, pascalcase has not yet been implemented. If you want to, you can open a PR to add it :D
To be clear @Antoniozinchenko LuaSnip does not use vscode engine at all. We just support the snippet format.
Okay, I had some time and implemented it, #735. Please try if it works correctly, it should be the same as vscode.
Thanks, @L3MON4D3 for the implementation, tested it with a snippet provided this issue, and everything works as expected! 🎉
Beautiful :)