LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

`pascalcase` transformation does not work

Open sidlatau opened this issue 3 years ago • 4 comments

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.

sidlatau avatar Sep 02 '22 11:09 sidlatau

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).

leiserfg avatar Sep 02 '22 11:09 leiserfg

These are Visual Studio Code snippets. Here is the full grammar: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar

sidlatau avatar Sep 02 '22 11:09 sidlatau

So Vscode implements transformations out of their own specification :man_facepalming: , Microsoft :tm:

leiserfg avatar Sep 02 '22 12:09 leiserfg

We can (should I think, compatibility and all that) just replicate these

L3MON4D3 avatar Sep 02 '22 12:09 L3MON4D3

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 =(

Antoniozinchenko avatar Jan 19 '23 23:01 Antoniozinchenko

Hi! Yeah, pascalcase has not yet been implemented. If you want to, you can open a PR to add it :D

L3MON4D3 avatar Jan 20 '23 08:01 L3MON4D3

To be clear @Antoniozinchenko LuaSnip does not use vscode engine at all. We just support the snippet format.

leiserfg avatar Jan 20 '23 12:01 leiserfg

Okay, I had some time and implemented it, #735. Please try if it works correctly, it should be the same as vscode.

L3MON4D3 avatar Jan 20 '23 12:01 L3MON4D3

Thanks, @L3MON4D3 for the implementation, tested it with a snippet provided this issue, and everything works as expected! 🎉

sidlatau avatar Jan 22 '23 17:01 sidlatau

Beautiful :)

L3MON4D3 avatar Jan 22 '23 17:01 L3MON4D3