Update for blade templating PHP

This commit is contained in:
Matt Blacker 2024-06-17 13:11:53 +10:00
parent 32cd02ed62
commit 8ab65c2e52
4 changed files with 77 additions and 2 deletions

View File

@ -0,0 +1,36 @@
;; extends
; AlpineJS attributes
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^x%-%l")
(#not-any-of? @_attr "x-teleport" "x-ref" "x-transition")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
; Blade escaped JS attributes
; <x-foo ::bar="baz" />
(element
(_
(tag_name) @_tag
(#lua-match? @_tag "^x%-%l")
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^::%l")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))))
; Blade PHP attributes
; <x-foo :bar="$baz" />
(element
(_
(tag_name) @_tag
(#lua-match? @_tag "^x%-%l")
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^:%l")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "php_only"))))

View File

@ -217,6 +217,7 @@ local function close_neo_tree()
require('neo-tree.sources.manager').close_all()
vim.notify 'closed all'
end
--
-- [[ Configure and install plugins ]]
--
@ -248,12 +249,13 @@ require('lazy').setup({
-- Auto-save sessions
{
'rmagatti/auto-session',
enabled = true,
lazy = false,
opts = {
log_level = 'error',
auto_session_suppress_dirs = { '~/', '/' },
auto_session_enable_last_session = true,
auto_session_root_dir = '~/.local/state/nvim/sessions/',
auto_session_enable_last_session = false,
-- auto_session_root_dir = '~/.local/state/nvim/sessions/',
bypass_session_save_file_types = { 'neo-tree' },
pre_save_cmds = {
close_neo_tree,
@ -933,6 +935,7 @@ require('lazy').setup({
},
{
'nvim-neo-tree/neo-tree.nvim',
enabled = true,
branch = 'v3.x',
cmd = 'Neotree',
dependencies = {
@ -1144,6 +1147,22 @@ require('lazy').setup({
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.blade = {
install_info = {
url = 'https://github.com/EmranMR/tree-sitter-blade',
files = { 'src/parser.c' },
branch = 'main',
},
filetype = 'blade',
}
vim.filetype.add {
pattern = {
['.*%.blade%.php'] = 'blade',
},
}
end,
},

View File

@ -0,0 +1,4 @@
(directive) @tag
(directive_start) @tag
(directive_end) @tag
(comment) @comment @spell

View File

@ -0,0 +1,16 @@
((text) @injection.content
(#not-has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language php))
((text) @injection.content
(#has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language bash))
((php_only) @injection.content
(#set! injection.combined)
(#set! injection.language php_only))
((parameter) @injection.content
(#set! injection.language php_only))