Replies: 25 comments 114 replies
-
Hi, @calebdw, If you have any queries files, etc. for indent in your environment, it would be helpful to share the information. |
Beta Was this translation helpful? Give feedback.
-
Hi @yaegassy! Thank you for the detailed instructions! I have actually had a few feedbacks from Nvim users asking for help with regards to setting up I am sure this will be extremely useful so I will put a link on a README.md pointing to this discussion for all Neovim users. 😊 I have two questions:
|
Beta Was this translation helpful? Give feedback.
-
Hey, @yaegassy and @calebdw ! I've set up the blade filetype and created the queries ( similar as yaegassy ) as you guys posted. But now only the blade directives from the blade parser are being highlighted and the html ( marked as a php node ) isn't. Should I change any configuration of the php parser for it to attach to the blade files too? I'm not pretty sure of what to do. |
Beta Was this translation helpful? Give feedback.
-
It would be great if someone could add the Lua installation guide. |
Beta Was this translation helpful? Give feedback.
-
Could someone help me out I am out of touch with this tree-sitter stuff and all I want is somewhat good blade support, I followed the instructions on your post and got this only, as you can see only about 10% of the file is highlighted. |
Beta Was this translation helpful? Give feedback.
-
I'm encountering an issue while attempting to integrate Treesitter for Blade syntax highlighting in my project. I've added the necessary code to my plugins/treesitter.lua file for Treesitter to recognize Blade. Additionally, I've created the appropriate queries in blade/highlights.scm and blade/injections.scm. However, when I run the command
I've reviewed my code, but I can't seem to identify the root cause of this error. I would appreciate any assistance or insights to help me resolve this issue. Here's a snippet of my code for reference: -- Relevant code from plugins/treesitter.lua
-- Relevant code from blade/highlights.scm
-- Relevant code from blade/injections.scm
If anyone has experience with this or has encountered a similar issue, your guidance would be greatly appreciated. Thank you! The full error is:
|
Beta Was this translation helpful? Give feedback.
-
Hi there, using this ((text) @injection.content
(#not-has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language php)) On this code: <div class="photo">
@if ($photo->extension == '.pdf')
@foreach ($photo->urls as $url)
<img src="{{ $url }}" alt="pdf page">
@endforeach
@endif
</div> Running :InspectTree it shows a tree twice, the first one with errors, the second one all ok.
Any clues how to fix it? |
Beta Was this translation helpful? Give feedback.
-
Hi! I had been using tree-sitter-blade successfully for a few months. I recently switched from packer to lazy and am having troubles getting it configured. I am successfully getting neovim to recognize .blade.php files as 'blade' files, and after running I have my blade filetype set in my
my
my
my
I'm not sure if I'm missing something or have something configured improperly. |
Beta Was this translation helpful? Give feedback.
-
I get the following error when running TSInstall blade command Installation not possible: ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/install.lua:86: Parser not available for language "blade" I have the following config return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"php",
},
config = function(plug, config)
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,
},
},
} Am I doing something wrong or missing anything @yaegassy ? |
Beta Was this translation helpful? Give feedback.
-
Hello, how do I add html textobjects to blade queries? I tried: ((content) @injection.content
(#set! injection.language "html")
(#set! injection.combined)) But it raises an I'm trying to use html textobjects to delete inside tags, change tag attributes, etc. I can do that already for html files but not for blade files. |
Beta Was this translation helpful? Give feedback.
-
Hi all, thank you for the amazing contributions! |
Beta Was this translation helpful? Give feedback.
-
Hi, I was wondering if php inside my blade directive can/is supposed to be formatted? Formatting of html and the blade directives themselves is working great! |
Beta Was this translation helpful? Give feedback.
-
Hey ✌ Thank you all so much for your work on this! I want to highlight nested blade components that include a dot. Can you please give me a hint how to achieve this? Thanks a bunch! If it helps this explains my problem pretty good in one picture (notice the |
Beta Was this translation helpful? Give feedback.
-
how to make |
Beta Was this translation helpful? Give feedback.
-
Wondering if anyone has has had any success configuring indentation and is willing to share their indents.scm file? |
Beta Was this translation helpful? Give feedback.
-
Hi, any one having this issue? It only shows the error when open any blade file from other php files. After some checking, seems like something to deal with lsp, phpactor. Once the phpactor lsp initiated, it started to complain highlight error. So if anyone also having this issue, here is an easy quick fix: -- your lsp setting file, mine lsp.lua
require("lspconfig").phpactor.setup({
filetypes = { "php", "blade" },
}) |
Beta Was this translation helpful? Give feedback.
-
Hello guys, print("Loading after/ftplugin/blade.lua")
vim.opt_local.expandtab = true
vim.opt_local.tabstop = 2
vim.opt_local.softtabstop = 2
vim.opt_local.shiftwidth = 2
print("Softtabstop: ", vim.opt_local.softtabstop:get())
print("tabstop: ", vim.opt_local.tabstop:get())
print("Shiftwidth: ", vim.opt_local.shiftwidth:get()) The print value "2" are displayed correctly when I open a blade file. Here is my nvim-treesitter file (highlighting work great) : return {
"nvim-treesitter/nvim-treesitter", build = ":TSUpdate",
config = function ()
local configs = require("nvim-treesitter.configs")
-- blade syntaxe highlight
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"
}
configs.setup({
ensure_installed = {
"c", "lua", "vim", "vimdoc", "query", "org", "javascript", "html", "php",
"hlsl", "json", "http", "css", "scss", "typescript", "vala", "xml", "vue",
"blade",
},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
enable = true,
-- Required for spellcheck, some LaTex highlights and
-- code block highlights that do not have ts grammar
additional_vim_regex_highlighting = {"org"},
},
indent = {
enable = true,
},
})
vim.cmd [[
augroup BladeFiletypeRelated
autocmd!
autocmd BufNewFile,BufRead *.blade.php set ft=blade
augroup END
]]
-- Try to indent by 2 also here
vim.cmd [[
augroup BladeIndentation
autocmd!
autocmd FileType blade setlocal tabstop=2 shiftwidth=2 expandtab
augroup END
]]
end
} When I run the command But each time I run the command I have a If you have any ideas, I would be very grateful. |
Beta Was this translation helpful? Give feedback.
-
I'm suddenly not able to get highlights in blade file but only in php file. Does anyone have the same experience? M.config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
require("nvim-treesitter.parsers").get_parser_configs().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 PHP: M.setup = function(on_attach, capabilities)
local lspconfig = require("lspconfig")
local lsp_config = require("lspconfig.configs")
lspconfig.phpactor.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = { "php", "blade" },
init_options = {
["language_server_phpstan.enabled"] = true,
["language_server_phpstan.level"] = "8",
},
})
-- Add custom blade lsp
lsp_config.blade_ls = {
default_config = {
name = "blade_ls",
cmd = { vim.fn.expand("$HOME/blade-lsp/builds/laravel-dev-tools"), "lsp" },
filetypes = { "blade" },
root_dir = function()
return vim.loop.cwd()
end,
settings = {},
},
}
-- Setup it
lspconfig.blade_ls.setup({
capabilities = capabilities,
})
end |
Beta Was this translation helpful? Give feedback.
-
Hi there, I want to consult about tree-sitter-blade on my neovim config. The configurations currently running on my machine can be found at this repository. I followed the instructions given in this discussion, and the current output I get when opening a As you can see, it identifies the OS: WSL2 Ubuntu 22.04 LTS |
Beta Was this translation helpful? Give feedback.
-
HTML highlighting not working for me. I am using NVChad. This is my setup
highlights
injection
|
Beta Was this translation helpful? Give feedback.
-
is their any way to setup format? |
Beta Was this translation helpful? Give feedback.
-
Just follow this https://medium.com/@jogarcia/laravel-blade-on-neovim-ee530ff5d20d |
Beta Was this translation helpful? Give feedback.
-
Hi! need help. My problems:
below is my -- import nvim-treesitter plugin safely
local status, treesitter = pcall(require, "nvim-treesitter.configs")
if not status then
return
end
-- configure treesitter
treesitter.setup({
-- enable syntax highlighting
highlight = {
enable = true,
},
-- enable indentation
indent = { enable = true },
-- enable autotagging (w/ nvim-ts-autotag plugin)
autotag = { enable = true },
-- ensure these language parsers are installed
ensure_installed = {
"json",
"javascript",
"typescript",
"tsx",
"yaml",
"html",
"css",
"php",
"blade",
"markdown",
"markdown_inline",
-- "lua",
"vim",
-- "dockerfile",
"gitignore",
},
-- auto install above language parsers
auto_install = true,
})
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",
},
})
below is my ((text) @injection.content
(#not-has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language php))
; tree-sitter-comment injection
; if available
((comment) @injection.content
(#set! injection.language "comment"))
; could be bash or zsh
; or whatever tree-sitter grammar you have.
((text) @injection.content
(#has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language bash))
((php_only) @injection.content
(#set! injection.language php_only))
((parameter) @injection.content
(#set! injection.include-children) ; You may need this, depending on your editor e.g Helix
(#set! injection.language "php-only")) below is my ((text) @injection.content
(#not-has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language php))
; tree-sitter-comment injection
; if available
((comment) @injection.content
(#set! injection.language "comment"))
; could be bash or zsh
; or whatever tree-sitter grammar you have.
((text) @injection.content
(#has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language bash))
((php_only) @injection.content
(#set! injection.language php_only))
((parameter) @injection.content
(#set! injection.include-children) ; You may need this, depending on your editor e.g Helix
(#set! injection.language "php-only")) |
Beta Was this translation helpful? Give feedback.
-
I found that
|
Beta Was this translation helpful? Give feedback.
-
Overview
I created this discussion topic to share information on using tree-sitter-blade in Neovim (nvim-treesitter). I hope that the number of tree-sitter-blade users will increase, and that better feedback, pull requests, etc. will increase.
Installation of nvim-treesitter and addition of settings for tree-sitter-blade
First, please install nvim-treesitter. For more information, please click here. https://github.com/nvim-treesitter/nvim-treesitter
Add settings for tree-sitter-blade to init.vim
Install tree-sitter-blade. Execute
:TSInstall blade
.Add queries file
Add queries files for highlighting, etc. queries files for blade are not currently bundled with nvim-treesitter and must be added manually.
Query file for highlights
Execute the following command. A file will be created in
~/.config/nvim/after/queries/blade/highlights.scm
.:TSEditQuery highlights blade
.Please write the following settings. The settings are examples only.
Example:
Query file for injections
Execute the following command. A file will be created in
~/.config/nvim/after/queries/blade/injections.scm
.:TSEditQuery injections blade
Please write the following settings. The settings are examples only.
Example:
Misc
For indentation, you will need to add a queries file for indentation. Alternatively, you can install vim-blade for indentation.
Beta Was this translation helpful? Give feedback.
All reactions