New issue
Advanced search Search tips

Issue 763570 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

GN (Vim): gn#TranslateToBuildFile doesn't work on absolute paths

Project Member Reported by michae...@chromium.org, Sep 8 2017

Issue description

Within a BUILD.gn file, I can't use `gf` in Vim to move to a dependency given by an absolute path (relative to source root of course).

From chrome/browser/BUILD.gn:

1. Move cursor to "//mash/common"
2. `gf`

Expected: opens //mash/common/BUILD.gn
Actual: opens //mash/common (the directory)

Reduced case:

 :echo gn#TranslateToBuildFile("foo/bar")

Expected: "foo/bar/BUILD.gn"
Actual: "foo/bar"

Workaround: Install the google-vim/maktaba plugin, AND call `:runtime autoload/maktaba.vim`.

I think there are 2 bugs:

1. The fallback (without maktaba) uses `isdirectory()`, which only works for a relative directory if the directory exists relative to the current directory.

2. autoload/gn.vim checks for maktaba, but merely checking for a function's existence does not cause the vim file defining the function to be autoloaded. Thus the call to `:runtime` is necessary to load maktaba before calling gn#TranslateToBuildFile.



note: gn/misc/vim/ftplugin/gn.vim sets `includeexpr` to gn#TranslateToBuildFile, which causes it to be called when looking for a file when the buffer is a .gn file
 
Third issue: since the preceding "//" are truncated, then even with the workarounds, going to an absolute path will follow a relative path instead if a relative path exists.

Example: from //chrome/browser/apps/BUILD.gn, highlight "//apps". `gf` opens the current file instead of //apps/BUILD.gn.

Sign in to add a comment