Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for how to add an lsp #340

Closed
faldor20 opened this issue Jun 21, 2021 · 21 comments
Closed

Documentation for how to add an lsp #340

faldor20 opened this issue Jun 21, 2021 · 21 comments
Labels
A-documentation Area: Documentation improvements C-enhancement Category: Improvements

Comments

@faldor20
Copy link

Describe your feature request

Nowhere in the docs does it actually explain how you configure an LSP.

I just found this project and whilst it looks interesting I have essentially no way of understanding how to set it up without going through the source code.

looks interesting though :)

@faldor20 faldor20 added the C-enhancement Category: Improvements label Jun 21, 2021
@pickfire pickfire added the A-documentation Area: Documentation improvements label Jun 22, 2021
@pickfire
Copy link
Contributor

I am not sure if it could be configured currently. I think it can't.

@tmke8
Copy link

tmke8 commented Jun 22, 2021

I think the general way to configure things is: Copy languages.toml to ~/.config/helix/languages.toml and then modify the language-server setting in the section corresponding to your programming language:

language-server = { command = "typescript-language-server", args = ["--stdio"] }

But I don't actually know what you can change there.

@pickfire
Copy link
Contributor

I think he meant the language specific configuration, not like the args.

@vv9k
Copy link
Contributor

vv9k commented Jun 22, 2021

I think the general way to configure things is: Copy languages.toml to ~/.config/helix/languages.toml and then modify the language-server setting in the section corresponding to your programming language:

language-server = { command = "typescript-language-server", args = ["--stdio"] }

But I don't actually know what you can change there.

That's still a bit of a hack. We should probably allow adding new language definitions without the need for the user to copy the languages.toml from the repo.

I think the best way here would be to have ~/.config/helix/languages.toml that will get merged with the default configuration (same as we do for the keymaps). All new defined languages will be added on top of the default config while any entries that conflict will be replaced by the ones from user config.

@faldor20
Copy link
Author

I actually meant exactly what @thomkeh said
How do I go from having no languageserver working to having one working?
But also is there a list of supported language servers? Or can I just add my own that will work with a specific file type? (f# in my case)

@ratsclub
Copy link

Would this PR solve the issue?

#654

@nico-abram
Copy link

Should this be closed now that #654 is merged?

@sudormrfbin
Copy link
Member

sudormrfbin commented Apr 18, 2022

The thread has multiple features mentioned, so I'll answer them in order:

How do I go from having no languageserver working to having one working?

You have to check the supported list of LSPs and install the one corresponding to your language.

Supported list of LSPs

See the "Default LSP" column in https://docs.helix-editor.com/lang-support.html.

How to install LSPs

https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers

How to override the language server?

Since #654 is merged instead of copying the default languages.toml, you can create an empty file of the same name alongside your config.toml and edit it as necessary (as mentioned further up in the thread).

How to pass config to the LSP itself?

It's possible to send config values to the LSP itself for fine-tuning it's behavior, see #2063 (comment) for an example.


This issue could be closed, but we still don't have any solid, centralized docs in https://docs.helix-editor.com describing LSP in detail (including why it's required, pointing to the LSP installation wiki, etc).

@AlexCzar
Copy link

AlexCzar commented May 31, 2022

I've just heard about helix editor and wanted to try it, LSP without config - nice. Checked out the docs, and installed taplo, as recommended, with cargo install taplo, but helix doesn't see it (it's in the PATH, double-checked by running taplo --help).
helix --health toml shows

Configured language server: None
Configured debug adapter: None
Highlight queries: Not found
Textobject queries: Not found
Indent queries: Not found

helix -v ~/.config/helix/config.toml

helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { LSP not defined }

Searching the web didn't help, except to find the diagnostics above.

Information for package helix:
------------------------------
Repository     : openSUSE:Tumbleweed
Name           : helix
Version        : 22.03~0-2.1

@the-mikedavis
Copy link
Member

Configured language server: None

It looks like you're running an older helix release - taplo was added after the 22.03 release: #2302 so you'll need to run 22.05

@cinerea0
Copy link
Contributor

cinerea0 commented Jun 2, 2022

I think it would be good to show a full example of how to translate a more complicated setup into the format that helix wants. #2063 (comment) provides a great example of how to port over a simple configuration, but I'm trying to work with a configuration with nested tables and it's not going well.

@sudormrfbin
Copy link
Member

sudormrfbin commented Jun 3, 2022

@cinerea0 Could you share the configuration with the nested tables? We could add the ported examples to the wiki too.

@cinerea0
Copy link
Contributor

cinerea0 commented Jun 4, 2022

@sudormrfbin After a bit more tinkering I realized that it isn't so much a nested table as it is lua not having the syntax to express the difference between tables and arrays, which TOML does. I've still included my configurations below in case they make a good example.

Lua for Neovim
texlab = {
  build = {
    forwardSearchAfter = true,
    onSave = true
  },
  chktex = {
    onEdit = true,
  },
  forwardSearch = {
    executable = 'zathura',
    args = { '--synctex-forward', '%l:1:%f', '%p' }
  },
}
TOML for Helix
[[language]]
name = "latex"
config = { texlab = { build = { onSave = true, forwardSearchAfter = true }, forwardSearch = { executable = "zathura", args = [ "--synctex-forward", "%l:1:%f", "%p" ] }, chktex = { onEdit = true } } }

EDIT: Actually, there were nested tables, and the TOML representation is quite awkward looking.

@MGlolenstine
Copy link

MGlolenstine commented Jun 27, 2022

@sudormrfbin After a bit more tinkering I realized that it isn't so much a nested table as it is lua not having the syntax to express the difference between tables and arrays, which TOML does. I've still included my configurations below in case they make a good example.
Lua for Neovim

texlab = {
  build = {
    forwardSearchAfter = true,
    onSave = true
  },
  chktex = {
    onEdit = true,
  },
  forwardSearch = {
    executable = 'zathura',
    args = { '--synctex-forward', '%l:1:%f', '%p' }
  },
}

TOML for Helix

[[language]]
name = "latex"
config = { texlab = { build = { onSave = true, forwardSearchAfter = true }, forwardSearch = { executable = "zathura", args = [ "--synctex-forward", "%l:1:%f", "%p" ] }, chktex = { onEdit = true } } }

EDIT: Actually, there were nested tables, and the TOML representation is quite awkward looking.

The TOML representation doesn't look that bad if you spread it out (I think I did it correctly, no Latex knowledge here).

[[language]]
name = "latex"

[language.config.texlab.build]
onSave = true
forwardSearchAfter = true

[language.config.texlab.forwardSearch]
executable = "zathura"
args = [ "--synctex-forward", "%l:1:%f", "%p" ]

[language.config.texlab.chktex]
onEdit = true

@cinerea0
Copy link
Contributor

@MGlolenstine That does indeed work. We were workshopping it in #2758, for some reason no one came up with that representation.

@MGlolenstine
Copy link

@cinerea0 I'm glad I was able to help!

The beauty of TOML is that you can reformat and reorganise your keys as much as you want to make it as readable as you want :)

@boborbt
Copy link

boborbt commented Apr 9, 2023

Using comments in this page I was able to get forward synctex search to work on macos (with Skim). I wonder if anybody has got inverse search to work as well. Apparently this is still a problem with helix itself.

I searched for a while and I couldn't find a way to ask a current hx process to switch to a particular file:lineno via a shell command...

Ideally it could be something like hx --pid xxx --cmd 'open yyyy, goto zzzz' or the even simpler hx --pid xxx open yyyy:zzzz). Maybe omitting the --pid option if only one hx process is active?

Is there any way this feature could be added?

By the way, helix rocks! I was (and still am) a vscode user, but I have so much fun using helix that I am really considering switching to it for all my work. You have my admiration for the excellent work 😊

@robrecord
Copy link

Apparently the config parameter is now defunct. How do we configure this now?

@gozes
Copy link

gozes commented Aug 16, 2023

@robrecord good question. I just added a rust config thing to use clippy and would also like to know how to make it work

@bluthej
Copy link

bluthej commented Aug 26, 2023

@gozes @robrecord I think I figured it out. Like some other lsp configs it seems with the new way things work we need to turn the previously mentioned config into:

[[language]]
name = "latex"

[language-server.texlab.config.texlab.build]
onSave = true
forwardSearchAfter = true

[language-server.texlab.config.texlab.forwardSearch]
executable = "zathura"
args = [ "--synctex-forward", "%l:1:%f", "%p" ]

[language-server.texlab.config.texlab.chktex]
onEdit = true

Basically, all the keys given in the texlab Wiki like texlab.build.onSave must be prefixed with language-server.texlab.config..

This works for me (I built from master on the 26th of august), hope this works for you too!

@pascalkuthe
Copy link
Member

I think we can close this, this issue is just quite old/stale. I consider the docs at https://docs.helix-editor.com/master/languages.html#language-server-configuration sufficient, especially with the many examples in the wiki: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers. If people have specific suggestions on how the docs can be improved they can open new issues (or even better a PR).

@helix-editor helix-editor locked and limited conversation to collaborators Aug 27, 2023
@pascalkuthe pascalkuthe converted this issue into discussion #8078 Aug 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
A-documentation Area: Documentation improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.