# Sane kak-lsp config/hook

**URL:** <https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019>\
**Category:** Uncategorized\
**Created:** [March 24, 2022, 2:16pm UTC](https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019 "2022-03-24T14:16:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADe](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ade/32/1062_2.png) [@ADe](https://discuss.kakoune.com/u/ADe)\
**Post date:** [March 24, 2022, 2:16pm UTC](https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019/1 "2022-03-24T14:16:51Z")

</div>

I personally cannot write code without inlay diagnostics feature enabled, which is unfortunately a bit buggy currently. The bug is mostly noticeable in insert mode. So, I created a simple hook which disables inlay diagnostics when in insert mode and enables in normal mode, which is a temporally fix, while this bug isn’t fixed.

```auto
hook global WinSetOption filetype=(rust|python|nim|go|javascript|typescript|c|cpp) %{
        lsp-enable-window
	lsp-inlay-diagnostics-enable buffer
	hook buffer ModeChange pop:insert:normal %{ lsp-inlay-diagnostics-enable buffer }
	hook buffer ModeChange push:normal:insert %{ lsp-inlay-diagnostics-disable buffer }
}

```

The problem now, is that when user wants to disable inlay diagnostics for current buffer, it ill pop back in as soon as it goes to normal mode.

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [March 26, 2022, 7:29am UTC](https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019/2 "2022-03-26T07:29:28Z")

</div>

Good point. I still haven’t really used inlay-diagnostics (I tend to use lsp-hover to view diagnostics) but I’d like to.

@raiguard is using [a similar hook](https://github.com/kak-lsp/kak-lsp/pull/515#issuecomment-915621084)

We should make this the default behavior, or at least document it.

---

<div class="post-metadata">

**Author:** ![Screwtapello](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/screwtapello/32/12_2.png) [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Post date:** [March 26, 2022, 8:31am UTC](https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019/3 "2022-03-26T08:31:49Z")

</div>

I used to use `lsp-hover`, but at least with the Rust language server, the hover text is 90% documentation and 10% diagnostics. There’s apparently an option to disable diagnostics for 100% documentation, but that’s usually the opposite of what I want. Inlay diagnostics lets me see the diagnostics without the documentation, which is very convenient.

(`lsp-hover-buffer` would be a good choice too, but my little laptop often doesn’t have the screen real-estate for a editing buffer, a documentation browser, a terminal for running tests, _and_ a diagnostics buffer.)

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [March 26, 2022, 9:11am UTC](https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019/4 "2022-03-26T09:11:16Z")

</div>

Same, I usually don’t care about hover documentation (go-to-definition is good enough) whereas hover diagnostics are nice because they don’t interrupt flow or editor state

There is an option to make hover show diagnostics only:

```
set-option global lsp_show_hover_format %{
	printf "Diagnostics:\n%s" "${lsp_diagnostics}"
}

```

this configuration is probably too obscure. Perhaps we should expose separate commands for documentation/diagnostics.

One disadvantage of hover is that I often don’t know exactly where the error is. I have to run lsp-hover at the correct position within a line to get diagnostics. I guess we can fix that, by making hover requests cover the entire line.

Today I’m still often falling back to `*cargo*` or `*make*` buffers for precise diagnostics. Yet, hover and inlay diagnostics are better for quick iteration, so we should make them work out of the box.

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [January 30, 2024, 3:47am UTC](https://discuss.kakoune.com/t/sane-kak-lsp-config-hook/2019/5 "2024-01-30T03:47:53Z")

</div>

with latest git master of Kakoune and kak-lsp, this is now fixed properly; inlay diagnostics no longer jump around and thus also needn’t be hidden in insert mode (see [Use `flag-lines -after` for inlay diagnostics by raiguard · Pull Request #714 · kak-lsp/kak-lsp · GitHub](https://github.com/kak-lsp/kak-lsp/pull/714))
