Skip to content
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

Laravel & Blade pack work but have issues #1126

Closed
4 tasks done
MrMic opened this issue Jul 24, 2024 · 9 comments · Fixed by #1130
Closed
4 tasks done

Laravel & Blade pack work but have issues #1126

MrMic opened this issue Jul 24, 2024 · 9 comments · Fixed by #1130
Labels
bug Something isn't working

Comments

@MrMic
Copy link
Contributor

MrMic commented Jul 24, 2024

Checklist

  • I have searched through the AstroNvim documentation
  • I have searched through the existing issues of this project
  • I have searched the existing issues of plugins related to this issue
  • I can replicate the bug with the minimal repro.lua provided below

Neovim version (nvim -v)

0.10.0

Operating system/version

Linux Ubuntu 22.04

Terminal/GUI

kitty

Describe the bug

  • LARAVEL: Some completion & definition are missing (parse not the entire project? ).
  • BLADE: Color syntax is missing => need to do: set filetype=html

Steps to Reproduce

Start AstroNvim in a Laravel project

Expected behavior

  • Completion work like in VS Code
  • Blade color syntax do not work

Screenshots

Capture d’écran du 2024-07-24 20-51-51

Capture d’écran du 2024-07-24 20-49-35

Capture d’écran du 2024-07-24 20-57-05

Additional Context

Otherwise, all seems to work as expected.

Minimal configuration

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  -- stylua: ignore
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)

-- install plugins
local plugins = {
  { "AstroNvim/AstroNvim", import = "astronvim.plugins" },
  { "AstroNvim/astrocommunity" },

  -- add any other plugins/customizations here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here (autocommands, vim.filetype, etc.)
@MrMic MrMic added the bug Something isn't working label Jul 24, 2024
@MrMic MrMic changed the title Laravel & Blade pack work but have issue Laravel & Blade pack work but have issues Jul 24, 2024
@ALameLlama
Copy link
Contributor

For blade syntax highlighting to work you'll need to manually create the tree sitter query files.

See the notes on https://github.com/AstroNvim/astrocommunity/tree/main/lua/astrocommunity/pack/laravel

@ALameLlama
Copy link
Contributor

I'm sorry the link in the notes is wrong, this should point to EmranMR/tree-sitter-blade#19 (comment)

You'll need to manually add the query files

@MrMic
Copy link
Contributor Author

MrMic commented Jul 25, 2024

@ALameLlama And for the completion in Laravel, that is not correct?

@ALameLlama
Copy link
Contributor

@MrMic how do you mean? The tree sitter queries are just for syntax highlighting. They shouldn't effect anything else.

@MrMic
Copy link
Contributor Author

MrMic commented Jul 25, 2024

@ALameLlama I know but my first issue was about completion (see the first 2 screenshots above).
And that is not fixed. The first screenshot is what VS Code provides (and it is OK) and the second
is what AstroNvim shows (NOK).

@ALameLlama
Copy link
Contributor

ALameLlama commented Jul 25, 2024

@MrMic I believe for Laravel methods like this laravel ide helper is what power this, try installing this and running php artisan ide-helper:generate.

If it's still complaining try to see if it does the same thing for redirect(route('hello')) or to_route('hello') since both of these should give the same result.

I'm not at my PC atm but I'll see if I get the same thing and see if there is something we can do it fix it on our side.

@ALameLlama
Copy link
Contributor

ALameLlama commented Jul 25, 2024

I ended up having the same issue but the two other suggestions I gave don't show the same error.
image

I also installed VS code with PHP Intelephense as the LSP and ran into the same issue where it wasn't detecting redirect()->route() as an option
Code_bNWj4S4Ez2

I assume you'll have some extra plugin within VS code that is doing something extra to get this to work. When I put together the pack, I tried to find every nvim plugin I could to make things as close to PHPStorm/VS code but it's not perfect. if you find other plugins that make the Laravel experience better within nvim. I'm more than happy to look into it

Edit: I know that doing redirect()->route() is valid the IDE will just complain/not accept it but the code itself will work

@ALameLlama
Copy link
Contributor

@MrMic Actually, the issue is with PHP Actor the LSP and it's because the redirect global function has a dynamic return type * @return ($to is null ? \Illuminate\Routing\Redirector : \Illuminate\Http\RedirectResponse)

This was fixed recently in PHP Actor itself phpactor/phpactor#2700 and merged 4 days ago. They haven't done a release but once they do and you update it, the issue will be solved.

For now, if you want to keep that syntax doing redirect(null)->route('something') will work

@MrMic
Copy link
Contributor Author

MrMic commented Jul 25, 2024

Thanks a lot, @ALameLlama for the time you take to troubleshoot this.
I will wait for the update on the PHP Actor. I can work with VS Code in the
meantime.
Maybe It will be worth not to close this issue too quickly... It may interests other Devs?

BTW, my VS Code has these laravel extensions installed:

  • Laravel Blade Snippets
  • Laravel Snippets
  • Laravel Artisan
  • Laravel Extra Intellisense (seems better than intellisense)
  • Laravel Blade Formatter
  • Laravel Blade Spacer
  • Laravel Blade

And so far, all works like a charm 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants