vscode-fortran-support icon indicating copy to clipboard operation
vscode-fortran-support copied to clipboard

Code folding

Open imirzov opened this issue 5 years ago • 9 comments

folding

Dear Miguel, Thank you for awesome extension!

I faced with a code folding problem in VSCode for Fortran. VSCode folding is not language-aware and is based only on indentation. So it treats comments with exclamation marks as a code and doesn't account for continuation lines. As a result we have incorrect folding: please, have a look on attached image.

It is mentioned here that now due to new API language extensions can add language aware folding. Are you planning to implement it? Please, it would be very helpful.

imirzov avatar Jun 02 '19 11:06 imirzov

Official API release for contextual code folding https://code.visualstudio.com/updates/v1_22#_folding-provider-api

gnikit avatar Apr 12 '21 10:04 gnikit

So this can also be handled by the language-server see https://github.com/hansec/fortran-language-server/issues/166

gnikit avatar Dec 10 '21 23:12 gnikit

Official API release for contextual code folding https://code.visualstudio.com/updates/v1_22#_folding-provider-api

Can you explain how this can be used? Setting Modern Fortran as the Default Folding Range Provider in the Settings doesn't seem to help

digrapsas avatar Sep 19 '23 13:09 digrapsas

You would register a Folding Provider and then the language server (https://github.com/fortran-lang/fortls) would add a request for this that would include the start-end of scopes.

gnikit avatar Sep 19 '23 19:09 gnikit

You would register a Folding Provider and then the language server (https://github.com/fortran-lang/fortls) would add a request for this that would include the start-end of scopes.

Thank for the response, but that doesn't seem to work... I tried with Better Folding and The Folding Stuff extensions and only indenting seems to be taken into account for folding. If you have any other extension to suggest, le me know.

digrapsas avatar Sep 21 '23 14:09 digrapsas

@digrapsas I think you misunderstood my comment. The comment is aimed at developers not users. Pull requests to implement this are welcome and I would be happy to review the code and get it merged.

gnikit avatar Sep 21 '23 14:09 gnikit

@digrapsas I think you misunderstood my comment. The comment is aimed at developers not users. Pull requests to implement this are welcome and I would be happy to review the code and get it merged.

Oh, I see! Indeed I misunderstood. This is out of my current pack of skills, so I wouldn't be able to help any time soon... Feel free to remove the discussion if you feel like. Regards.

digrapsas avatar Sep 21 '23 14:09 digrapsas

@gnikit I thought I'd give it a try on my rhythm... I have forked the repos and built the default version, but when I open a project I get the following error:

screen

Then the extension seems to not be loaded and the previous version seems to be kept... I also get two errors when running the unit test, don't know if they are somehow related:

screen2

Any feedback would be appreciated.

digrapsas avatar Mar 29 '24 12:03 digrapsas

What is it that you are trying to achieve @digrapsas? Registering a LSP response in fortls for the folding range? If so, can you have a look at the contributing.md in the fortls repo and open a Discussion in that repo?

Let's keep the 2 issues (vscode and fortls) separate.

gnikit avatar Mar 29 '24 12:03 gnikit