Godot scripts sometimes contain lines like:
If my project is in c:/project, then that line refers to the path c:/project/cars/car_base.gd.
How can I make
gf work with this root substitution scheme?
I would expect this to work, but it does not:
let &includeexpr = "substitute(v:fname, 'res:/', substitute(fnamemodify(findfile('project.godot', '.;'), ':h'), '\\', '/', 'g'), '')"
As a test, I can't get
res:// paths to be affected by 'includeexpr' at all:
let &includeexpr = "substitute(v:fname, '.*', '~/.vimrc', '')"
gf on my
res:// line edits "res://cars/driveable.gd" (a nonexistent file, but no E447). If I change
res_, then that 'includeexpr' works. So it seems like vim thinks
res:// is a real filepath and doesn't care that it doesn't exist.
I saw the question open salt://whatever as somedir/whatever and it seems close, but
findfile("project.godot", ".;") returns
res://cars/project.godot inside my BufReadCmd instead of the actual path. The returned path should be
c:/code/project/project.godot and definitely shouldn't have the "cars" directory in it. (Neither resolve() nor expand() are helpful.)
I have netrw disabled, but I get similar results with