Hovering over a variable to show hints of its derived type

I am using Modern Fortran with fortls in vscode. When I hover over a variable

type(MyType) :: my_variable

the hovering text simply shows what type is the variable. I want the hovering text to show the text of the type MyType.

For instance, in the following code, I want for the text

A derived type that contains two integer components and a procedure.

to appear when I hover over the variable my_variable

module mModule

implicit none

!>
!! @brief A derived type that contains two integer components and a procedure.
type MyType
integer :: a
integer :: b

contains

   procedure :: myFunction

end type MyType

type(MyType) :: my_variable
contains

subroutine myFunction(this)
class(MyType), intent(inout) :: this

   this%a = 1
   this%b = 2

end subroutine myFunction

end module mModule

Is this possible?

If I’m not mistaken what you want is what happens when you hover over MyType. When you hover above the variable the behaviour is showing the type of the variable, but just because that variable was not documented. You could have two documented variables of the same type, what should it show?


type(MyType) :: var_1 !! This is var 1
type(MyType) :: var_2 !! This is var 2

Hovering over MyType shows the description of MyType (what you want to see) and hovering over each variable will show “This is var 1” and “This is var 2” respectively.

Yes, I see your point. I guess I would like the hints to remember me what methods var_1 have without having to go back to the declararion of the variable. Thank you for the prompt reply.