Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 2.77 KB

non-dub.md

File metadata and controls

61 lines (40 loc) · 2.77 KB

Tutorial

Configuring non-DUB projects

By default code-d loads the project folder itself and then each dub project in child folders as separate root.

Without dub by default it will only load the project folder itself as root but it's possible to specify multiple roots in one folder for multiple projects in one folder. For this, specify d.extraRoots in your workspace settings with relative paths to each folder that is supposed to be treated as separate project.

In each root code-d checks if one of the following folders exist if there is no dub and the d.projectImportPaths user setting is not set:

  • source/
  • src/

The first one off that list is going to be picked as source directory for that root. If none of those exist, the folder itself is going to be used as directory for sources. By specifying d.projectImportPaths it is possible to override this behavior to use a custom defined source folder path. All paths in d.projectImportPaths are relative to the project folder and all roots will have the same import paths with this.

example showing root source files

You can see that imports from local files are auto-completed with no problems. However when trying to use files from external folders (such as here, the ext/ folder) the auto completion will not find these symbols.

To fix this, change d.projectImportPaths to [".", "ext"] in your workspace settings:

{
	"d.projectImportPaths": [".", "ext"]
}

project import paths

By setting this all external dependencies specified will now load properly:

working auto complete

Building

If you have a very simple script without any extra dependencies outside the source folder itself, you can run each file using RDMD:

run file with rdmd

However this will not work in this case with extra custom dependencies if they are used as it will not pick them up for the imports.

Otherwise you will have to define your own scripts or build tools and best integrate them in the build task definitions so you can use them for debugging.