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

Configuration in standalone setup #154

Closed
gustavo-hms opened this issue Mar 31, 2020 · 13 comments
Closed

Configuration in standalone setup #154

gustavo-hms opened this issue Mar 31, 2020 · 13 comments
Labels
Non VS Code The server is communicating with a client that is not VS Code

Comments

@gustavo-hms
Copy link

Hello! How can I configure this server? For example, to set the behaviour of diagnostics? I couldn't find any documentation for it.

I'm on a standalone setup, using it with coc plugin for neovim.

Thanks!

@sumneko sumneko added the Non VS Code The server is communicating with a client that is not VS Code label Apr 3, 2020
@sumneko
Copy link
Collaborator

sumneko commented Apr 3, 2020

In the standard of LSP, the server obtains the configuration through Configuration.
For VSCode, the configuration is declared in package.json.
However, LSP does not specify how the language client resolves the settings, so neovim needs to refer to the package. JSON file for its own configuration.
In the future, it may be considered to parse a specific configuration file directly by the language server.

@gustavo-hms
Copy link
Author

Thank you for your response!

I've found that writing

"Lua.diagnostics.disable": [
    "lowercase-global"
]

to coc-settings.json does the job in neovim with coc plugin.

Anyway, is there a place (apart from the package.json you linked above) where we can find the list of options to configure with some description explaining them? I mean, one more or less can guess the meaning of each option and the way to set it by looking at this json file, but it's much easier if there is, for instance, a wiki page for them.

But I understand it can be a big and tedious work. So it's OK if you don't have the time to write it.

Thanks again!

@sumneko
Copy link
Collaborator

sumneko commented Apr 7, 2020

It's a good idea to explain the configuration options on the wiki, I will do it in these days. Thank you for your advice!

@dseeni
Copy link

dseeni commented Apr 29, 2020

Would love to hear details about how you set things up? I am on windows and using neovim and coc @gustavo-hms, even if not on windows, please let us know.

@gustavo-hms
Copy link
Author

gustavo-hms commented Apr 29, 2020

Sure! Follow these steps:

For example, mine has the following json:

{
    ... many unrelated options here ...
    "languageserver": {
        "lua": {
	    "cwd": "full path of lua-language-server directory", (not sure this one is really necessary)
	    "command": "full path to lua-language-server executable",
	    "args": ["-E", "-e", "LANG=en", "[full path of lua-language-server directory]/main.lua"],
	    "filetypes": ["lua"],
	    "rootPatterns": [".git/"]
        }
    },
    "Lua.diagnostics.disable" : [
        "lowercase-global"
    ]
}

@ckipp01
Copy link

ckipp01 commented Apr 29, 2020

@gustavo-hms thanks for the instructions! I just tested this out locally, and when I build locally for macOS, the [full path of the lua-language-server directory] like you have mentioned doesn't have a main.lua in it, so I'm getting an error there that the file or directory doesn't exist. Should there be a main.lua there that I don't have for some reason?

@gustavo-hms
Copy link
Author

Well, the [full path of the lua-language-server directory] is not the path of the executable, but the path of the base directory of the lua-language-server project (as you clone from github). So, the main.lua file refers to this file: https://github.com/sumneko/lua-language-server/blob/master/main.lua

@gustavo-hms
Copy link
Author

By the way, for those interested, I also managed to configure Kakoune with kak-lsp. You have to add the following lines to ~/.config/kak-lsp/kak-lsp.toml:

[language.lua]
filetypes = ["lua"]
roots = [".git/"]
command = "full path to lua-language-server executable"
args = ["-E", "[full path of lua-language-server directory]/main.lua"]

I couldn't set lua-language-server options like the lowercase-global above though. I didn't find how.

@ckipp01
Copy link

ckipp01 commented Apr 30, 2020

Well, the [full path of the lua-language-server directory] is not the path of the executable, but the path of the base directory of the lua-language-server project (as you clone from github). So, the main.lua file refers to this file: /main.lua@master

ahhh duh, I interpreted that as the directory that directly contained the executable. I changed it and now it works fine. Thanks a ton!

@kkharji
Copy link

kkharji commented Sep 25, 2020

Yah I failed to get it working with coc.nvim: here is my config:

    let lua_lsp = glob('~/.local/lua-language-server')
    if len(lua_lsp)
        call coc#config('languageserver', {
            \ 'lua-language-server': {
            \     'cwd': lua_lsp,
            \     'command': lua_lsp . '/bin/Linux/lua-language-server',
            \     'args': ['-E', '-e', 'LANG="LANG=en","', lua_lsp . '/main.lua'],
            \     'filetypes': ['lua'],
            \ }
        \ })
    endif

Any suggestions, thanks

@gustavo-hms
Copy link
Author

Hi, @tami5 !

I'm not on my machine right now to test your configuration, but may be you could try replacing:

       call coc#config('languageserver', {
            \ 'lua-language-server': {
            \     'cwd': lua_lsp,

with:

       call coc#config('languageserver', {
            \ 'lua': {
            \     'cwd': lua_lsp,

Tell me if it helps.

@kkharji
Copy link

kkharji commented Oct 1, 2020

@gustavo-hms thanks so much for taking interest in my issue. same thing, here's the output of the error message

/home/tami/.local/lua-language-server/bin/Linux/lua-language-server: (command line):1: unfinished string near <eof>
[Error  - 11:18:17 PM] /home/tamibam/.local/lua-language-server/bin/Linux/lua-language-server exited with code: 1
    let lua_lsp = glob('~/.local/lua-language-server')
    if len(lua_lsp)
        call coc#config('languageserver', {
            \ 'lua': {
            \     'cwd': lua_lsp,
            \     'command': lua_lsp . '/bin/Linux/lua-language-server',
            \     'args': ['-E', '-e', 'LANG="LANG=en","', lua_lsp . '/main.lua'],
            \     'filetypes': ['lua'],
            \ }
        \ })
    endif

@flamendless
Copy link

Hi, in vim, do we still need to do the json-schema part? Here is the output of CocInfo for me (without doing the json-schema) part.

## versions

vim version: VIM - Vi IMproved 8.2 8020814
node version: v14.5.0
coc.nvim version: 0.0.79-8230b63641
coc.nvim directory: /home/brbl/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2020-10-28T20:42:02.071 INFO (pid:3085631) [services] - registered service "languageserver.lua"
2020-10-28T20:42:02.088 INFO (pid:3085631) [services] - lua state change: stopped => starting
2020-10-28T20:42:02.095 INFO (pid:3085631) [plugin] - coc.nvim 0.0.79-8230b63641 initialized with node: v14.5.0 after 191ms
2020-10-28T20:42:02.130 INFO (pid:3085631) [language-client-index] - Language server "languageserver.lua" started with 3085646
2020-10-28T20:42:02.150 ERROR (pid:3085631) [language-client-client] - connection error: Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:785:11)
    at Socket._write (net.js:797:8)
    at writeOrBuffer (_stream_writable.js:352:12)
    at Socket.Writable.write (_stream_writable.js:303:10)
    at StreamMessageWriter.write (/home/brbl/.vim/plugged/coc.nvim/build/index.js:18391:27)
    at /home/brbl/.vim/plugged/coc.nvim/build/index.js:17539:35
    at new Promise (<anonymous>)
    at Object.sendRequest (/home/brbl/.vim/plugged/coc.nvim/build/index.js:17529:26)
    at Object.initialize (/home/brbl/.vim/plugged/coc.nvim/build/index.js:74405:44)
    at LanguageClient.doInitialize (/home/brbl/.vim/plugged/coc.nvim/build/index.js:76521:27)
    at LanguageClient.initialize (/home/brbl/.vim/plugged/coc.nvim/build/index.js:76508:25)
    at /home/brbl/.vim/plugged/coc.nvim/build/index.js:76439:25 {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
} undefined
2020-10-28T20:42:02.210 INFO (pid:3085631) [services] - lua state change: starting => stopped

@sumneko sumneko closed this as completed Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non VS Code The server is communicating with a client that is not VS Code
Projects
None yet
Development

No branches or pull requests

6 participants