Open certik opened 3 years ago
Here's the one I use, I think it's popular: https://github.com/hansec/fortran-language-server
Nice! How accurate is it? Is it able to find definitions in other files and in dependencies? I think that is what fpm could provide.
I tried to install the extension: https://marketplace.visualstudio.com/items?itemName=hansec.fortran-ls in VSCode, but it does not to anything, I can't get it to work. I'll report it to them.
I don't know how accurate it is, I only used that extension for Fortran. I'm a basic user of it and use only autocomplete and hover-on definitions. They work and are good enough for me, from other source files too. I didn't customize the extension in any way.
You need to pip install fortran-language-server --user
first, maybe that's the problem.
I mainly use vs code. The existing fortran-language-server
is written based on python, which can provide me with good code hints and definition jumps, provide all methods and variables (derived types, etc.) in a given module in the Outline section in the left.
There are at least three vs code plugins for Fortran worth paying attention to:
In addition, Intel Visual Fortran can only be used in Visual Studio before. Intel OneAPI has recently begun to support the use of OneAPI in VS Code, but currently more support for C and C++, Fortran may not be planned.
Thanks for that @zoziha. I tried to install the Python pip install fortran-language-server
, with and without --user
. The problem is probably on my side, but at the same time things should just work and they don't for me. :(
Hi all, I thought I would add my 2 cents on this issue and maybe help a bit. Full disclosure I am the co-author of Modern Fortran in VS Code and the fortls
Language Server (a fork of the original fortran-language-server).
@certik I think the reason for Modern Fortran/FORTRAN Intellisense not working out of the box was a bad release I authored around that time. All of that in an attempt to unify the VS Code extension with the fortls
Language Server, to make it work out of the box (yeah I know, pretty ironic). I think since then, most major issues have been fixed.
If one installs the latest version of Pre-Release Modern Fortran (that should be v3.0.20220119
) everything should work out of the box. Modern Fortran will then prompt you to install fortls
. If you already have installed the fortran-language-server
you might have to uninstall it or install fortls
and point Modern Fortran via the setting "fortran.fortls.path"
to the fortls
binary.
For now we still support fortran-language-server
in Modern Fortran, hence why I stuck with the name fortls
, but given how buggy it is, the numerous missing features + how annoying it is to configure and interface with Modern Fortran in typescript I would recommend people to switch to fortls
. My plan is to release Modern Fortran v3.0.0 with support for both and then drop support for fortran-language-server in v3.1.0.
This effectively makes the use of FORTRAN Intellisense and fortran-language-server redundant.
You can further configure fortls
via a json
file see docs
I would be very keen to add support for fpm
(and also cmake
)
Please feel free to ask questions/open issues on both Modern Fortran and fortls repos. I seem to be quite a bit siloed from people that are experiencing issues with these tools. I only stumbled on this particular issue by accident. I also went ahead and signed up to the fortran-lang Discourse if people prefer to reach me that way.
Is there one already?
I would like the language server to provide all methods and variables (derived types, etc.) in a given module in the Outline section in the left. It should be fast (immediate). The C++ language server updates quite slowly, and I think Fortran can be made instantaneous because the language is simpler.
The language server should work with fpm to correctly and automatically resolve all project files and dependencies (!) and when use pres F12, it would find the definition in any file (whether project file or dependency) and open it. Thanks to fpm, this should just work and be 100% robust.
In terms of compiler support to get this working, what exactly is needed? If somebody has experience with the language server protocol, please get in touch.
This is a long term project, but I think it is important to get started, getting it working perhaps on single file projects and then go from there.