Modern Fortran not parsing the workspace .fortlsrc?


Debian Linux 12 with VS Code v-1.85.1, Modern Fortran Pre-Release v3.4.2024010301. fortls is installed through pipx and available in my $PATH. The linter is disabled for the moment.

Here are my *.code-workspace settings:

	"folders": [
			"path": "."
	"settings": {
		"cmake.automaticReconfigure": false,
		"cmake.parallelJobs": 4,
		"workbench.colorTheme": "Visual Studio Dark - C++",
		"workbench.preferredDarkColorTheme": "Abyss",
		"workbench.iconTheme": "vs-minimal",
		"workbench.sideBar.location": "right",
		"workbench.editor.closeOnFileDelete": false,
		"window.density.editorTabHeight": "compact",
		"files.autoSave": "onFocusChange",
		"editor.wordWrap": "on",
		"fortran.linter.compiler": "Disabled",
		"fortran.linter.compilerPath": "/usr/bin/gfortran",
		"fortran.logging.level": "Debug",
		"fortran.fortls.configure": "/home/ziad/CoursesTutorials/Fortran/NetCDF/.fortlsrc"

And here are the settings in my local .fortlsrc:

  "lowercase_intrinsics": false,
  "source_dirs": ["./**", "/usr/include"],
  "enable_code_actions": false,
  "nthreads": 4

The DEBUG output from VS Code is the following:

[DEBUG - 16:00:12] [lsp.client] Language Server arguments:
[DEBUG - 16:00:12] [lsp.client] Language Server version: 2.13.0

It’s clear that the .fortlsrc settings were not picked up by the server, since nthreads and enable_code_actions correspond to the VS Code settings, and there is no reporting of source_dirs.

Is fortls actually parsing the local .fortlsrc or not?

This is incorrect. The log message you posted explicitly states [lsp.client] ... these are the arguments passed by the client, i.e. vscode, and not the server, fortls. The configuration files are read by fortls not VSCode.

My question though is why are you not using a single source of truth and you define config options in multiple places? This is bound to lead to confusion.

Fair enough. Should I then conclude that the DEBUG output is done before fortls parses the workspace-local settings file? If so, is there a way to get the settings printed out just so I can verify whether they are correct? I looked at the fortls official docs and couldn’t find anything. That would be pretty useful BTW.

I agree that mixing sources is confusing, but not all relevant options can be set by file. For example, the linter settings need to be set on Modern Fortran side. If you can recommend a simple working configuration I would be very grateful.

BTW when I use Kate editor, skipping the configuration file and using the GUI configuration exclusively works for all modules. I had reported here as well.

The project does have a contributing guide, if you’d like to have a go at it :+1: : fortls/ at master · fortran-lang/fortls · GitHub

1 Like

I don’t think we have such a feature in fortls, I have gone ahead an opened an Issue on GitHub: Display input arguments to fortls in debug logs · Issue #348 · fortran-lang/fortls · GitHub

As @ivanpribec mentioned contributions for such things are welcome.

you should be able to use project local settings.json and define there both the linter settings and the fortls settings. In Modern Fortran I think we mirror almost all the fortls command line settings as explicit on/off options + we also have an option "fortran.fortls.extraArgs": [], which you can use to pass anything not explicitly defined in the VSCode settings menu.

Thanks for opening the issue on GitHub. I will certainly look at the contributing guide and give it a go.

Already aware of the many customization options in VS Code. Frankly, I think it is too much, especially when combined with the workspace customization features. I’ll be testing exclusive solutions, like settings in either Modern Fortran or local .fortlsrc.