Fortran language server (fortls) error in VSCode (Windows)

Viewed 1649

VSCode keeps showing the error notification,

Error launching fortls: Please check that all selected options are supported by your language server version. Source: FORTRAN IntelliSense (Extension)

I have fortls installed and provided the path in settings.json as,

"fortran-ls.executablePath": "C:\\Users\\xxxxx\\Anaconda3\\Scripts\\fortls.exe"

I am not sure what options are not supported by the fortran language server version or how to change the version. Also, most of the features of Modern Fortran and Fortran IntelliSense extensions are not working, is this for not being able to use fortran language server? Sorry, I'm new to VSCode. Here's my full settings.json file in case you want to have a look for what options are not being compatible,

       "python.defaultInterpreterPath": "C:\\Users\\xxxxx\\Anaconda3\\python.exe",
  "fortran-ls.executablePath": "C:\\Users\\xxxxx\\Anaconda3\\Scripts\\fortls.exe",
  "editor.codeLens": false,
  "editor.formatOnSave": true,
  "editor.formatOnType": true,
  "diffEditor.codeLens": true,
  "editor.formatOnPaste": true,
  "editor.quickSuggestionsDelay": 1000,
  "workbench.colorTheme": "Visual Studio Dark - C++",
  "editor.minimap.maxColumn": 200,
  "editor.fontSize": 16,
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "editor.rulers": [
    132
  ],
  "workbench.colorCustomizations": {
    "editorRuler.foreground": "#458cff"
  },
  "workbench.iconTheme": "vscode-icons",
  "fortran.formatting.formatter": "fprettify",
  "editor.quickSuggestions": {
    "other": "on",
    "comments": "on",
    "strings": "on"
  },
  "fortran.linter.compiler": "gfortran"

Thank you so much!

2 Answers

I have found a temporary solution to this problem but I don't clearly understand it. I believe the problem was occurring because I had both fortran-language-server (LSP using Python (2.7+ or 3.0+)) and fortls (LSP using Python (3.7+).) installed. For some reason, uninstalling fortls (i.e., keeping fortran-language-server) works only, not the other way around. They both create the same named executable and somehow that was causing trouble for Fortran IntelliSense extension. My guess is Fortran IntelliSense only works with fortran-language-server, not the updated fortls. Please let me know if anyone has some explanation on why's this happening/if my guess is correct. Thank you!

Update: My guess seems to be correct, the author of fortls says Fortran IntelliSense was made to work with only fortran-language-server. And Modern Fortran in conjunction with fortls should be enough to provide IntelliSense features. Here is his original post.

I am the author of fortls and Modern Fortran and as you pointed out fortls can work with Modern Fortran without FORTRAN Intellisense, so you can go ahead and uninstall that from VS Code.

As for fortls vs fortran-language-server, basically fortls is the continuation of the project.

For more info check out the fortls + VS Code documentation: https://gnikit.github.io/fortls/editor_integration.html#visual-studio-code

Related