Skip to content

Commit a6cfdd8

Browse files
author
Ellis Kenyő
committed
feat(+php-laravel-mode): add __ snippet
1 parent 6b2bd5a commit a6cfdd8

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

+php-laravel-mode/.yas-parents.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(eval-when-compile (require 'subr-x))
2+
3+
(defun string-split-words (string)
4+
(split-string
5+
(let ((case-fold-search nil))
6+
(replace-regexp-in-string
7+
"\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2"
8+
(replace-regexp-in-string "\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)" "\\1 \\2" string)))
9+
"[^[:word:]0-9]+"
10+
t))
11+
12+
(defun +php-laravel-mode--get-namespace ()
13+
"Get a formatted namespace for the current PHP file"
14+
(substring
15+
(replace-regexp-in-string "/" (regexp-quote "\\")
16+
(thread-first
17+
buffer-file-name
18+
(file-relative-name (doom-project-root))
19+
file-name-directory
20+
capitalize))
21+
0
22+
-1))
23+
24+
(defun +php-laravel-mode--get-class-name ()
25+
"Get a formatted class name for the current PHP file"
26+
(string-join (mapcar 'capitalize (string-split-words (file-name-base buffer-file-name)))))

+php-laravel-mode/__

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- mode: snippet -*-
2+
# name: PHP template
3+
# --
4+
<?php
5+
6+
namespace `(+php-laravel-mode--get-namespace)`;
7+
8+
class `(+php-laravel-mode--get-class-name)`
9+
{
10+
$0
11+
}

0 commit comments

Comments
 (0)