VSCode (Windows)中Fortran语言服务器(fortls)错误



VSCode一直显示错误通知,

启动fortls错误:请检查您的语言服务器版本是否支持所有选择的选项。来源:FORTRAN智能感知(扩展)

我已经安装了fortls,并在设置中提供了路径。json,

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

我不确定fortran语言服务器版本不支持哪些选项或如何更改版本。另外,现代Fortran和Fortran智能感知扩展的大部分功能都不起作用,这是因为不能使用Fortran语言服务器吗?对不起,我是VSCode的新手。这是我的全部设置。如果你想查看哪些选项不兼容,请查看

"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"

非常感谢!

我已经找到了这个问题的临时解决方案,但我不清楚它。我认为问题之所以发生,是因为我安装了fortran-language-server(使用Python(2.7+或3.0+)的LSP)和fortls(使用Python(3.7+)的LSP)。出于某种原因,卸载forts(即,保留fortrans -language-server)只能起作用,而不是反过来。它们都创建了相同名称的可执行文件,不知何故,这给Fortran智能感知扩展带来了麻烦。我猜Fortran智能感知只适用于Fortran -language-server,而不是更新后的Fortran。请让我知道,如果有人有一些解释为什么会发生这种情况/如果我的猜测是正确的。谢谢你!

更新:我的猜测似乎是正确的,fortls的作者说Fortran IntelliSense只适用于Fortran -language-server。现代Fortran结合fortls应该足以提供智能感知功能。这是他的原文。

我证实了mo_sal在他的案例中观察到的情况。

我在我的vscode上安装了Modern-Fortran扩展(v3.4.2022111811),它需要指向可执行fortls的路径。我需要通过安装

使Modern-Fortran工作
pip3 install fortran-language-server --user

~/.local/bin/文件夹中出现一个名为fortls的可执行文件。如果我做了

pip3 install fortls --user

然后相同的可执行文件出现在相同的文件夹中,但我的vscode一直弹出"错误启动fortls"消息。

我是fortls和Modern Fortran的作者,正如你指出的,fortls可以在没有Fortran智能感知的情况下与Modern Fortran一起工作,所以你可以继续从VS Code中卸载它。

对于fortlsfortran-language-server,基本上fortls是项目的延续。

更多信息请查看fortls+ VS Code文档:https://fortls.fortran-lang.org/editor_integration.html#visual-studio-code

最新更新