# \[SOLVED\] Help needed setting texlab up - Latex Language Server Protocol

**URL:** <https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866>\
**Category:** Help\
**Tags:** lsp\
**Created:** [January 28, 2020, 9:54pm UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866 "2020-01-28T21:54:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [January 28, 2020, 9:54pm UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/1 "2020-01-28T21:54:38Z")

</div>

Hello,

I’m trying to set up kakoune to take notes in latex. Similar to this post in vim: [https://castel.dev/post/lecture-notes-1/](https://castel.dev/post/lecture-notes-1/).

Right now, I’m focused on setting up the language server protocol and some snippets.

To this purpose, I installed kak-lsp plugin and copied texlab binary to my path. After that I added the following lines to my kakrc:

```auto
plug "ul/kak-lsp" do %{
    cargo install --locked --force --path .
} config %{
    eval %sh{kak-lsp --kakoune -s $kak_session}
}

```

and

```auto
# Latex Specific
hook global WinCreate .*(\.tex|\.latex) %{
    # Line Wrapping
    add-highlighter window/ wrap -indent -width 120
    # Compile on save
    hook window BufWritePost .* %{ %sh{ pdflatex header.tex } }
    # Language Server Protocol
    lsp-enable-window
}

```

I also added these lines to my **kak-lsp.toml** file located in **~/.config/kak/kak-lsp/**

```auto
[language.latex]
filetypes = ["latex"]
roots = ["header.tex"]
command = "texlab"

```

I don’t know if I have to do something else, but I can’t make the lsp work. I would expect that now if I start typing **\beg** suggestions should appear.

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [January 29, 2020, 6:09am UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/2 "2020-01-29T06:09:20Z")

</div>

first of, you should start kak-lsp by using `lsp-enable-window` and not by calling `eval %sh{...}`. Plug already loads lsp for you, so you only need the hook that will call it for needed filetype:

```auto
plug "ul/kak-lsp" do %{
    cargo install --locked --force --path .
} config %{
    hook global WinSetOption filetype=latex lsp-enable-window
}

```

Though Kakoune doesn’t set `latex` filetype for `.latex` buffers, so we can fix this:

```auto
hook global BufCreate .*\.latex %{
    set-option buffer filetype latex
}

```

Latex specific settings then should go under hook for filetype:

```auto
hook global WinSetOption filetype=latex %{
    # Line Wrapping
    add-highlighter window/ wrap -indent -width 120
    # Compile on save
    hook window BufWritePost .* %{ %sh{ pdflatex header.tex } }
}

```

Try this and see if it works

---

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [January 29, 2020, 9:01am UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/3 "2020-01-29T09:01:01Z")

</div>

Hi, thanks for your help.

I changed my settings but again it doesn’t work. It is recognizing the file type because compile on save and wrap do work, but when I run **kak-capabilities** nothing appears.

Is there an easy way of testing components separately? I mean kak-lsp and texlab.

Thanks

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [January 29, 2020, 9:46am UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/4 "2020-01-29T09:46:44Z")

</div>

perhaps you should run `lsp-capabilities` instead.

@ulis have you tried LSP for LATEX for a chance?

* * *

I’ve downloaded texlab source, compiled it with `cargo build --release` installed it with `cargo install --path . --locked` and it works for me with the config I’ve mentioned in my previous reply. @useredsa are you sure that you have texlab installed correctly?

---

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [January 29, 2020, 11:05am UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/5 "2020-01-29T11:05:26Z")

</div>

Of course :), I was running `lsp-capabilities` but wrote it by heart.

Well, actually, I didn’t download texlab from source, I just downloaded the binary. I will compile from source and see.

---

<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:** [January 29, 2020, 11:24am UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/6 "2020-01-29T11:24:10Z")

</div>

The usual `kak-lsp` troubleshooting procedure might offer some clues:

- instead of letting Kakoune automatically launch kak-lsp, launch it manually yourself with a specific session name:

- In a separate terminal, run Kakoune with the same session name, so it will connect to the kak-lsp you’ve already started:

- Run `lsp-capabilities` in Kakoune, and check the terminal containing `kak-lsp` for error messages.

If that doesn’t provide enough clues, try it again but this time add `-v` to the kak-lsp command line… or `-vv` or `-vvv` or however much additional verbosity you want.

---

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [January 29, 2020, 12:30pm UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/7 "2020-01-29T12:30:20Z")

</div>

Thanks for the info on debugging `kak-lsp`. Doing it I managed to find the mistake. Basically, when I told plug to install the plugin, it didn’t work because `cargo` wasn’t in my path at the moment. I didn’t notice that because although it said error, after hitting enter to retry it said done. Also, I had some other problems.

Anyway, everything works great now. Thank both!

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [January 29, 2020, 12:47pm UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/8 "2020-01-29T12:47:09Z")

</div>

> [@useredsa](#):
>
> after hitting enter to retry it said done

In case of error you can run post installation hooks again with R in plug menu. Log is also available with L

---

<div class="post-metadata">

**Author:** ![duncan](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/duncan/32/95_2.png) [@duncan](https://discuss.kakoune.com/u/duncan)\
**Post date:** [February 5, 2020, 3:36pm UTC](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/9 "2020-02-05T15:36:13Z")

</div>

Thank you for your post @useredsa I had no idea this was possible with kak-lsp must set it up.

I have found this helpful with my Uni maths assignments for \*.png [LaTeXiT](https://pierre.chachatelier.fr/latexit/).

As well, compatible with all IntelliJ-based IDEs including community additions.  
[TeXiFy IDEA](https://plugins.jetbrains.com/plugin/9473-texify-idea)  
[TeXiFy-IDEA](https://github.com/Hannah-Sten/TeXiFy-IDEA)

Enjoy and the struggle of learning is definitely worth the reward.
