RicardoRamirezR / blade-nav.nvim

Navigating Blade views within Laravel projects
MIT License
47 stars 6 forks source link

Slow when navigating through livewire components #19

Closed rizkyilhampra closed 2 months ago

rizkyilhampra commented 2 months ago

Hi. I was using v1.4 then recently updated your plugin to v1.5.4 and I noticed there is slowness when navigating blade files or livewire components. It takes maybe 1-2 seconds to see the component I want to look for. I'm sorry I don't know how to debug to show you the exact time it takes.

Here is my neovim version i used

NVIM v0.10.1
type: Release
2.1.1713484068
"nvim -V1 -v" for more info

I know the gf key will trigger some processes instead of only navigating through blade files or livewire components, so it's understandable for being slow. My workaround is, maybe make it configurable to set keymaps for different process?

Thanks

RicardoRamirezR commented 2 months ago

@rizkyilhampra thanks for reporting. Give a look at v1.6.0 to see if happens there please.

Edit: v1.6.1 instead

Edit (2): please post the output of :checkhealth blade-nav

rizkyilhampra commented 2 months ago

Yes it still hapen in v1.6.1. Here is some information

checkhealth output

blade-nav: require("blade-nav.health").check()

Blade Nav health check started ~
- OK fd 10.1.0
- OK PHP 8.3.9 (cli) (built: Jul  2 2024 15:37:13) (NTS)
- WARNING Blade command components-aliases not found
  to install it run the Ex command BladeNavInstallArtisanCommand
- OK composer.json
- OK resources/views
- OK vendor/composer/autoload_psr4.php
- OK Git repository found

I do run BladeNavInstallArtisanCommand in a laravel project, but it give me error

BladeNavInstallArtisanCommand Error writing file: Could not open file: /home/aquila/Projects/test/app/Console/Commands/BladeNav.php

Edit: After I tried to create a command first with php artisan make:command BladeNav and then run BladeNavInstallArtisan, the BladeNavInstallArtisan command worked and didn't give me an error. After that, my checkhealth output looked like this

blade-nav: require("blade-nav.health").check()

Blade Nav health check started ~
- OK fd 10.1.0
- OK PHP 8.3.9 (cli) (built: Jul  2 2024 15:37:13) (NTS)
- OK Blade command blade-nav:components-aliases
- OK composer.json
- OK resources/views
- OK vendor/composer/autoload_psr4.php
- OK Git repository found
RicardoRamirezR commented 2 months ago

@rizkyilhampra thanks for the input.

The error was because app/Console/Command directory does not exist, that's why after making the command with artisan it worked, it is fixed now.

After BladeNavInstallArtisan worked, did gf on <x- is still slow?

RicardoRamirezR commented 2 months ago

@rizkyilhampra a new command BladeElapsedTimes was added in v.1.6.2, please run it an report the output back.

rizkyilhampra commented 2 months ago

@RicardoRamirezR First, i want to tell you, i do reproduce in Breeze laravel starter kit project instead my own. i do BladeNavInstallArtisanCommand but it give me error, even with tried run php artisan make:command. Here is the error i got.

BladeNavInstallArtisanCommand Error executing Lua callback: Vim:E739: Cannot create directory /app: permission denied
stack traceback:
    [C]: in function 'mkdir'
    ...ocal/share/nvim/lazy/blade-nav.nvim/lua/blade-nav/gf.lua:570: in function <...ocal/share/nvim/lazy/blade-nav.nvim/lua/blade-nav/gf.lua:560>

Then, i rollback the plugin into v1.6.1 to make the BladeNavInstallArtisanCommand work, and finally run BladeElapsedTimes.

Here is the output

02:28:07 AM msg_show   BladeElapsedTimes Elapsed time: 0.0351 seconds on check_blade_command
02:28:09 AM msg_show   BladeElapsedTimes Elapsed time: 0.0465 seconds on get_components_aliases
02:28:09 AM msg_show   BladeElapsedTimes Elapsed time: 0.0048 seconds on get_blade_files
02:28:09 AM msg_show   BladeElapsedTimes Elapsed time: 0.0042 seconds on get_root_dir
02:28:10 AM msg_show   BladeElapsedTimes Elapsed time: 0.0089 seconds on get_route_names
   Info  02:28:11 AM notify.info Error parsing JSON output
02:28:11 AM msg_show   BladeElapsedTimes Elapsed time: 0.0150 seconds on get_routes

If you don't mind i'll put in here my 55 second video how do i reproduce.

https://github.com/user-attachments/assets/37838fd3-778d-4ae3-ade3-ce7b35a0c47d

If you see the video, at the 23 second I trigger the gf key, then it finishes at the 25 second.

RicardoRamirezR commented 2 months ago

@rizkyilhampra creating the console command is ok now in v1.6.3

Can reproduce the slowness 😏

See here, fresh laravel + breeze + livewire 3

https://github.com/user-attachments/assets/fc4e95e6-2959-418a-b083-b5d588bb2ec1

RicardoRamirezR commented 2 months ago

@rizkyilhampra, check the new pre-release and let me know. If not works I will comment a section to test on it, then we'll see

rizkyilhampra commented 2 months ago

@RicardoRamirezR it still happen

RicardoRamirezR commented 2 months ago

@rizkyilhampra try v1.6.4 please

rizkyilhampra commented 2 months ago

Yes it worksss now, thanks @RicardoRamirezR

RicardoRamirezR commented 2 months ago

@rizkyilhampra great to know, I've comment an implementation, I'll dig further to provide full solution

RicardoRamirezR commented 2 months ago

@rizkyilhampra can you use main branch please and see if it works. I'm trying to find the culprit

RicardoRamirezR commented 2 months ago

@rizkyilhampra, try main again please., it will fails. Then edit the app/Console/Command/BladeNav.php the in the handle before line 29 add a return echo json_encode([]); then test again please

rizkyilhampra commented 2 months ago

@rizkyilhampra can you use main branch please and see if it works. I'm trying to find the culprit

It's not work, my bad if you had see my reply before.

RicardoRamirezR commented 2 months ago

No problem

rizkyilhampra commented 2 months ago

@rizkyilhampra, try main again please., it will fails. Then edit the app/Console/Command/BladeNav.php the in the handle before line 29 add a return echo json_encode([]); then test again please

i see the decrement, but it's still not fast like i was in v1.4. I'm still ok with this

RicardoRamirezR commented 2 months ago

Let's try again

rizkyilhampra commented 2 months ago

same i just see the decrement

RicardoRamirezR commented 2 months ago

Can you run php artisan --format=json to see if it is the culprit

rizkyilhampra commented 2 months ago

Is too much. You still want to see all the output?

image

RicardoRamirezR commented 2 months ago

Nop, it ok. I'll go to an alternative

RicardoRamirezR commented 2 months ago

Please check again fro main branch

rizkyilhampra commented 2 months ago

it workss

rizkyilhampra commented 2 months ago

I'm not sure, i think you got typo in here https://github.com/RicardoRamirezR/blade-nav.nvim/blob/fabdfc9a9db7aa66eb0fe8adf36b9740a53e578b/lua/blade-nav/utils.lua#L379

RicardoRamirezR commented 2 months ago

Yep, thank you. I've made the correction. Please try again to check it is working

RicardoRamirezR commented 2 months ago

@rizkyilhampra the updated release v1.6.6 has the final fix.

rizkyilhampra commented 2 months ago

@RicardoRamirezR Ya it works now. Thanks