Modern Fortran for VS Code v3.0.X final Pre-Release

I am mostly done with v3.0 of Modern Fortran for VS Code. I have gone ahead and released a Pre-Release version (with our old publisher ID krvajalm, probably for the last time) for people to test. There will be an official release memo when v3.0 comes out, but nonetheless here is a summary of the main changes:

  • Added native integration with language server fortls. Allowing for access to all fortls’ options through the VS Code settings. The settings are in constant sync with the language server so changes can be propagated to server without needing to restart VS Code.
  • Added the option to restart the language server from the command pallet
  • Added single file support and multi-root workspace support with the language server.

IMPORTANT:
By default the language server will detect and then parse ALL Fortran files from the root directory. The root directory in VS Code is the directory where VS Code is opened from; in Linux and Mac the default dir is usually $HOME.

This means that if you open an empty VS Code instance and then open a single Fortran file, the language server will scan and parse your entire $HOME, which is terribly slow and very memory intensive.

There are ways to circumvent this, like setting in your settings.json

   "fortran.fortls.extraArgs": ["--source_dirs", "."],

but I am still looking for more elegant solutions that would not affect file autodiscovery in existing projects.

  • Added Linting support for Intel’s ifort
  • Fixed a critical bug that caused VS Code to crash if a line contained more than +1k characters
  • Fixed bugs on Windows that would cause our formatters to fail
  • Fixed hovering messages while debugging nested user defined variables e.g. foo%bar%dummy hovering over bar and dummy will now yield the correct output whilst debugging.

I also updated the README and the logos of the extension to match Fortran Langs style.

There are still a few minor things that need to be added like a walkthrough and some minor bug fixes, but I think in general v3.0 is mostly done. The new version will be the first release under our new publisher ID, the change should be flawless for the end user but do not be alarmed if you see fortran-lang instead of krvajalm in your extension manifest.

Have a go at the pre-Release. Let me know either here or on GitHub if you come across any bugs or if there are any features that you would like to see being added in the future.

10 Likes

Note, when I switch to pre-release, I get this warning:

Deprecated settings have been detected in your settings. 
Please update your settings to make use of the new names. 
The old names will not work.

Source: Modern Fortran (Extension)

It isn’t clear to me what settings this is referring to…

1 Like

If you open your settings.json you will see some settings starting with fortran. being underlined with yellow. These are the deprecated settings
(The settings UI shows something similar)

Might be a good idea to offer users to open their settings for edit

1 Like

Ah! Thank you! I didn’t notice that.

Hi gnikit,

Your work is great, however I am having problem launching fortls with Modern Fortran extension in vscode.

The setup I used is:

  1. macOS
  2. Modern Fortran version v3.0.2022050508
  3. fortls version 2.7.0

And I am connecting to a remote server using ssh extension.

With this setup, when I tried open an f90 file to launch the fortls, the following error occurs:


[“INFO” - 8:34:37 PM] Fortran Language Server
[“INFO” - 8:34:38 PM] Initialising Language Server for file: /home/yz167/GLX15/code/RCM-E/rcm-e.f90
[Error - 8:34:38 PM] Server initialization failed.
Message: ‘list’ object is not callable
Code: -32603
[object Object]
[Error - 8:34:38 PM] Starting client failed
Message: ‘list’ object is not callable
Code: -32603
[object Object]
error handling request {‘jsonrpc’: ‘2.0’, ‘id’: 0, ‘method’: ‘initialize’, ‘params’: {‘processId’: 33435, ‘clientInfo’: {‘name’: ‘Visual Studio Code’, ‘version’: ‘1.67.2’}, ‘locale’: ‘en’, ‘rootPath’: None, ‘rootUri’: None, ‘capabilities’: {‘workspace’: {‘applyEdit’: True, ‘workspaceEdit’: {‘documentChanges’: True, ‘resourceOperations’: [‘create’, ‘rename’, ‘delete’], ‘failureHandling’: ‘textOnlyTransactional’, ‘normalizesLineEndings’: True, ‘changeAnnotationSupport’: {‘groupsOnLabel’: True}}, ‘didChangeConfiguration’: {‘dynamicRegistration’: True}, ‘didChangeWatchedFiles’: {‘dynamicRegistration’: True}, ‘symbol’: {‘dynamicRegistration’: True, ‘symbolKind’: {‘valueSet’: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, ‘tagSupport’: {‘valueSet’: [1]}}, ‘codeLens’: {‘refreshSupport’: True}, ‘executeCommand’: {‘dynamicRegistration’: True}, ‘configuration’: True, ‘workspaceFolders’: True, ‘semanticTokens’: {‘refreshSupport’: True}, ‘fileOperations’: {‘dynamicRegistration’: True, ‘didCreate’: True, ‘didRename’: True, ‘didDelete’: True, ‘willCreate’: True, ‘willRename’: True, ‘willDelete’: True}}, ‘textDocument’: {‘publishDiagnostics’: {‘relatedInformation’: True, ‘versionSupport’: False, ‘tagSupport’: {‘valueSet’: [1, 2]}, ‘codeDescriptionSupport’: True, ‘dataSupport’: True}, ‘synchronization’: {‘dynamicRegistration’: True, ‘willSave’: True, ‘willSaveWaitUntil’: True, ‘didSave’: True}, ‘completion’: {‘dynamicRegistration’: True, ‘contextSupport’: True, ‘completionItem’: {‘snippetSupport’: True, ‘commitCharactersSupport’: True, ‘documentationFormat’: [‘markdown’, ‘plaintext’], ‘deprecatedSupport’: True, ‘preselectSupport’: True, ‘tagSupport’: {‘valueSet’: [1]}, ‘insertReplaceSupport’: True, ‘resolveSupport’: {‘properties’: [‘documentation’, ‘detail’, ‘additionalTextEdits’]}, ‘insertTextModeSupport’: {‘valueSet’: [1, 2]}}, ‘completionItemKind’: {‘valueSet’: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}, ‘hover’: {‘dynamicRegistration’: True, ‘contentFormat’: [‘markdown’, ‘plaintext’]}, ‘signatureHelp’: {‘dynamicRegistration’: True, ‘signatureInformation’: {‘documentationFormat’: [‘markdown’, ‘plaintext’], ‘parameterInformation’: {‘labelOffsetSupport’: True}, ‘activeParameterSupport’: True}, ‘contextSupport’: True}, ‘definition’: {‘dynamicRegistration’: True, ‘linkSupport’: True}, ‘references’: {‘dynamicRegistration’: True}, ‘documentHighlight’: {‘dynamicRegistration’: True}, ‘documentSymbol’: {‘dynamicRegistration’: True, ‘symbolKind’: {‘valueSet’: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, ‘hierarchicalDocumentSymbolSupport’: True, ‘tagSupport’: {‘valueSet’: [1]}, ‘labelSupport’: True}, ‘codeAction’: {‘dynamicRegistration’: True, ‘isPreferredSupport’: True, ‘disabledSupport’: True, ‘dataSupport’: True, ‘resolveSupport’: {‘properties’: [‘edit’]}, ‘codeActionLiteralSupport’: {‘codeActionKind’: {‘valueSet’: [’’, ‘quickfix’, ‘refactor’, ‘refactor.extract’, ‘refactor.inline’, ‘refactor.rewrite’, ‘source’, ‘source.organizeImports’]}}, ‘honorsChangeAnnotations’: False}, ‘codeLens’: {‘dynamicRegistration’: True}, ‘formatting’: {‘dynamicRegistration’: True}, ‘rangeFormatting’: {‘dynamicRegistration’: True}, ‘onTypeFormatting’: {‘dynamicRegistration’: True}, ‘rename’: {‘dynamicRegistration’: True, ‘prepareSupport’: True, ‘prepareSupportDefaultBehavior’: 1, ‘honorsChangeAnnotations’: True}, ‘documentLink’: {‘dynamicRegistration’: True, ‘tooltipSupport’: True}, ‘typeDefinition’: {‘dynamicRegistration’: True, ‘linkSupport’: True}, ‘implementation’: {‘dynamicRegistration’: True, ‘linkSupport’: True}, ‘colorProvider’: {‘dynamicRegistration’: True}, ‘foldingRange’: {‘dynamicRegistration’: True, ‘rangeLimit’: 5000, ‘lineFoldingOnly’: True}, ‘declaration’: {‘dynamicRegistration’: True, ‘linkSupport’: True}, ‘selectionRange’: {‘dynamicRegistration’: True}, ‘callHierarchy’: {‘dynamicRegistration’: True}, ‘semanticTokens’: {‘dynamicRegistration’: True, ‘tokenTypes’: [‘namespace’, ‘type’, ‘class’, ‘enum’, ‘interface’, ‘struct’, ‘typeParameter’, ‘parameter’, ‘variable’, ‘property’, ‘enumMember’, ‘event’, ‘function’, ‘method’, ‘macro’, ‘keyword’, ‘modifier’, ‘comment’, ‘string’, ‘number’, ‘regexp’, ‘operator’], ‘tokenModifiers’: [‘declaration’, ‘definition’, ‘readonly’, ‘static’, ‘deprecated’, ‘abstract’, ‘async’, ‘modification’, ‘documentation’, ‘defaultLibrary’], ‘formats’: [‘relative’], ‘requests’: {‘range’: True, ‘full’: {‘delta’: True}}, ‘multilineTokenSupport’: False, ‘overlappingTokenSupport’: False}, ‘linkedEditingRange’: {‘dynamicRegistration’: True}}, ‘window’: {‘showMessage’: {‘messageActionItem’: {‘additionalPropertiesSupport’: True}}, ‘showDocument’: {‘support’: True}, ‘workDoneProgress’: True}, ‘general’: {‘regularExpressions’: {‘engine’: ‘ECMAScript’, ‘version’: ‘ES2020’}, ‘markdown’: {‘parser’: ‘marked’, ‘version’: ‘1.1.0’}}}, ‘trace’: ‘off’, ‘workspaceFolders’: None}}
Traceback (most recent call last):
File “/home/yz167/pkg/miniconda/lib/python3.9/site-packages/fortls/langserver.py”, line 1505, in _load_config_file
config_dict = json.load(jsonfile)
File “/home/yz167/pkg/miniconda/lib/python3.9/json/init.py”, line 293, in load
return loads(fp.read(),
File “/home/yz167/pkg/miniconda/lib/python3.9/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
File “/home/yz167/pkg/miniconda/lib/python3.9/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/home/yz167/pkg/miniconda/lib/python3.9/json/decoder.py”, line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/yz167/pkg/miniconda/lib/python3.9/site-packages/fortls/langserver.py”, line 166, in handle
resp = handler(request)
File “/home/yz167/pkg/miniconda/lib/python3.9/site-packages/fortls/langserver.py”, line 193, in serve_initialize
self._load_config_file()
File “/home/yz167/pkg/miniconda/lib/python3.9/site-packages/fortls/langserver.py”, line 1529, in _load_config_file
self.post_messages(
TypeError: ‘list’ object is not callable


Could you help me with this?

Many thanks.

1 Like

Hi @ChiseiMinamoto welcome to the community!

From the looks of it the configuration file i.e. ‘.fortls’ seems to contain invalid json syntax

Expecting property name enclosed in double quotes: line 2 column 1 (char 2)

so fortls cannot initialise. See the fortls documentation for using a configuration file: https://gnikit.github.io/fortls/options.html#configuration-using-a-file

There was a related bug in v2.7.0 that fatal errors such as the one you reported were not properly displayed and that basically makes the rest of the logs you posted. This has now been fixed in v2.8.0!

Thanks, it now works just fine!

@gnikit do you know how to turn off all suggestions with the Modern Fortran vscode extension? For example, when I type “func”, a suggestion pops up for making a function. I want to disable all these suggestions. Thanks!

I don’t think disabling autocomplete completely is possible.

These 2 should somehow limit the autocomplete suggestions but unfortunately there is no way to completely turn off the feature AFAIK.

1 Like