Skip to content

Add new +php-laravel-mode snippets #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions +php-laravel-mode/.yas-parents.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(eval-when-compile (require 'subr-x))

(defun +php-laravel-mode--get-namespace ()
"Get a formatted namespace for the current PHP file"
(substring
(replace-regexp-in-string "/" (regexp-quote "\\")
(thread-first
buffer-file-name
(file-relative-name (doom-project-root))
file-name-directory
capitalize))
0
-1))

(defun +php-laravel-mode--get-class-name ()
"Get a formatted class name for the current PHP file"
(string-join (mapcar 'capitalize
(split-string
(let ((case-fold-search nil))
(replace-regexp-in-string
"\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2"
(replace-regexp-in-string
"\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)" "\\1 \\2"
(file-name-base buffer-file-name))))
"[^[:word:]0-9]+"
t))))
11 changes: 11 additions & 0 deletions +php-laravel-mode/__
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: PHP template
# --
<?php

namespace `(+php-laravel-mode--get-namespace)`;

class `(+php-laravel-mode--get-class-name)`
{
$0
}
8 changes: 8 additions & 0 deletions +php-laravel-mode/migration
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: Laravel Migration method
# key: mig
# uuid: mig
# --
Schema::table('$1', function (Blueprint $table) {
`%`$0
});