svenstaro / glsl-language-server

Language server implementation for GLSL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do you actually use the language server?

christofferaakre opened this issue · comments

I compiled the server following the instructions. Just running glslls gives me a message
saying it started a web server on port 61313. When I go to localhost:61313 in my browser, the request just hangs. glslls --stdin just gives me a hanging prompt.

It's not clear to me how to actually use the language server to get diagnostics from a shader file.

I also tried setting up a custom lsp server for neovim lspconfig using this, but had little success. However, I figure I should probably understand how to actually use it from the command line before trying to make a custom lspconfig server.

So, how do you actually use this thing?

Well, you're not really supposed to interact with it as a user. You should set it up as a language server in your editor of choice. It's mostly compliant and so should just work as other LS.

Thanks for the response. I did indeed try to set it up for neovim, but the server doesn't connect when I open a .glsl file or even when I try to manually start it. Everything looks okay when I execute the LspInfo command and I get no error messages.
I realise now this is probably not actually an issue with the server but rather I must have made a mistake trying to set lspconfig up to use it. I guess I just have to get good and figure out how to properly add a new custom server to neovim because clearly I messed something up.

I will post my setup code here just in case you might be able to see what's wrong, but I understand you probably can't unless you just so happen to use neovim too.

-- Set up glslls for glsl
if not configs.glslls then
    configs.glslls = {
        default_config = {
            cmd = {'/usr/local/bin/glslls'};
            filetypes = {'glsl', 'fs', 'vs'};
            root_dir = function(fname)
                return lspconfig.util.find_git_ancestor(fname)
            end;
            settings = {},
            },
        }
end


local servers = { 'pyright', 'tsserver', 'clangd', 'gdscript', 'rust_analyzer', 'glslls'}
for _, lsp in ipairs(servers) do
 require'lspconfig'[lsp].setup {
    on_attach = on_attach,
    flags = {
      debounce_text_changes = 150,
    }
  }
end

Running LspInfo from neovim gives me this:

     Language client log: /home/negosaki/.cache/nvim/lsp.log
     Detected filetype:   glsl
     
     0 client(s) attached to this buffer: 
     
     Other clients that match the filetype: glsl
     
     Config: glslls
        filetypes:         glsl, fs, vs
        root directory:    /home/negosaki/coding/graphics
        cmd:               /usr/local/bin/glslls
        cmd is executable: true
        autostart:         true
        custom handlers:   

I'm not familiar with your particular config type (using nvim coc myself) but this:

     0 client(s) attached to this buffer: 
     
     Other clients that match the filetype: glsl

seems like there's no clients being started?

Indeed, it doesn't seem to connect, even though autostart is set to true. Other servers start up automatically when I open a file with the relevant file type. And it does detect my config for glslls and detects that it matches the filetype, but for some reason it just doesn't start, even when I try to manually start it. Can you perhaps share your coc config so I can look through it?

I am having similar trouble setting it up for Helix. The editor is recognising the server, but it isn't starting for .glsl files. Maybe share your coc config as requested above? Cheers.

Ah, yes actually I think we had a very similar issue before here: #13

So basically it boils down to giving it a precise file extension to work with so the parser knows which shader type it's actually looking at. Depending on which shader type it is, you get slightly different semantics.

Does that work fine for you @christofferaakre?

@svenstaro with the right file extensions, it does indeed start yeah. I am now havng a different problem, where when I start to type, I get the following error message:

LSP[glslls]: Error INVALID_SERVER_MESSAGE: {
  error = {
    code = -32601,
    message = "Method 'textDocument/completion' not supported."
  },
  jsonrpc = "2.0"

But I haven't really tried to troubleshoot this yet, so there might be an easy fix.

Well, completion is indeed not supported I'm afraid.

@svenstaro sorry, I should have reread the readme. I guess I'll just have to figure out how to disable completion for my server config then. Thanks!