Fortls testing the new hover messages

The hover messages of the Fortran Language Server fortls are about to drastically change from displaying Fortran source code to displaying Markdown. There is a standing PR (feat: Change hover to use MarkupContent by gnikit · Pull Request #213 · gnikit/fortls · GitHub) that I will try and finalise today. I would like to ask for users to try and test it on their local editor

  • to see how the new hover messages are displayed correctly. I am not sure if all editors have support for Markdown hover messages and at this point the changes I’ve made are not backwards compatible.
  • to catch any errors in parsing or make suggestions about the new syntax.

Here is a sneak peak of how standard FORD syntax will be displayed (Doxygen is pending)

Install PR branch

Requirements

  • Python 3.7>=
  • git
git clone -b gnikit/issue45 https://github.com/gnikit/fortls.git
cd fortls && pip install -e .

List of supported editors with config instructions Editor Integration - fortls (please ignore Atom)

6 Likes

@gnikit , hello!
I tried to test local build of fortls from gnikit/issue45 branch with the code of fortran stdlib project.
The result depends on documentation comment style (!! or !>) used in file:

  1. stdlib_array.f90pure subroutine logicalloc hover looks OK;
  2. stdlib_array.f90pure function trueloc and pure function falseloc hover just displays LOGICAL without additional info (like with fortls-2.13.0);
  3. stdlib_stringlist_type.f90pure function get_string_idx_wrap the hover display info about function.
  4. stdlib_hashmaps.f90function total_depth hover displays info;
  5. stdlib_hashmaps.f90subroutine init_map - the scrollbar appears in the hover window, the scrolling looks working.

P.S.
I built and installed fortls via system package manager instead of using pip directly.

1 Like

Thanks for taking the time @band-a-prend to test it. As you pointed out the style matters !! or !>. The problem is that FORD documentation can look a lot like Doxygen, so creating a parser that works for both is rather tricky.

I will have a look at the stdlib examples you mentioned and see what can be done.
I will also try and make the doc parser more generic.

In your opinion, would you like to see anything else in the hover window?

For completeness, could you also mention what code editor you are using?

@band-a-prend if you/stdlib change the trueloc docstring from

  !> Version: experimental
  !>
  !> Return the positions of the true elements in array.
  !> [Specification](../page/specs/stdlib_array.html#trueloc)

Into

  !> Version: experimental
  !! 
  !! Return the positions of the true elements in array.
  !! [Specification](../page/specs/stdlib_array.html#trueloc) 

Then I think it should work. On my phone so I can’t verify it at the moment though. For doxygen style docstring (comment before declaration) fortls expects them to start with !>. Consecutive lines in the docstring should start with !! .

For ford style docstrings (comment after declaration) then all lines should start with !! .

@gnikit ,

In your opinion, would you like to see anything else in the hover window?

The FORD math expressions support will be excellent (I don’t know is it supported now). But there is a huge problem that FORD (it actualy mainly uses MathJax style with some restriction) doesn’t support inline expressions via $ so it isn’t directly compatible with python-markdown style. Maybe it could be transfered internaly before displaying. But it’s future feature request.

For completeness, could you also mention what code editor you are using?

I used Visual Studio Code 1.72.2 editor for previewing fortls new markdown feature.

@plevold
Thank you for notice. I rechecked the FORD documentation and it should be work as default syntax. I could try it later.

I tried it out on a codebase that uses the second style of docstring as above, and it works well.

VSCode 1.72.2 and Python 3.10