Vim: `gf` should use the current project root too

Created on 23 Jul 2017  路  7Comments  路  Source: VSCodeVim/Vim

  • Click thumbs-up 馃憤 on this issue if you want it!
  • Click confused 馃槙 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


Is this a BUG REPORT or FEATURE REQUEST? (choose one): FEATURE REQUEST

Currently, the gf command only uses the current location of the currently opened file. Sometimes, it's correct/handy to open a path relative to the top of the project directory

Environment:

  • VSCode Version: 1.14.0
  • VsCodeVim Version: 0.8.4
  • OS:
    Linux

Most helpful comment

Does gd work for those having issues with gf? And does gd lack any behavior expected out of gf?

Personally I use gd instead of gf, and that already works with configuration like jsconfig.json for paths, if configured properly with baseUrl and paths. For example, with a jsconfig.json at the project root:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "jsx": "preserve",
    "baseUrl": "./",
    "paths": {
      "Home/*": [
        "src/routes/Home/*"
      ]
    }
  }
}

I can then use absolute imports:

import Home from "Home/Home";
// ...

gd on "Home/Home" will jump to that file. Note there might be a bug currently with jumping to just "Home" if trying to jump to an index.js, it wasn't working with me unless I do "Home/index" instead of just "Home": https://github.com/Microsoft/vscode/issues/57096

All 7 comments

It seems you want something similar to the path option for vim?

Sorta. A full-fledged path option would sure be powerful. But the default behavior with root of the project in the search path is also sensible.

I suggest gf could search file basing 'jsconfig.json', https://code.visualstudio.com/docs/languages/jsconfig

This is a quite unpleasant experience for me too. I tried to use gf on #include in C/C++ projects and the extension was trying to open the header file relative to the directory of current file, instead of the workspace root, which failed of course. This makes gf practically useless in C/C++ projects.

any solution for this?

Does gd work for those having issues with gf? And does gd lack any behavior expected out of gf?

Personally I use gd instead of gf, and that already works with configuration like jsconfig.json for paths, if configured properly with baseUrl and paths. For example, with a jsconfig.json at the project root:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "jsx": "preserve",
    "baseUrl": "./",
    "paths": {
      "Home/*": [
        "src/routes/Home/*"
      ]
    }
  }
}

I can then use absolute imports:

import Home from "Home/Home";
// ...

gd on "Home/Home" will jump to that file. Note there might be a bug currently with jumping to just "Home" if trying to jump to an index.js, it wasn't working with me unless I do "Home/index" instead of just "Home": https://github.com/Microsoft/vscode/issues/57096

I am also facing the same issue. 'gf' should jump relative to workspace root rather than file location. Is there any update regarding the same ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edwintorok picture edwintorok  路  3Comments

gerardmrk picture gerardmrk  路  3Comments

liamdawson picture liamdawson  路  3Comments

jaredly picture jaredly  路  3Comments

triztian picture triztian  路  3Comments