So I started a Vim plugin called gfi (goto file improved). The goal for me was to create a plugin that is plug ’n play, zero-configuration required for you to enjoy this simple but efficient plugin.
So how does it work? When using this plugin your regular gf will be remapped and when pressing gf it always tries to resolve the file under the cursor using atleast the following logic:
- relative to the current buffer
- relative to Vim's current working directory
- based on the git directory it is located in
Implementing these 3 checks for every filetype made sense to me. Just having these 3 checks already makes gf already much more efficient want useful.
If these 3 fail to retrieve a path then some filetypes may have additional checks. Javascript-like projects can be webpack-configured and thus may use absolute imports. These are done by checking the package.json in the root of the project.
Golang path resolving for the import-statement is also taken into account. Since these imports are directories, the directory will be opened rather than a file, but it’s still more efficient, since gf does not open directories by default.
A goal I have is hoping for contributions for as many languages as possible so that the gf command will be more useful for many more developers.
If you have feedback or like to contribute, send me a mail or do your contribution via https://github.com/kkoomen/gfi.vim