How to autocomplete file paths using user defined alias and relative file path in VS code

Viewed 358

As the title suggest, I am trying to get the VS Code to recognize my current working directory and my user home directory with a user defined alias. I've tried to extensions to achieve this: "Path Autocomplete" and "Path Intellisense". So far, I've been able to set aliases for absolute paths successfully, but not relative ones. To add to the issue, while the both extensions will autocomplete the file path, they will leave the alias in place and not the actual path.

Based on the user guide for the extensions, I've tried adding the following lines to settings.json:

// Path Autocomplete
"path-autocomplete.pathMappings": {
      "/": "/", // Root directory (Works) 
      "wd": "${folder}", // Alias for relative path to current working directory. (Doesn't work) 
      "abs_path": "/home/user/path/to/directory" // Alias for absolute path to directory. (Autocomplete works, but insertion of the actual path doesn't.) 
   },

or

// Path Intellisense
"path-intellisense.mappings": {
        "/": "/",
        "wd": "${workspaceFolder}/", // Alias for relative path to current working directory. (Doesn't work)
        "abs_path": "/home/user/path/to/directory" // Alias for absolute path to directory. (Autocomplete works, but insertion of the actual path doesn't.) 
    },

Both extensions has the same problem:

  1. Relative paths are not recognized. E.g.
    > "wd/" # No autocompletion suggestions appears.
    
  2. Absolute paths are recognized, and autocomplete options appear, but leaves the alias and not the actual path. E.g.
    > "abs_path/my_file.txt"
    'abs_path/my_file.txt' # Output is not the path: '/home/user/path/to/directory/my_file.txt'
    

According to the user wikis for both extension, it should be possible to set relative paths. However, this is practically useless if they can not insert the actual path to the file I want to select.

I am not sure if this is of relevance, but I am testing the code in R inside the Jupyter extension.

Any suggestions?

0 Answers
Related