Skip to content

Conversation

@idbrii
Copy link
Contributor

@idbrii idbrii commented Sep 13, 2022

Draft because I haven't tested this enough, but I saw your comment on my related vim question, so I thought I'd post so you can see and it might be awhile before I work on it again.


Fix gf on extends "res://cars/car_base.gd" opens "res://cars/car_base.gd" instead of C:/project/cars/car_base.gd.

The includeexpr isn't sufficient to open these files because vim sees res:// as a valid filepath and fails to invoke it includeexpr. Possibly includeexpr is unnecessary; I don't entirely understand what it's for.

Use a similar method to netrw and use BufReadCmd to capture attempts to edit res:// files and resolve to the intended file. During this resolve, we're already editing the res:// path, so the old
findfile("project.godot", ".;") returns a nonsense path (vim/vim#11060) and we need to try harder.

Test

  • gf on a extends line
  • edit res://file without ever opening a godot project and it still opens res://file.

@idbrii idbrii marked this pull request as ready for review January 7, 2023 01:00
@idbrii
Copy link
Contributor Author

idbrii commented Jan 7, 2023

After using this for a while, I think it's pretty good. I occasionally gf on a file and it doesn't have syntax loaded, but otherwise haven't seen anything wrong.

@idbrii
Copy link
Contributor Author

idbrii commented Nov 14, 2023

@habamax Is there anything blocking merging this PR?

Fix gf on `extends "res://cars/car_base.gd"` opens
`"res://cars/car_base.gd"` instead of `C:/project/cars/car_base.gd`.

The includeexpr isn't sufficient to open these files because vim sees
res:// as a valid filepath and fails to invoke it includeexpr. Possibly
includeexpr is unnecessary; I don't entirely understand what it's for.

Use a similar method to netrw and use BufReadCmd to capture attempts to
edit res:// files and resolve to the intended file. During this resolve,
we're already editing the res:// path, so the old
findfile("project.godot", ".;") returns a nonsense path (vim/vim#11060)
and we need to try harder.

Test
* gf on a extends line
* edit res://file without ever opening a godot project and it still
  opens res://file.
@idbrii
Copy link
Contributor Author

idbrii commented Aug 30, 2025

I occasionally gf on a file and it doesn't have syntax loaded, but otherwise haven't seen anything wrong.

I fixed this issue by making the autocmd nested. Seems like it's consistently loading the syntax of destination files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant