What do you want out of a Fortran IDE the most?

I have recently created a Fortran IDE as my first big project for me. this is the github repo for it if you wan to look at it. But I had asked on reddit what I should do to have another goal for this. The main purpose of this project is to basically be a learning adventure for me so I can get better at programming. I was told something really important is a plugin API. My question is, what specifically would you want to see come of that. What kind of plugins would you want to see. I’m fairly new to this and any help and feedback is greatly, greatly appreciated.

7 Likes

Integration to Fortran references like intrinsics descriptions and Fortran documentation, integration with fpm and the to-be-released fpm registry including searching by description for existing code, and a plugin that uses AI-like utilities to create, locate, or translate code based on a textual description, integrated into at least the basic functionality of source code management systems like mercurial and git with the ability to automatically update the fpm manifest file fpm.toml; incorporating markdown descriptions of the code alongside the code and the ability to output the resulting projects as packages compatible with apt(1) and other common linux package distribution systems. Now if you wanted to create a more complex interface I could expand on that :wink:

I would like to be able to mark a routine and export it straight into a discourse discussion with the code hidden if > 40 lines with an option to have a link that places the code into an on-line Fortran service like the fortran-lang playground to make asking the Fortran community questions more easily in a form where the Fortran community can click on the code when it is a runnable code and run it with freely available compilers (hopefully the latest versions); thus integrating the IDE, fpm, Fortran Discourse and freely available Fortran resources like the fortran-lang documentation and vendor fortran documentation.

So thinking big about what I would really like, and then starting with something do-able I might suggest a pull-down of the Fortran intrinsics that would place a call at the current location with an option to click on the intrinsic name and go to a description of it.

For easily discoverable reasons I might suggest starting with the fpm plugin fpm-man. A single-file source is at

https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fman.f90

4 Likes

This is such an amazing answer. Thank you so much! Like I said before, I’m still getting good at
C++ but I’m happy to have so decent goals now. If you ever want to contribute to the project let me know, I’d be happy to work along side you!

While I suspect many people will read this and think “well that’s some pie in the sky”, I see absolutely no reason any of it couldn’t be achieved. Every bit of it has at least some proof of concept, or prior art to draw on, even if it’s never been done for Fortran specifically. If only there was enough motivation and resources to put towards it, this would make for an incredible ecosystem and development environment. If it were me, I think biggest ROI would come from

6 Likes

I’m guessing you are using this project to get your hands dirty and learn by doing which is great. I’m just thinking that if you would like to have a larger impact and take those nice ideas to a larger public wouldn’t it be better to maybe stand on top of VS Code (different from MVS2022) and the tooling’s that have been produced by the community such as Modern Fortran and fortls and push them further or add missing ones from all the ideas given?

The other thing is that one seldomly works with a single language in todays dev landscape. My feeling is that a Fortran only IDE is not necessarily the best approach. I personally preferer VS Code over any other IDE because with the plug-in approach, you can have everything needed from linters to debuggers for basically every language you could think of. VS Code has the same interface on Windows and Linux, which is also nice when working on cross-platforms projects.

8 Likes

Things which matter the most to me

  • robust syntax highlighting, including OpenMP and OpenACC, and potentially fypp
  • hyper-links between procedures and modules for “jump-to”
  • built-in reference for intrinsic procedures

Some Fortran-specific ideas I’ve though about it, but not seen yet in practice

  • connections between modules and submodule, so that the interfaces remain consistent
  • related to submodules, a switch to make the module read-only (meaning the ABI is stable in the context of semantic versioning);
  • expansion of included files (or at least being able to jump to them)
  • visual aids (guides) for legacy constructs involving goto’s
  • visual aids for recognizing array access patterns
  • ways of displaying module hierarchies and callgraphs

I also really like some of the things available in Compiler Explorer, such as the control flow graph visualization.

I also find MATLAB’s Customized Code suggestions and Completions can be helpful at times:

image
(image borrowed from the MATLAB documentation)

For example in Fortran, as you type the arguments, it could display the type, kind, rank and attributes. If specified somewhere it could also show a description of the expected dummy argument.

4 Likes

This is a great way to get familiar with all sorts of cool CS concepts. In terms of a usable Fortran IDE/Editor I pretty much agree with @hkvzjal, but I am heavily biased since I am also the author of these tools. For inspiration in your own project you might want to look at the VS Code features page

A lot of the modern editors’ functionality comes from using the Language Server Protocol, where the server provides the client i.e. the editor, with information like which file should you peek or where to find the implementation of a function foo.
However, you can achieve a lot of these tasks like completion suggestions or syntax highlighting without ever touching LSP (I believe Simply Fortran does this). Feel free to use our syntax highlighting grammar files, they are MIT licensed.

Best of luck!

Than you for this! I have been planning for awhile to put in an LSP but I can’t really figure how because all the info I could find is meant for something like Vim or VSCode, but I will figure it out eventually.

Re: how do I add Modern Fortran to my custom IDE? · fortran-lang/vscode-fortran-support · Discussion #1092 · GitHub

I don’t know if this question is asked often. I’ve made an IDE for Fortran for fun to try and give me a big project to work on. I used ImGui and SFML to make it but now I want to add Modern Fortran for systax highlighting, code completion, etc. same with FortLS. All the tutorials I’ve found online is everybody doing it for Vim or VSCode but those, I feel, can’t really help me. I’m still new to most of this so if you could help me out, that’d be great!

This is my personal take, so take things with a grain of salt.


When tackling a large project/feature I would suggest you follow a practice in the software industry that is referred to as Elephant Carpaccio. It essentially means you break down a large, complex task into small, manageable bits. This helps with delivering quickly features and also not getting overwhelmed with the amount of work (among many other things).

Since you are developing your code editor in C++ implementing some of these features will unfortunately be an uphill battle, since most commonly used code editors tend to be written in Javascript/Typescript, Java, Lua, etc., so the information available online is skewed in their favour.

That being said there are many great, open source, code editors/IDEs that are written in C++. Here are the ones I know off the top of my head:

Maybe you can take a page out of their book and see how they have implemented syntax highlighting, a plugin architecture and even maybe their LSP client support.

Circling back to what features you could add to your project, IMO a good start would be Fortran Intrinsics documentation support. For that you would need:

  • A way of getting the position of the cursor (file URI, line number, column number).
  • A very basic lexer, you can use simple regular expressions, to extract the whole word of where the cursor is on.
  • A serialised version of the Fortran intrinsics. You can get that from here, it’s MIT Licensed. (Note: type: 2 refers to a Fortran subroutine, type: 3 refers to a Fortran function).
  • A JSON library to read and traverse the serialised intrinsics. I like either GitHub - nlohmann/json: JSON for Modern C++ or GitHub - Tencent/rapidjson: A fast JSON parser/generator for C++ with both SAX/DOM style API. They both have great docs and are easy to use.
  • A pop-up window to display the intrinsic’s documentation.
  • A key binding to trigger the action.

Linting (i.e. mock compiling) using gfortran is another possibility, but slightly more complicated.
The short summary of this feature is, use gfortran to mock compile your source file upon save, capture its output, and display that in an output dialog box or inline in your source file.

Another big feature would be adding syntax highlighting (potentially using TextMate grammar files). That is somewhat harder and would probably help if you tried to understand how the other C++ code editors do it before starting.

Personally, I wouldn’t start with something as complicated as trying to implement a LSP client or completion suggestions. Don’t get me wrong they are cool features, but it is easy to get overwhelmed with the amount of existing infrastructure they require.

Hope this helps.

1 Like

@everythingfunctional @urbanjost I had been working on it discovery of packges for fpm, I have added a functionality to search packages in the fpm registry from the cli from descriptions, tags, keywords and added paging . can you provide some feedback on this implementation (output implementation is very poc) and what could be added to it (I will be working on adding searching of local packages soon).

fork branch: GitHub - henilp105/fpm at fpm-search

fpm search --query m --page 2 # page is an optional paramter.

I have not gotten to far into the code, but did pull and built it. It is getting quiet afield of the original OP question about IDEs even though it relates to integrating fpm(1) into an IDE I suppose. I would definitely want the IDE to include access to the fpm search sub-command. So just some quick first impressions or questions

WHAT IS SEARCHED

Can it read from local registry mirror on offline systems?

Need at option to read metadata from local fpm.toml files as well.

Should there be a way to specify a URI for a registry or will the
search be based on the current path for satisfying registered dependencies
found in the manifest fpm.toml?

PLUGIN VERSUS INTEGRATED INTO FPM

This implementation appears integrated into fpm monolithically yet all
the functionality is independent of fpm. That would suggest the search
sub-command should be a separate application and/or a plugin.

Using a plug-in is suggested so as not to break the single-file fpm build
unneccessarily and to allow for rapid development and use of additional
external dependencies without bloating fpm.

A search string should allow globbing or regular expressions and optional
case-insensitivity.

PROTOTYPE

Should add a description of the command including unimplemented proposed
features so everyone can see what the final result is currently proposed
to be with unimplimented or proposed features being indicated as such.

Currently the --help switch produces help text for the clean subcommand

So if the current syntax is
fpm search --query --page

What fields are searched? Description, author, license, ??

Possible additional switches:
–registry URI
–force-download # locate and pull down, perhaps with an option to
# install locally in a package or globally in a local registry mirror.
–namespace LIST_OF_NAMES_TO_SEARCH
–lookin {description,author,keywords,…}
–since YYYY-MM-DD # only search packages added or changed after date

Perhaps a list of manifest fields to output should be allowed but the --verbose
field should generate a longer list of output.

Consider making output easily parseable as NAMELIST or JSON/YAML/TOML/XML output.
NAMELIST is Fortranik and is very easily read in converted to other formats with
a simple filter program and is robust as it is defined in the standard.

SEE ALSO

There is previous art. @brocolis created a fpm-search tool for the initial registry.
There are several iterations. The last iteration had been simplified but previous
versions included color highlighting of search matches; and regular expressions as
search terms. Similar sub-commands exist in NPM, cargo, …

1 Like

Thanks @urbanjost , These are great insights. I will be adding these features by the weekend.

I will be working on supporting both local mirror and fpm-registry. I will be adding support to search from a different registry URI and local registry.

All the fields like author, package name, namespace, description, keywords, tags are searched for a query.

will be adding them by this weekend.

I will have to refer for namelist format, I have added support for JSON/TOML format.

@certik Can you please split this thread for feedback. (as it is getting afield of original OP question).

1 Like

I have implemented a new iteration of this fpm search, it supports various parameters like:

  • query (can be used to search in description/README.md)
  • package (search by package name)
  • page (page number of the results) (default: 1)
  • registry (URL of custom registry) (default: fpm-registry)
  • namespace (search by namespace)
  • license (search by license)
  • limit (limit by number of results) (default: 10)
  • sort-by (sort the results by: “name” (package name), “author”, “createdat”, “updatedat”, “downloads” ) (default: name)
  • sort ( ascending: ‘asc’ , descending: ‘desc’) (default: ascending)

The parameters: namespace, package, license, query are case insensitive.

All these parameters are supported for fpm-registry (local registry search part is WIP).

fpm search --query m --page 1 --package p --namespace n --license mit --limit 100 --sort-by name  --sort desc --registry https://fpm-registry.vercel.app # any custom registry url can be used)

Github branch: GitHub - henilp105/fpm at fpm-search

Please feel free to provide feedback on the current implementation.

1 Like