From dd292472b9a67cbd04d4489c2f7c854fb6804f76 Mon Sep 17 00:00:00 2001 From: Arnaud Baes Date: Thu, 14 Mar 2024 11:27:45 +0100 Subject: [PATCH] [IMP] owl-vision: Better snippets - Adds a basic XML owl template - Make use of `$TM_FILENAME_BASE` and `$RELATIVE_FILEPATH` and attempt to predict the component and template names. See: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables --- tools/owl-vision/snippets/component.json | 33 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/owl-vision/snippets/component.json b/tools/owl-vision/snippets/component.json index cbbe14406..2ee7e5c2c 100644 --- a/tools/owl-vision/snippets/component.json +++ b/tools/owl-vision/snippets/component.json @@ -1,18 +1,43 @@ { - "Basic owl component": { + "Basic OWL Component": { "prefix": "owlcomponent", + "scope": "javascript,typescript", "body": [ - "export class ${1:component-name} extends Component {", - " static template = \"${2:template-name}\";", + "import { Component } from \"@odoo/owl\";", + "", + "class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} extends ${2:Component} {", + "", + " static template = \"${3:${RELATIVE_FILEPATH/(.*[\\|\\/])??([a-zA-Z_]+)([\\|\\/]static[\\|\\/].*)/${2}/g}}.${4:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}\";", " static components = {};", " static props = {};", "", " setup() {", - "", + " ${5:super.setup();}", " }", + "", + " ${6:// Do Something}", "}", "" + ], "description": "The starting base for an owl component" + }, + + "Basic OWL Template": { + "prefix": "owltemplate", + "scope": "xml", + "body": [ + "", + "", + "", + "", + " ", + " ${3:

Hello World

}", + "
", + "", + "
", + "" + ], + "description": "Generate a basic OWL template XML file" } }