hansec / vscode-fortran-ls

Fortran IntelliSense for Visual Studio Code
MIT License
37 stars 7 forks source link

Setup for out-of-source builds #7

Closed pbrady closed 5 years ago

pbrady commented 5 years ago

Not sure if this is the right place to ask but how does one properly set this up for out of source builds?
I have a fortran project organized into several different source directories with a separate build directory. The project structure looks like:

$ tree . -d
.
├── build
├── filter
├── optimizer
├── pde_solver
│   ├── app
│   ├── base
│   ├── embedded
│   ├── integrate
│   ├── io
│   ├── lib
│   ├── mms
│   ├── operator
│   ├── solver
│   └── system
├── tests
│   └── utils
└── tools

I created a .fortls file at the root of my project which looks like:

{
    "mod_dirs": [
        "build/optimizer", "build/tools", "build/pde_solver/base",
        "build/pde_solver/embedded", "build/pde_solver/integrate", "build/pde_solver/io",
        "build/pde_solver/lib", "build/pde_solver/mms", "build/pde_solver/operator",
        "build/pde_solver/solver", "build/pde_solver/system"
        ]
}

After a cmake build, all those directories are populated with the appropriate .mod files but the language server still can't seem to find them when I edit a source file. Am I missing something? Thanks.

hansec commented 5 years ago

This is the right place! The language server that this package uses parses the source files, not the module files. So you need to point the language server to the directories containing the source files.

pbrady commented 5 years ago

Thanks for the quick response!

Is there something special I need to do to add the source file locations?

After playing around with this some more it seems that when I open a file, it tries to compile the file and that's where it's running into issues with missing .mod files. Can I turn that feature off?

hansec commented 5 years ago

The "mod_dirs" variable actually specifies the source file directories. Sorry, that is a little confusing. By default though the server will search all directories below the root directory of your VSCode project.

As for the build errors. This package does not do any compilation or anything like that, so if you're getting errors related to compilation it must be coming from another package.

pbrady commented 5 years ago

Thanks @hansec. So I shouldn't need to specify the mod_dirs at all then.

Thanks for clarifying the build errors as well. Since I only have two extensions active I suspect the other one is the culprit..