Fortran syntax for kakoune editor

Made a start -

7 Likes

Welcome @freevryheid and thank you for this. I havenā€™t heard of Kakoune before this so I went to take a look and may even try it.

this is strictly free-form format and I donā€™t have plans right now to develop kak syntax for pre-f90 or fixed format files.

This seems sensible to me. With f90.kak, will Kakoune render a .f file without any syntax highlighting or will it assume free-form for that as well?

See relevant discussions on this here and here.

2 Likes

Yep, the top lines in the f90.kak file define the syntax. Detection is done by regex examining the filename extension. Currently the following is used:

hook global BufCreate .*\.(f90|f95|f03|f08) %{
    set-option buffer filetype fortran
}

To use .f as free-form, just append ā€œ|fā€ as in:

hook global BufCreate .*\.(f90|f95|f03|f08|f) %{
    set-option buffer filetype fortran
}

Also, I forgot to mention - kak can be extended as a language server client to the fortran-language-server.

2 Likes

Welcome @freevryheid. Awesome, thanks for doing this. Here is the link to the editor, I never heard of it before: https://kakoune.org/

Just what Iā€™ve was looking for! I just restarted my Fortran learning from a few years ago. I came to love kakoune for my main C++ job. Iā€™ll dig through the syntax files.

Have you considered opening a PR to add Fortran support ā€˜out of the boxā€™?
Iā€™ll probably spend the new few hours tackling the integration with fort-ls into kak-lsp. IIRC one issue is the recognition of % as a trigger for the completion engine.

Hi @MagBad welcome to fortran-lang, I was under the impression that kakoune was already able to integrate with fortls Editor Integration - fortls .
Is that not the case?

Welcome @MagBad

Good to see another kak user. I considered moving over to helix, which supports fortran ā€œout-of-the-boxā€ but missed kakouneā€™s client/server sessions.

The recent update to python broke my fortls installation. Iā€™m on archlinux and was using the fortls package (yay fortls). I caved and opted for pip install fortls. In archlinux this installs fortls to your ~/.local/bin folder, which kakoune cannot see (even though in the PATH). Trick was to move fortls to the /usr/bin folder.

Thank you!

IMHO the configuration has always been a bit tricky / unstable with kakoune, i.e. the language server might work great sometimes - and no so good in other situations. Since the highlighting etc is also lacking a bit, only thanks to @freevryheid we have some sort of highlighting.

I found his suggestion on switching to helix insightful! Iā€™ve been itching to test that one. The client/server sessions certainly are amazing, but since Iā€™m using tmux anyway thatā€™s not that big of a problem. At least at the moment.

But since I now donā€™t need to tinker with the kakoune LSP configuration, I can continue with the study of the ModernFortran book.