helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.57k stars 2.4k forks source link

Language server not active for current buffer #2164

Closed archwebio closed 2 years ago

archwebio commented 2 years ago

Hello,

I have a Mac with Apple M1 chip.

I just installed the app running:

brew tap helix-editor/helix
brew install helix

hx --grammar fetch
hx --grammar build

I added a configuration to change the theme under ~/.config/helix/config.toml and it works fine.

I created a JS file containing a function:

// erase.js
const hello = () => {
  console.log("Hello")
}

hello()

When trying to go to definition by g + d I get a notification:

image

I read through the docs but did not read any specifics on how to connect to the LSP.

Any help is much appreciated.

Thanks,

the-mikedavis commented 2 years ago

You'll need to install the default language server for JavaScript: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers#tsserver

(JavaScript uses the TypeScript language server)

archwebio commented 2 years ago

Indeed. Yes, thanks. That worked for me

workingj commented 2 years ago

Better guiding for language server usage in helix seems to be a thing...

archwebio commented 2 years ago

I started with the docs on https://helix-editor.com and didn't find instructions there.

I just saw the link in the repo pointing to the installation.

Sorry,

Max0nyshchenko commented 2 years ago

@workingJ Can you provide some example with helix LSP, I've installed helix lsp by ghcup, added language to languages.toml but cannot get it to work anyway, still have "Language server not active for current buffer" issue.

Here is my languages.toml

[[language]] name = "haskell" scope = "source.haskell" injection-regex = "haskell" file-types = ["hs"] roots = [] auto-format = false comment-token = "--" language-server = { command = "haskell-language-server-wrapper", args = ["--lsp"] } indent = { tab-width = 2, unit = " " }

workingj commented 2 years ago

@Max0nyshchenko make sure the Folder with the LSP is also added to your $PATH env var. Currently i have only the configuration for rust, hope this helps:

[[language]]
name = "rust"
scope = "source.rust"
injection-regex = "rust"
file-types = ["rs"]
roots = ["Cargo.toml", "Cargo.lock"]
auto-format = true
comment-token = "//"
language-server = { command = "rust-analyzer" }
indent = { tab-width = 4, unit = "  " }

[language.debugger]
name = "lldb-vscode"
transport = "stdio"
command = "lldb-vscode"
Max0nyshchenko commented 2 years ago

@workingJ Thank you, but I cannot get it to work anyway. Updated $PATH env var to

export PATH="$PATH:$HOME/.cabal/bin:$HOME/.ghcup/bin"

I can access haskell-language-server from terminal but helix still gives "Language server not active for current buffer"

------- Edit ---------

Deleting languages.toml did the thing for me.

workingj commented 2 years ago

@Max0nyshchenko great to hear you could fix this, may be there was a bug some where in the languages toml...

Max0nyshchenko commented 2 years ago

@Max0nyshchenko great to hear you could fix this, may be there was a bug some where in the languages toml...

@workingJ Yeah, probably) But it has less code actions available compared to VS Code, when I'm trying Typescript React, no autoimports available in quick fixes. Is it should be like that?

workingj commented 2 years ago

@Max0nyshchenko as far as i have followed the project LSP support is still being worked and improved on. You can open an issue for your case if you'd like.

dawkrish commented 6 months ago

I have installed the lsps, but they are not connecting to the buffer for some reasons ...