Skip to content
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

Build/Use outside of VSCode #60

Closed
norcalli opened this issue Jul 11, 2019 · 17 comments
Closed

Build/Use outside of VSCode #60

norcalli opened this issue Jul 11, 2019 · 17 comments
Labels
question User has a question

Comments

@norcalli
Copy link

I've been looking for a good lua language server since I've found EmmyLua to be a little unreliable. I want to use this with vim, which just requires running the server, but I don't see instructions for how to build the server standalone.

Is it possible to run as a stdio server so I could use it with vim?

@sumneko sumneko added the question User has a question label Jul 11, 2019
@sumneko
Copy link
Collaborator

sumneko commented Jul 11, 2019

If you are on Windows, you can download this extension then copy the server folder. Otherwise, see readme How to use on macOS/Linux.
And then startup server like here.

@norcalli
Copy link
Author

norcalli commented Jul 12, 2019

So, I actually went through the steps by installing VSCode, and etc, but in that process I learned what the real build steps were. They were defined in .vscode/tasks.json:

git clone [email protected]:sumneko/lua-language-server.git
cd lua-language-server
# PreCompile
cd 3rd/luamake/
ninja -f ninja/linux.ninja
cd ../../
# Compile
3rd/luamake/luamake rebuild
# Run
server/bin/lua-language-server -E -e LANG=en server/main.lua

You could put this in a Makefile for those of us who want to try this outside of VSCode.

Here's a 30 second version:

run: server/bin/lua-language-server
  server/bin/lua-language-server -E -e LANG=en server/main.lua

server/bin/lua-language-server: 3rd/luamake/luamake
  3rd/luamake/luamake rebuild

3rd/luamake/luamake:
  cd 3rd/luamake && ninja -f ninja/linux.ninja

Note to others:

server/bin/lua-language-server must be run from inside of lua-language-server as it contains relative paths.

@norcalli
Copy link
Author

Works well!

@sumneko consider adding the instructions I made above to the README. I could open a PR if you're interested.

@MaskRay
Copy link

MaskRay commented Oct 6, 2019

Drop-by comment. I was looking for a Lua language server and just came across this project.

@sumneko Please add a wiki page and probably make it publicly editable https://help.github.com/en/articles/changing-access-permissions-for-wikis Users of editors other than VSCode can benefit from the build instructions here.

@wbthomason
Copy link

For anyone finding these instructions now, @norcalli's comment needs two modifications:

  1. You'll need git submodule update --init --recursive before you can run ninja for luamake.
  2. Running the server (on Linux, at least) now requires running /path/to/lua-language-server/server/Linux/bin/lua -E -e LANG=en /path/to/lua-language-server/server/main.lua (the main difference is that the executable now seems to be called lua instead of lua-language-server, and that seemingly you can run it from outside of the root repo directory).

It would be really great if, as @MaskRay suggests, there was a wiki where we could put these build instructions, or section of the README, a Makefile, etc.

@sumneko
Copy link
Collaborator

sumneko commented Nov 22, 2019

I have create a wiki page for building and runing.
@MaskRay Sorry I missed your message before, now everyone could edit wiki.

@sumneko sumneko reopened this Nov 22, 2019
@norcalli
Copy link
Author

norcalli commented Nov 23, 2019

@wbthomason @MaskRay @sumneko Since opening this PR, I have since joined the neovim team and wrote the builtin client for neovim vim.lsp. I also started a project to add specific language server configs in https://github.com/neovim/nvim-lsp/, but I hope for it to be a reference for any 3rd party users as to how to configure servers since the configurations are very abstracted and you don't need a lot familiarity with Lua to use them.

I wrote a script to auto install it that you can reference, and it has the benefit that it will be maintained by the neovim contributors. I added a step to download ninja if you don't have it.

Here's the PR https://github.com/neovim/nvim-lsp/pull/49/files#diff-b4f1130fbd1295c6654d11c3dd94b1e7

And here's the install script https://github.com/neovim/nvim-lsp/blob/ddd62036c8509a8a9fd78595fdcf53884bd02f7f/lua/nvim_lsp/sumneko_lua.lua#L32

You may find our automatic extension scraping and settings generation especially useful. You can see it in the README.md. I scrape the package.json for settings.

@teto
Copy link

teto commented Dec 29, 2019

mainstream packager for lua projects is https://luarocks.org/. It would be very cool to see a rockspec for it. It's quite simple to write.

@weisa-san
Copy link

I got the server running outside of VSCode. Like @sumneko suggests I copied the server folder from the extension and ran it with the command: bin\Windows\lua-language-server.exe -E main.lua

Now I just don't understand how I can access it? How do I send him the code of my file so that the Lua LS can send me his suggestions?

Context: I work with Angular 8 and the Monaco Editor (core of VSCode) on a IDE, it's only used locally. To connect Monaco to an LSP I use the Monaco Editor Language Client (https://github.com/TypeFox/monaco-languageclient), it provides a language client that establishes communication between Monaco editors and language servers over JSON-RPC via WebSockets.

@sumneko
Copy link
Collaborator

sumneko commented Mar 13, 2020

@weisa-san Currently the language server only supports connection by standard output and standard input.

@rodamaral
Copy link

I got it working with neovim, using the coc.nvim plugin, in my Linux machine. The steps are similar to @norcalli 's.

# Clone the repository recursively into a desired folder
# in my case $HOME/.lua-language-server/
git clone --recursive [email protected]:sumneko/lua-language-server.git .lua-language-server/

# PreCompile with ninja, you must have this package
cd .lua-language-server/3rd/luamake/
ninja -f ninja/linux.ninja

# Compile
cd ../../
3rd/luamake/luamake rebuild

# Run
cd ../
.lua-language-server/bin/Linux/lua-language-server  -E -e LANG=en .lua-language-server/main.lua

If everything went OK, the command won't return and wont' print anything, until you Ctrl+C.
Pay attention to the OS name in the path. And make sure to invoke this command in the parent directory, because main.lua uses the path argument.
To connect to coc.nvim, you must use edit coc-settings.json and include:

    "languageserver": {
        "lua": {
            // FIXME: avoid absolute paths
            "cwd": "/home/myUserName/",
            "command": "/home/myUserName/.lua-language-server/bin/Linux/lua-language-server",
            "args": ["-E", "-e", "LANG=\"en\"", ".lua-language-server/main.lua"],
            "filetypes": [
                "lua"
            ]
        }
    },

@gagbo
Copy link

gagbo commented Jun 3, 2020

Do you need dotnet as an additional dependency ?
I'm trying to build it on Linux, and I can't build luamake (rewritten here because it's running on another laptop and reasons) :

# In 3rd/luamake with the submodules recursively initialized
[0/3] cd 3rd/bee.lua && ninja -f ninja/linux.ninja
[2/2] build/linux/bin/bootstrap test/test.lua
FAILED: build/linux/_/test
build/linux/bin/boootstrap test/test.lua
OS: Linux
Arch: 64
Compiler: GCC 10.1.0
CRT: libstdc++ 20200507
DEBUG: false
....
ninja: build stopped: subcommand fialed.
FAILED: build/linux/_/bee
cd 3rd/bee.lua && ninja -f ninja/linux.ninja
ninja: build stopped: subcommand failed.

@gagbo
Copy link

gagbo commented Jun 3, 2020

That's actually this issue I was able to compile removing the tests (both on 3rd/luamake/3rd/bee and 3rd/bee).

The unit tests at the end of luamake fail though. Still trying to figure out why.

But meanwhile, commenting out the test in the default targets to make.lua works well

lm:default {
    'install',
-    'test',
+    -- 'test',
    'unittest',
}

@wbthomason
Copy link

@gagbo: If you could try the steps in actboy168/bee.lua#8 (comment) and report if you get any more information in actboy168/bee.lua#8, that would be helpful!

@sumneko
Copy link
Collaborator

sumneko commented Nov 23, 2020

Has been integrated into neovim.

@sumneko sumneko closed this as completed Nov 23, 2020
@gagbo
Copy link

gagbo commented Nov 23, 2020

But there are other editors than VSCode and neovim :(

Either way, I think the issue I mentionned earlier has been fixed, I didn't need extra steps to get it working after reinstalling recently. 👍

@arnoson
Copy link

arnoson commented Nov 28, 2021

@weisa-san I also tried to connect this language server to a Monaco Editor running in the browser and finally got a working example: https://github.com/arnoson/monaco-lua-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User has a question
Projects
None yet
Development

No branches or pull requests

9 participants