SmiteshP/nvim-gps

I guess HTML support is broken

lucasvianav opened this issue · 8 comments

Don't know how to to describe it much, but I opened an HTML file and suddenly could move anymore because was being spammed the following error.

...nvim/site/pack/packer/opt/nvim-gps/lua/nvim-gps/init.lua:57: bad argument #1 to 'match' (string expected, got nil) function: builtin#18 ...nvim/site/pack/
packer/opt/nvim-gps/lua/nvim-gps/init.lua:57: bad argument #1 to 'match' (string expected, got nil) function: builtin#18 ...nvim/site/pack/packer/opt/nvim-gp
s/lua/nvim-gps/init.lua:57: bad argument #1 to 'match' (string expected, got nil) function: builtin#18 ...nvim/site/pack/packer/opt/nvim-gps/lua/nvim-gps/ini
t.lua:57: bad argument #1 to 'match' (string expected, got nil) function: builtin#18 ...nvim/site/pack/packer/opt/nvim-gps/lua/nvim-gps/init.lua:57: bad argu
ment #1 to 'match' (string expected, got nil) function: builtin#18 ...nvim/site/pack/packer/opt/nvim-gps/lua/nvim-gps/init.lua:57: bad argument #1 to 'match'
 (string expected, got nil) function: builtin#18 ...nvim/site/pack/packer/opt/nvim-gps/lua/nvim-gps/init.lua:57: bad argument #1 to 'match' (string expected,
 got nil)

As a temporary measure you can disable html in setup function.

Does this happen for every html file or some specific file? If its for some specific file, could you share it with me so I can reproduce this issue.

Hello @SmiteshP, sorry for the delay.

Unfortunately I can't share the files because it's from my work, but I got the error on multiple HTML files in an Angular project.

From what I could notice, it happens when the cursor is over Angular stuff - either a component or a normal HTML tag with Angular directives (like [routerLink], *ngFor, etc) - and works fine on standard HTML.

Could you share some dummy file with angular tags where you encounter this issue? I am not familiar with Angular 😓

Sure, no worries. I tested it without generating a whole Angular project and the same error happens. Take a look at the following code:

<div>
  <p
    *ngFor="let item of items"
    *ngIf="visible"
    [class.custom]="isCustom"
  >
    {{ item }}
  </p>
  <app-test></app-test>
</div>
  • *ngFor="let item of items" means that this<p> tag will be repeated in a for loop for every element of the items list.
  • *ngIf="visible" means that those <p> tags will only be actually created if the variable visible is true.
  • [class.custom]="isCustom" means that the class custom will be attributed to the <p> tag only if the variable isCustom is true.
  • {{ item }} is a placeholder that'll be substituted by item's value.
  • <app-test></app-test> is a custom component.

I tried adding each directive alone and evaluating require('nvim-gps').get_location() for each tag --- *ngFor and *ngIf are fine, [class.custom] is where the problem lies (I think it's beacuse of the brackets). It gives me the same error I've already posted:

E5108: Error executing lua ...nvim/site/pack/packer/opt/nvim-gps/lua/nvim-gps/init.lua:58: bad argument #1 to 'match'
(string expected, got nil)

For <app-test>, it gives me "炙div > 炙app". It's not an error, I just noticed it doesn't get the whole tag's name.

Thanks for the code snippet. I have determined that the error is because the tag is across multiple lines.

Hey @lucasvianav
Could you checkout the latest commit. It should fix this issue :)
I also modified the regex to also capture - in a tag. This will allow app-data to be captured completely. Are there any other non alpha-numeric characters that can appear in a html tag?

Thanks for the code snippet. I have determined that the error is because the tag is across multiple lines.

Oh, I see. Makes sense.

Could you checkout the latest commit. It should fix this issue :)

Awesome, I'll try it later today!

Are there any other non alpha-numeric characters that can appear in a html tag?

Not that I've seen so far.

Hey @SmiteshP sorry for disappearing. It's working fine now, thanks :)