initial
This commit is contained in:
commit
8cc59af68e
37 changed files with 72435 additions and 0 deletions
13673
lua/snippets/bootstrap.json
Normal file
13673
lua/snippets/bootstrap.json
Normal file
File diff suppressed because it is too large
Load diff
512
lua/snippets/django-python.json
Executable file
512
lua/snippets/django-python.json
Executable file
|
|
@ -0,0 +1,512 @@
|
|||
{
|
||||
"mauto": {
|
||||
"prefix": "mauto",
|
||||
"description": "AutoField (mauto) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.AutoField()"
|
||||
]
|
||||
},
|
||||
"mbigint": {
|
||||
"prefix": "mbigint",
|
||||
"description": "BigIntegerField (mbigint) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.BigIntegerField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mbool": {
|
||||
"prefix": "mbool",
|
||||
"description": "BooleanField (mbool) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.BooleanField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mchar": {
|
||||
"prefix": "mchar",
|
||||
"description": "CharField (mchar) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.CharField(${DESCRICAO}, max_length=50)"
|
||||
]
|
||||
},
|
||||
"mcoseint": {
|
||||
"prefix": "mcoseint",
|
||||
"description": "CommaSeparatedIntegerField (mcoseint) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.CommaSeparatedIntegerField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mdate": {
|
||||
"prefix": "mdate",
|
||||
"description": "DateField (mdate) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.DateField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mdatetime": {
|
||||
"prefix": "mdatetime",
|
||||
"description": "DateTimeField (mdatetime) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.DateTimeField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mdecimal": {
|
||||
"prefix": "mdecimal",
|
||||
"description": "DecimalField (mdecimal) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.DecimalField(${DESCRICAO}, max_digits=5, decimal_places=2)"
|
||||
]
|
||||
},
|
||||
"mduration": {
|
||||
"prefix": "mduration",
|
||||
"description": "DurationField (mduration) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.DurationField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"memail": {
|
||||
"prefix": "memail",
|
||||
"description": "EmailField (memail) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.EmailField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mfile": {
|
||||
"prefix": "mfile",
|
||||
"description": "FileField (mfile) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.FileField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mfilepath": {
|
||||
"prefix": "mfilepath",
|
||||
"description": "FilePathField (mfilepath) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.FilePathField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mfloat": {
|
||||
"prefix": "mfloat",
|
||||
"description": " (mfloat) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.FloatField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mimg": {
|
||||
"prefix": "mimg",
|
||||
"description": "ImageField (mimg) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.ImageField(${DESCRICAO}, upload_to='${SUBPASTA}')"
|
||||
]
|
||||
},
|
||||
"mint": {
|
||||
"prefix": "mint",
|
||||
"description": "IntegerField (mint) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.IntegerField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mip": {
|
||||
"prefix": "mip",
|
||||
"description": "IPAddressField (mip) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.IPAddressField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mnullbool": {
|
||||
"prefix": "mnullbool",
|
||||
"description": "NullBooleanField (mnullbool) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.NullBooleanField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mphone": {
|
||||
"prefix": "mphone",
|
||||
"description": "PhoneNumberField (mphone) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.PhoneNumberField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mposint": {
|
||||
"prefix": "mposint",
|
||||
"description": "PositiveIntegerField (mposint) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.PositiveIntegerField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mpossmallint": {
|
||||
"prefix": "mpossmallint",
|
||||
"description": "PositiveSmallIntegerField (mpossmallint) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.PositiveSmallIntegerField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mslug": {
|
||||
"prefix": "mslug",
|
||||
"description": "SlugField (mslug) model Field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.SlugField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"msmallint": {
|
||||
"prefix": "msmallint",
|
||||
"description": "SmallIntegerField (msmallint) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.SmallIntegerField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mtext": {
|
||||
"prefix": "mtext",
|
||||
"description": "TextField (mtext) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.TextField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mtime": {
|
||||
"prefix": "mtime",
|
||||
"description": "TimeField (mtime) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.TimeField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"murl": {
|
||||
"prefix": "murl",
|
||||
"description": "URLField (murl) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.URLField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"musstate": {
|
||||
"prefix": "musstate",
|
||||
"description": "USStateField (musstate) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.USStateField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"mxml": {
|
||||
"prefix": "mxml",
|
||||
"description": "XMLField (mxml) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.XMLField(${DESCRICAO})"
|
||||
]
|
||||
},
|
||||
"fk": {
|
||||
"prefix": "mfo",
|
||||
"description": "ForeignKey (fk) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.ForeignKey(${FKNAME}, on_delete=models.${PROTECT}, verbose_name='${DESCRICAO}', related_name='${RELACAO}')"
|
||||
]
|
||||
},
|
||||
"m2m": {
|
||||
"prefix": "m2m",
|
||||
"description": "ManyToManyField (m2m) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.ManyToManyField(${FKNAME}, verbose_name='${DESCRICAO}', related_name='${RELACAO}')"
|
||||
]
|
||||
},
|
||||
"o2o": {
|
||||
"prefix": "o2o",
|
||||
"description": "OneToOneField (o2o) model field",
|
||||
"body": [
|
||||
"${FIELDNAME} = models.OneToOneField(${DESCRICAO}, on_delete=models.${PROTECT})"
|
||||
]
|
||||
},
|
||||
"mserializer": {
|
||||
"prefix": "mserializer",
|
||||
"description": "ModelSerializer (mserializer) Rest Framework",
|
||||
"body": [
|
||||
"class ${ModelName}Serializer(serializers.ModelSerializer):",
|
||||
"",
|
||||
"\tclass Meta:",
|
||||
"\t\tmodel = ${ModelName}",
|
||||
"\t\tfields = '__all__'"
|
||||
]
|
||||
},
|
||||
"mviewset": {
|
||||
"prefix": "mviewset",
|
||||
"description": "ModelViewSet (mviewset) Rest Framework",
|
||||
"body": [
|
||||
"class ${ModelName}ViewSet(viewsets.ModelViewSet):",
|
||||
"",
|
||||
"\tqueryset = ${ModelName}.objects.all()",
|
||||
"\tserializer_class = ${ModelName}Serializer"
|
||||
]
|
||||
},
|
||||
"ronlymviewset": {
|
||||
"prefix": "ronlymviewset",
|
||||
"description": "ReadOnlyModelViewSet (ronlymviewset) Rest Framework",
|
||||
"body": [
|
||||
"class ${ModelName}ViewSet(viewsets.ReadOnlyModelViewSet):",
|
||||
"",
|
||||
"\tqueryset = ${ModelName}.objects.all()",
|
||||
"\tserializer_class = ${ModelName}Serializer"
|
||||
]
|
||||
},
|
||||
"Model": {
|
||||
"prefix": "mmodel",
|
||||
"description": "models.Model (Model) Class Model of Django",
|
||||
"body": [
|
||||
"class ${ModelName}(models.Model):",
|
||||
"",
|
||||
"\tdef __str__(self):",
|
||||
"\t\tpass",
|
||||
"",
|
||||
"\tclass Meta:",
|
||||
"\t\tdb_table = ''",
|
||||
"\t\tmanaged = True",
|
||||
"\t\tverbose_name = '${ModelName}'",
|
||||
"\t\tverbose_name_plural = '${ModelName}s'"
|
||||
]
|
||||
},
|
||||
"Meta": {
|
||||
"prefix": "mmeta",
|
||||
"description": "Meta (Meta) Meta Class of Model",
|
||||
"body": [
|
||||
"class Meta:",
|
||||
"\tdb_table = ''",
|
||||
"\tmanaged = True",
|
||||
"\tverbose_name = '${ModelName}'",
|
||||
"\tverbose_name_plural = '${ModelName}s'"
|
||||
]
|
||||
},
|
||||
"adminRegister": {
|
||||
"prefix": "adr",
|
||||
"description": "Create admin site resgister for app",
|
||||
"body": [
|
||||
"from .models import ${AppName}",
|
||||
"",
|
||||
"admin.site.register(${AppName})"
|
||||
]
|
||||
},
|
||||
"ondelete": {
|
||||
"prefix": "ond",
|
||||
"description": "on_delete option",
|
||||
"body": [
|
||||
"on_delete=models.${PROTECT}"
|
||||
]
|
||||
},
|
||||
"null&blank": {
|
||||
"prefix": "nbl",
|
||||
"description": "null=True, blank=True option",
|
||||
"body": [
|
||||
"null=True, blank=True"
|
||||
]
|
||||
},
|
||||
"Django CRUD Views": {
|
||||
"prefix": "dcv",
|
||||
"description": "Create CRUD views",
|
||||
"body": [
|
||||
"from django.views.generic import ListView, CreateView, UpdateView, DeleteView",
|
||||
"from django.contrib.auth.mixins import LoginRequiredMixin",
|
||||
"from django.urls import reverse_lazy",
|
||||
"from .models import ${ClasseObjeto}",
|
||||
"",
|
||||
"class ${ClasseObjeto}List(LoginRequiredMixin, ListView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"",
|
||||
"class ${ClasseObjeto}Create(LoginRequiredMixin, CreateView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"\tform_class = None",
|
||||
"\tsuccess_url = reverse_lazy('${ClasseObjeto}_list')",
|
||||
"",
|
||||
"class ${ClasseObjeto}Update(LoginRequiredMixin, UpdateView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"\tform_class = None",
|
||||
"\tsuccess_url = reverse_lazy('${ClasseObjeto}_list')",
|
||||
"",
|
||||
"class ${ClasseObjeto}Delete(LoginRequiredMixin, DeleteView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"\tsuccess_url = reverse_lazy('${ClasseObjeto}_list')"
|
||||
]
|
||||
},
|
||||
"Django TemplateView": {
|
||||
"prefix": "dtv",
|
||||
"description": "Create a TemplateView",
|
||||
"body": [
|
||||
"from django.views.generic import TemplateView",
|
||||
"from django.contrib.auth.mixins import LoginRequiredMixin",
|
||||
"",
|
||||
"class ${NomeClasse}(LoginRequiredMixin, TemplateView):",
|
||||
"\ttemplate_name = \"${arquivo}.html\"",
|
||||
"",
|
||||
"\tdef get_context_data(self, **kwargs):",
|
||||
"\t\tcontext = super().get_context_data(**kwargs)",
|
||||
"\t\tcontext['${var}'] = \"\"",
|
||||
"\t\treturn context"
|
||||
]
|
||||
},
|
||||
"Django ListView": {
|
||||
"prefix": "dclv",
|
||||
"description": "Create a ListView",
|
||||
"body": [
|
||||
"class ${ClasseObjeto}Create(LoginRequiredMixin, ListView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"",
|
||||
"\tdef get_context_data(self, **kwargs):",
|
||||
"\t\tcontext = super().get_context_data(**kwargs)",
|
||||
"\t\tcontext['minha_variavel'] = 'Pode ser qualquer coisa'",
|
||||
"\t\treturn context"
|
||||
]
|
||||
},
|
||||
"Django CreateView": {
|
||||
"prefix": "dccv",
|
||||
"description": "Create a CreateView",
|
||||
"body": [
|
||||
"class ${ClasseObjeto}Create(LoginRequiredMixin, CreateView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"\tform_class = None",
|
||||
"\tsuccess_url = reverse_lazy('${ClasseObjeto}_list')"
|
||||
]
|
||||
},
|
||||
"Django UpdateView": {
|
||||
"prefix": "dcuv",
|
||||
"description": "Create a UpdateView",
|
||||
"body": [
|
||||
"class ${ClasseObjeto}Update(LoginRequiredMixin, UpdateView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"\tform_class = None",
|
||||
"\tsuccess_url = reverse_lazy('${ClasseObjeto}_list')"
|
||||
]
|
||||
},
|
||||
"Django DeleteView": {
|
||||
"prefix": "dcdv",
|
||||
"description": "Create a DeleteView",
|
||||
"body": [
|
||||
"class ${ClasseObjeto}Delete(LoginRequiredMixin, DeleteView):",
|
||||
"\tmodel = ${ClasseObjeto}",
|
||||
"\tsuccess_url = reverse_lazy('${ClasseObjeto}_list')"
|
||||
]
|
||||
},
|
||||
"Django Settings Internationalization and Static": {
|
||||
"prefix": "dss",
|
||||
"description": "Create Internationalization and staticfolders settings",
|
||||
"body": [
|
||||
"# Internationalization",
|
||||
"# https://docs.djangoproject.com/en/2.1/topics/i18n/",
|
||||
"",
|
||||
"LANGUAGE_CODE = 'pt-br'",
|
||||
"",
|
||||
"TIME_ZONE = 'America/Sao_Paulo'",
|
||||
"",
|
||||
"USE_I18N = True",
|
||||
"",
|
||||
"USE_L10N = True",
|
||||
"",
|
||||
"USE_TZ = True",
|
||||
"",
|
||||
"",
|
||||
"# Static files (CSS, JavaScript, Images)",
|
||||
"# https://docs.djangoproject.com/en/2.1/howto/static-files/",
|
||||
"",
|
||||
"STATIC_URL = '/static/'",
|
||||
"",
|
||||
"STATICFILES_DIRS = [",
|
||||
"\tos.path.join(BASE_DIR, \"staticfiles\"),",
|
||||
"]",
|
||||
"",
|
||||
"MEDIA_URL = '/media/'",
|
||||
"",
|
||||
"MEDIA_ROOT = os.path.join(BASE_DIR,'media')",
|
||||
"",
|
||||
"STATIC_ROOT = os.path.join(BASE_DIR,\"static/\")",
|
||||
"",
|
||||
"LOGIN_REDIRECT_URL = 'home'",
|
||||
"",
|
||||
"LOGOUT_REDIRECT_URL = 'login'"
|
||||
]
|
||||
},
|
||||
"Django Settings Template": {
|
||||
"prefix": "dst",
|
||||
"description": "Create template settings",
|
||||
"body": [
|
||||
"TEMPLATES = [",
|
||||
"\t{",
|
||||
"\t\t'BACKEND': 'django.template.backends.django.DjangoTemplates',",
|
||||
"\t\t'DIRS': ['templates', os.path.join(BASE_DIR,'templates')],",
|
||||
"\t\t'APP_DIRS': True,",
|
||||
"\t\t'OPTIONS': {",
|
||||
"\t\t\t'context_processors': [",
|
||||
"\t\t\t\t'django.template.context_processors.debug',",
|
||||
"\t\t\t\t'django.template.context_processors.request',",
|
||||
"\t\t\t\t'django.contrib.auth.context_processors.auth',",
|
||||
"\t\t\t\t'django.contrib.messages.context_processors.messages',",
|
||||
"\t\t\t],",
|
||||
"\t\t},",
|
||||
"\t},",
|
||||
"]"
|
||||
]
|
||||
},
|
||||
"Django middleware": {
|
||||
"prefix": "middlweware",
|
||||
"description": "Create a middleware",
|
||||
"body": [
|
||||
"def ${nome}_middleware(get_response):",
|
||||
"\tdef middleware(request):",
|
||||
"\t\tresponse = get_response(request)",
|
||||
"\t\treturn response",
|
||||
"\treturn middleware"
|
||||
]
|
||||
},
|
||||
"Django get_context_data": {
|
||||
"prefix": "dgetc",
|
||||
"description": "Create a get_context_data function",
|
||||
"body": [
|
||||
"def get_context_data(self, **kwargs):",
|
||||
"\tcontext = super().get_context_data(**kwargs)",
|
||||
"\tcontext[\"${variavel}\"] = \"${valor}\"",
|
||||
"\treturn context"
|
||||
]
|
||||
},
|
||||
"Django post": {
|
||||
"prefix": "dpos",
|
||||
"description": "Create a post function",
|
||||
"body": [
|
||||
"def post(self, request, *args, **kwargs):",
|
||||
"\treturn super().post(request, *args, **kwargs)"
|
||||
]
|
||||
},
|
||||
"Django get": {
|
||||
"prefix": "dget",
|
||||
"description": "Create a get function",
|
||||
"body": [
|
||||
"def get(self, request, *args, **kwargs):",
|
||||
"\treturn super().get(request, *args, **kwargs)"
|
||||
]
|
||||
},
|
||||
"Django constraints": {
|
||||
"prefix": "dcons",
|
||||
"description": "Create a constraint for Meta Models",
|
||||
"body": [
|
||||
"constraints = [",
|
||||
"\tmodels.UniqueConstraint(",
|
||||
"\t\tfields=[\"${cons1}\", \"${cons2}\"], name=\"${model}_${cons1}_${cons2}\",",
|
||||
"\t)",
|
||||
"]"
|
||||
]
|
||||
},
|
||||
"Pyhton def __str__": {
|
||||
"prefix": "defs",
|
||||
"description": "Create a __str__ function",
|
||||
"body": [
|
||||
"def __str__(self):",
|
||||
"\treturn self.${NOME}"
|
||||
]
|
||||
},
|
||||
"Python encode": {
|
||||
"prefix": "enc",
|
||||
"description": "coding utf-8",
|
||||
"body": [
|
||||
"# coding=utf-8"
|
||||
]
|
||||
},
|
||||
"Python Try/Except/Finally": {
|
||||
"prefix": "try",
|
||||
"description": "Command try/except/finally",
|
||||
"body": [
|
||||
"try:",
|
||||
"\t${pass}",
|
||||
"except Exception as e:",
|
||||
"\tprint(\"{}\".format(e))",
|
||||
"finally:",
|
||||
"\tpass"
|
||||
]
|
||||
}
|
||||
}
|
||||
231
lua/snippets/django.json
Executable file
231
lua/snippets/django.json
Executable file
|
|
@ -0,0 +1,231 @@
|
|||
{
|
||||
"autoescape": {
|
||||
"prefix": "autoescape",
|
||||
"description": "autoescape tag django template",
|
||||
"body": ["{% autoescape ${off} %}", " ", "{% autoescape %}"]
|
||||
},
|
||||
"block": {
|
||||
"prefix": "block",
|
||||
"description": "block tag django template",
|
||||
"body": [
|
||||
"{% block $1 %}",
|
||||
" ",
|
||||
"{% endblock $1 %}"
|
||||
]
|
||||
},
|
||||
"comment": {
|
||||
"prefix": "comment",
|
||||
"description": "Comment tag django template",
|
||||
"body": ["{% comment %}", " $1", "{% endcomment %}"]
|
||||
},
|
||||
"csrf": {
|
||||
"prefix": "csrf",
|
||||
"description": "csrf token django template",
|
||||
"body": ["{% csrf_token %}"]
|
||||
},
|
||||
"cycle": {
|
||||
"prefix": "cycle",
|
||||
"description": "cycle tag django template",
|
||||
"body": ["{% cycle %}"]
|
||||
},
|
||||
"debug": {
|
||||
"prefix": "debug",
|
||||
"description": "debug tag django template",
|
||||
"body": ["{% debug %}"]
|
||||
},
|
||||
"ext": {
|
||||
"prefix": "ext",
|
||||
"description": "extends tag django template",
|
||||
"body": ["{% extends \"$1\" %}"]
|
||||
},
|
||||
"extends": {
|
||||
"prefix": "extends",
|
||||
"description": "extends tag django template",
|
||||
"body": ["{% extends \"$1\" %}"]
|
||||
},
|
||||
"filter": {
|
||||
"prefix": "filter",
|
||||
"description": "filter tag django template",
|
||||
"body": ["{% filter $1 %}", " ", "{% endfilter %}"]
|
||||
},
|
||||
"firstof": {
|
||||
"prefix": "firstof",
|
||||
"description": "firstof tag django template",
|
||||
"body": ["{% firstof %}"]
|
||||
},
|
||||
"for": {
|
||||
"prefix": "for",
|
||||
"description": "for tag django template",
|
||||
"body": ["{% for $1 in %}", " ", "{% endfor %}"]
|
||||
},
|
||||
"fore": {
|
||||
"prefix": "fore",
|
||||
"description": "foreach with empty tag django template",
|
||||
"body": ["{% for $1 in %}", " ", "{% empty %}", " ", "{% endfor %}"]
|
||||
},
|
||||
"if": {
|
||||
"prefix": "if",
|
||||
"description": "if tag django template",
|
||||
"body": ["{% if $1 %}", " ", "{% endif %}"]
|
||||
},
|
||||
"ifchanged": {
|
||||
"prefix": "ifchanged",
|
||||
"description": "ifchanged tag django template",
|
||||
"body": ["{% ifchanged $1 %}", " ", "{% endifchanged %}"]
|
||||
},
|
||||
"ife": {
|
||||
"prefix": "ife",
|
||||
"description": "if else tag django template",
|
||||
"body": ["{% if $1 %}", " ", "{% else %}", " ", "{% endif %}", ""]
|
||||
},
|
||||
"ifelse": {
|
||||
"prefix": "ifelse",
|
||||
"description": "if else tag django template",
|
||||
"body": ["{% if $1 %}", " ", "{% else %}", " ", "{% endif %}", ""]
|
||||
},
|
||||
"ifeq": {
|
||||
"prefix": "ifeq",
|
||||
"description": "ifequal tag django template",
|
||||
"body": ["{% ifequal $1 %}", " ", "{% endifequal %}"]
|
||||
},
|
||||
"ifequal": {
|
||||
"prefix": "ifeq",
|
||||
"description": "ifequal tag django template",
|
||||
"body": ["{% ifequal $1 %}", " ", "{% endifequal %}"]
|
||||
},
|
||||
"ifnotequal": {
|
||||
"prefix": "ifnotequal",
|
||||
"description": "ifnotequal tag django template",
|
||||
"body": ["{% ifnotequal $1 %}", " ", "{% ifnotequal %}"]
|
||||
},
|
||||
"inc": {
|
||||
"prefix": "inc",
|
||||
"description": "include tag django template",
|
||||
"body": ["{% include \"$1\" %}"]
|
||||
},
|
||||
"include": {
|
||||
"prefix": "include",
|
||||
"description": "include tag django template",
|
||||
"body": ["{% include \"$1\" %}"]
|
||||
},
|
||||
"load": {
|
||||
"prefix": "load",
|
||||
"description": "load tag django template",
|
||||
"body": ["{% load $1 %}"]
|
||||
},
|
||||
"now": {
|
||||
"prefix": "now",
|
||||
"description": "now tag django template",
|
||||
"body": ["{% now \"$1\" %}"]
|
||||
},
|
||||
"regroup": {
|
||||
"prefix": "regroup",
|
||||
"description": "regroup tag django template",
|
||||
"body": ["{% regroup $1 by as %}"]
|
||||
},
|
||||
"spaceless": {
|
||||
"prefix": "spaceless",
|
||||
"description": "spaceless tag django template",
|
||||
"body": ["{% spaceless %}", " $1", "{% endspaceless %}"]
|
||||
},
|
||||
"ssi": {
|
||||
"prefix": "ssi",
|
||||
"description": "ssi tag django template",
|
||||
"body": ["{% ssi $1 parsed %}"]
|
||||
},
|
||||
"static": {
|
||||
"prefix": "static",
|
||||
"description": "static tag django template",
|
||||
"body": ["{% static '$1' %}"]
|
||||
},
|
||||
"templatetag": {
|
||||
"prefix": "templatetag",
|
||||
"description": "templatetag tag django template",
|
||||
"body": ["{% templatetag $1 %}"]
|
||||
},
|
||||
"url": {
|
||||
"prefix": "url",
|
||||
"description": "url tag django template",
|
||||
"body": ["{% url $1 %}"]
|
||||
},
|
||||
"verbatim": {
|
||||
"prefix": "verbatim",
|
||||
"description": "verbatim tag django template",
|
||||
"body": ["{% verbatim %}", " $1", "{% endverbatim %}"]
|
||||
},
|
||||
"widthratio": {
|
||||
"prefix": "widthratio",
|
||||
"description": "widthratio tag django template",
|
||||
"body": ["{% widthratio ${this_value} max_value 100 %}"]
|
||||
},
|
||||
"with": {
|
||||
"prefix": "with",
|
||||
"description": "with tag django template",
|
||||
"body": ["{% with $1 as %}", " ", "{% endwith %}"]
|
||||
},
|
||||
"trans": {
|
||||
"prefix": "trans",
|
||||
"description": "translate tag django template",
|
||||
"body": ["{% translate \"$1\" %}"]
|
||||
},
|
||||
"blocktrans": {
|
||||
"prefix": "blocktrans",
|
||||
"description": "blocktrans tag django template",
|
||||
"body": ["{% blocktrans %}", " $1", "{% endblocktrans %}"]
|
||||
},
|
||||
"super": {
|
||||
"prefix": "super",
|
||||
"description": "Block super",
|
||||
"body": ["{{ block.super }}"]
|
||||
},
|
||||
"extrahead": {
|
||||
"prefix": "extrahead",
|
||||
"description": "Extrahead no oficial tag",
|
||||
"body": ["{% block extrahead %}", " $1", "{% endblock extrahead %}"]
|
||||
},
|
||||
"extrastyle": {
|
||||
"prefix": "extrastyle",
|
||||
"description": "Extrastyle no oficial Tag",
|
||||
"body": ["{% block extrahead %}", " $1", "{% endblock extrahead %}"]
|
||||
},
|
||||
"var": {
|
||||
"prefix": "var",
|
||||
"description": "Variable autocomplete",
|
||||
"body": ["{{ $1 }}"]
|
||||
},
|
||||
"tag": {
|
||||
"prefix": "tag",
|
||||
"description": "tag autocomplete no oficial",
|
||||
"body": ["{% $1 %}"]
|
||||
},
|
||||
"staticurl": {
|
||||
"prefix": "staticurl",
|
||||
"description": "STATIC_URL no oficial var",
|
||||
"body": ["{{ STATIC_URL }}"]
|
||||
},
|
||||
"mediaurl": {
|
||||
"prefix": "mediaurl",
|
||||
"description": "",
|
||||
"body": ["{{ MEDIA_URL }}"]
|
||||
},
|
||||
"template_tag": {
|
||||
"prefix": "dtt",
|
||||
"description": "Django template tag",
|
||||
"body": ["{% $1 %}"]
|
||||
},
|
||||
"csrfmiddlewaretoken": {
|
||||
"prefix": "csrfmiddlewaretoken",
|
||||
"description": "Django csrf token",
|
||||
"body": ["csrfmiddlewaretoken: $(\"input[name='csrfmiddlewaretoken']\").val()"]
|
||||
},
|
||||
"render_form": {
|
||||
"prefix": "render_form",
|
||||
"description": "Django render form",
|
||||
"body": ["{% render_form $1 %}"]
|
||||
},
|
||||
"render_table": {
|
||||
"prefix": "render_table",
|
||||
"description": "Django render table",
|
||||
"body": ["{% render_table $1 %}"]
|
||||
}
|
||||
}
|
||||
1395
lua/snippets/dripicons.json
Normal file
1395
lua/snippets/dripicons.json
Normal file
File diff suppressed because it is too large
Load diff
122
lua/snippets/golang.json
Normal file
122
lua/snippets/golang.json
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
{
|
||||
"main": {
|
||||
"prefix": "fmain",
|
||||
"description": "main function",
|
||||
"body": ["package main\n", "func main() {", "\t$1", "}"]
|
||||
},
|
||||
"basicmainfile": {
|
||||
"prefix": "basic",
|
||||
"description": "basic main file",
|
||||
"body": [
|
||||
"package main\n",
|
||||
"import (",
|
||||
"\t\"log\"",
|
||||
"\t\"net/http\"",
|
||||
"\t\"os\"\n",
|
||||
"\t\"github.com/go-chi/chi\"",
|
||||
"\t\"github.com/go-chi/cors\"",
|
||||
"\t\"github.com/joho/godotenv\"",
|
||||
")\n",
|
||||
"func main() {",
|
||||
"\tgodotenv.Load(\".env\")\n",
|
||||
"\tport := os.Getenv(\"PORT\")",
|
||||
"\tif port == \"\" {",
|
||||
"\t\tlog.Fatal(\"PORT environment variable is not set\")",
|
||||
"\t}\n",
|
||||
"\trouter := chi.NewRouter()\n",
|
||||
"\trouter.Use(cors.Handler(cors.Options{",
|
||||
"\t\tAllowedOrigins: []string{\"https://*\", \"http://*\"},",
|
||||
"\t\tAllowedMethods: []string{\"GET\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\"},",
|
||||
"\t\tAllowedHeaders: []string{\"*\"},",
|
||||
"\t\tExposedHeaders: []string{\"Link\"},",
|
||||
"\t\tAllowCredentials: false,",
|
||||
"\t\tMaxAge: 300,",
|
||||
"\t}))\n",
|
||||
"\tv1Router := chi.NewRouter()",
|
||||
"\tv1Router.Get(\"/healthz\", handlerReadiness)",
|
||||
"\tv1Router.Get(\"/err\", handlerErr)\n",
|
||||
"\trouter.Mount(\"/v1\", v1Router)",
|
||||
"\tsrv := &http.Server{",
|
||||
"\t\tAddr: \":\" + port,",
|
||||
"\t\tHandler: router,",
|
||||
"\t}\n",
|
||||
"\tfileServer := http.FileServer(http.Dir(\"./static/\"))",
|
||||
"\tmux.Handle(\"/static/*\", http.StripPrefix(\"/static\", fileServer))\n",
|
||||
"\tlog.Printf(\"Serving on port: %s\\n\", port)",
|
||||
"\tlog.Fatal(srv.ListenAndServe())",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
"error": {
|
||||
"prefix": "ife",
|
||||
"description": "if statment for error",
|
||||
"body": ["if err != nil {", "\t$1", "}"]
|
||||
},
|
||||
"println": {
|
||||
"prefix": "pl",
|
||||
"description": "fmt.Println",
|
||||
"body": ["fmt.Println(\"$1\")"]
|
||||
},
|
||||
"sprintf": {
|
||||
"prefix": "spf",
|
||||
"description": "fmt.Sprintf",
|
||||
"body": ["fmt.Sprintf(\"$1\")"]
|
||||
},
|
||||
"handler": {
|
||||
"prefix": "hand",
|
||||
"description": "http.Handler",
|
||||
"body": ["func $1(w http.ResponseWriter, r *http.Request) {", "\t", "}"]
|
||||
},
|
||||
"chirouter": {
|
||||
"prefix": "chi",
|
||||
"description": "import for chi router",
|
||||
"body": ["github.com/go-chi/chi/v5"]
|
||||
},
|
||||
"godotenv": {
|
||||
"prefix": "godotenv",
|
||||
"description": "Go dot env",
|
||||
"body": ["\"github.com/joho/godotenv\""]
|
||||
},
|
||||
"potgresdriver": {
|
||||
"prefix": "postgresdriver",
|
||||
"description": "Postgres Driver",
|
||||
"body": ["\"https://github.com/lib/pq\""]
|
||||
},
|
||||
"import": {
|
||||
"prefix": "impt",
|
||||
"description": "import tag",
|
||||
"body": ["import (", "\t\"$1\"", ")\n"]
|
||||
},
|
||||
"funcwithreceiver": {
|
||||
"prefix": "fr",
|
||||
"description": "Function with some receiver",
|
||||
"body": ["func ($1 *$2) $3 {", "\t", "}"]
|
||||
},
|
||||
"sqlcontext": {
|
||||
"prefix": "ctx",
|
||||
"description": "context with timeout",
|
||||
"body": [
|
||||
"ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\n",
|
||||
"defer cancel()\n"
|
||||
]
|
||||
},
|
||||
"fecho": {
|
||||
"prefix": "fecho",
|
||||
"description": "echo with fasthttp",
|
||||
"body": [
|
||||
"package main\n",
|
||||
"import (",
|
||||
"\t\"net/http\"",
|
||||
"\t\"github.com/labstack/echo/v4\"",
|
||||
")\n",
|
||||
"func main() {",
|
||||
"\te := echo.New()\n",
|
||||
"\te.GET(\"/\", func(c echo.Context) error {",
|
||||
"\t\treturn c.String(http.StatusOK, \"Hello, World!\")",
|
||||
"\t})\n",
|
||||
"\te.Static(\"/static\", \"static\")",
|
||||
"\te.Logger.Fatal(e.Start(\":8000\"))",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
}
|
||||
1457
lua/snippets/hero_outline.json
Normal file
1457
lua/snippets/hero_outline.json
Normal file
File diff suppressed because it is too large
Load diff
1457
lua/snippets/hero_solid.json
Normal file
1457
lua/snippets/hero_solid.json
Normal file
File diff suppressed because it is too large
Load diff
52131
lua/snippets/material.json
Normal file
52131
lua/snippets/material.json
Normal file
File diff suppressed because it is too large
Load diff
20
lua/snippets/md.json
Normal file
20
lua/snippets/md.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"command": {
|
||||
"prefix": "cmd",
|
||||
"description": "create command tag",
|
||||
"body": [
|
||||
"```$1",
|
||||
"$2",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
"bashcommand": {
|
||||
"prefix": "bash",
|
||||
"description": "create bash command tag",
|
||||
"body": [
|
||||
"```bash",
|
||||
"$1",
|
||||
"```"
|
||||
]
|
||||
}
|
||||
}
|
||||
55
lua/snippets/package.json
Executable file
55
lua/snippets/package.json
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "nvim-snippets",
|
||||
"author": "LucasF",
|
||||
"engines": {
|
||||
"vscode": "^1.11.0"
|
||||
},
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": "python",
|
||||
"path": "./python.json"
|
||||
},
|
||||
{
|
||||
"language": "python",
|
||||
"path": "./django-python.json"
|
||||
},
|
||||
{
|
||||
"language": "htmldjango",
|
||||
"path": "./django.json"
|
||||
},
|
||||
{
|
||||
"language": "htmldjango",
|
||||
"path": "./bootstrap.json"
|
||||
},
|
||||
{
|
||||
"language": "htmldjango",
|
||||
"path": "./dripicons.json"
|
||||
},
|
||||
{
|
||||
"language": "htmldjango",
|
||||
"path": "./hero_outline.json"
|
||||
},
|
||||
{
|
||||
"language": "htmldjango",
|
||||
"path": "./material.json"
|
||||
},
|
||||
{
|
||||
"language": "htmldjango",
|
||||
"path": "./hero_solid.json"
|
||||
},
|
||||
{
|
||||
"language": "go",
|
||||
"path": "./golang.json"
|
||||
},
|
||||
{
|
||||
"language": "sql",
|
||||
"path": "./sql.json"
|
||||
},
|
||||
{
|
||||
"language": "markdown",
|
||||
"path": "./md.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
13
lua/snippets/python.json
Normal file
13
lua/snippets/python.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"ifmain": {
|
||||
"prefix": "ifmain",
|
||||
"description": "create basic function with if __name__ == \"__main__\"",
|
||||
"body": [
|
||||
"def execute():",
|
||||
"\t${1}",
|
||||
"\n\n",
|
||||
"if __name__ == \"__main__\":",
|
||||
"\texecute()"
|
||||
]
|
||||
}
|
||||
}
|
||||
25
lua/snippets/sql.json
Normal file
25
lua/snippets/sql.json
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"goosesql": {
|
||||
"prefix": "goosesql",
|
||||
"description": "create up and down comments",
|
||||
"body": [
|
||||
"-- +goose Up\n",
|
||||
"-- +goose Down\n"
|
||||
]
|
||||
},
|
||||
"goosetable": {
|
||||
"prefix": "goosetable",
|
||||
"description": "create sql table",
|
||||
"body": [
|
||||
"-- +goose Up\n",
|
||||
"CREATE TABLE $1 (",
|
||||
"\tid UUID PRIMARY KEY,",
|
||||
"\tcreated_at TIMESTAMP NOT NULL,",
|
||||
"\tupdated_at TIMESTAMP NOT NULL,",
|
||||
"\tname TEXT NOT NULL",
|
||||
");\n",
|
||||
"-- +goose Down\n",
|
||||
"DROP TABLE $1;"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue