# Fortran syntax for kakoune editor

**URL:** <https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728>\
**Category:** Announcements\
**Created:** [February 18, 2021, 8:32pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728 "2021-02-18T20:32:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![freevryheid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/freevryheid/32/357_2.png) [@freevryheid](https://fortran-lang.discourse.group/u/freevryheid)\
**Post date:** [February 18, 2021, 8:32pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/1 "2021-02-18T20:32:50Z")

</div>

Made a start -

> **[freevryheid/f90.kak](https://github.com/freevryheid/f90.kak)**
>
> modern fortran syntax for kakoune editor. Contribute to freevryheid/f90.kak development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![milancurcic](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/milancurcic/32/2_2.png) [@milancurcic](https://fortran-lang.discourse.group/u/milancurcic)\
**Post date:** [February 18, 2021, 9:09pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/2 "2021-02-18T21:09:06Z")

</div>

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](https://fortran-lang.discourse.group/t/fortran-com-site/637/26) and [here](https://github.com/fortran-lang/fpm/issues/363).

---

<div class="post-metadata">

**Author:** ![freevryheid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/freevryheid/32/357_2.png) [@freevryheid](https://fortran-lang.discourse.group/u/freevryheid)\
**Post date:** [February 18, 2021, 10:52pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/3 "2021-02-18T22:52:27Z")

</div>

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:

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

```

To use .f as free-form, just append “|f” as in:

```auto
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.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [February 18, 2021, 11:02pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/4 "2021-02-18T23:02:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MagBad](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@MagBad](https://fortran-lang.discourse.group/u/MagBad)\
**Post date:** [May 21, 2023, 1:23pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/5 "2023-05-21T13:23:41Z")

</div>

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](https://github.com/kak-lsp/kak-lsp). IIRC one issue is the recognition of `%` as a trigger for the completion engine.

---

<div class="post-metadata">

**Author:** ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)\
**Post date:** [May 21, 2023, 6:56pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/6 "2023-05-21T18:56:33Z")

</div>

Hi @MagBad welcome to fortran-lang, I was under the impression that kakoune was already able to integrate with fortls [Editor Integration - fortls](https://fortls.fortran-lang.org/editor_integration.html#kakoune) .  
Is that not the case?

---

<div class="post-metadata">

**Author:** ![freevryheid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/freevryheid/32/357_2.png) [@freevryheid](https://fortran-lang.discourse.group/u/freevryheid)\
**Post date:** [May 22, 2023, 12:32pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/7 "2023-05-22T12:32:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MagBad](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@MagBad](https://fortran-lang.discourse.group/u/MagBad)\
**Post date:** [May 22, 2023, 5:06pm UTC](https://fortran-lang.discourse.group/t/fortran-syntax-for-kakoune-editor/728/8 "2023-05-22T17:06:38Z")

</div>

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.
