svenstaro / glsl-language-server

Language server implementation for GLSL
MIT License
175 stars 29 forks source link

Client glslls quit with exit code 0 and signal 6 #59

Open Thisishemmit opened 3 months ago

Thisishemmit commented 3 months ago

I'm using glslls along with lsp_config.nvim and whenever I try to open glsl file in the editor this error show up:

Client glslls quit with exit code 0 and signal 6. Check log
 for errors: /home/user/.local/state/nvim/lsp.log

The log line in lsp.log is:

[ERROR][2024-07-25 15:13:05] .../vim/lsp/rpc.lua:772    "rpc"   "/usr/local/bin/glslls" "stderr"    "terminate called after throwing an instance of 'std::invalid_argument'\n  what():  Unknown file extension!\n"

And the glslls.lua of the lsp_config.nvim is:

local util = require "lspconfig.util"

return {
    default_config = {
        cmd = {"glslls", "--stdin"},
        filetypes = {
            "glsl",
            "vert",
            "tesc",
            "tese",
            "frag",
            "geom",
            "comp"
        },
        root_dir = util.find_git_ancestor,
        single_file_support = true,
        capabilities = {
            textDocument = {
                completion = {
                    editsNearCursor = true
                }
            },
            offsetEncoding = {
                "utf-8",
                "utf-16"
            }
        }
    },
    docs = {
        description = [[
https://github.com/svenstaro/glsl-language-server
Language server implementation for GLSL
`glslls` can be compiled and installed manually, or, if your distribut>
via the `glsl-language-server` AUR package
    ]]
    }
}
svenstaro commented 3 months ago

Hm that's odd. Can you tell what file extension your plugin tries to communicate?

Thisishemmit commented 3 months ago

@svenstaro my file extension was .glsl but after i added .frag like .frag.glsl it worked but highlighted some errors like:

uniform float time;     ■ 'non-opaque uniforms outside a block' : not allowed when using GLSL for Vulkan
pcrady commented 1 week ago

I'm having the exact same issue exit code 0 and signal 6. Heres my lsp.log:

[START][2024-10-23 13:07:45] LSP logging initiated
[ERROR][2024-10-23 13:07:45] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/petercrady/.local/share/nvim/mason/bin/glslls"  "stderr"        "libc++abi: terminating due to uncaught exc

This happens when i:

nvim shader.glsl

If i try shader.frag or something else nothing happens. The lsp doesnt seem to even start up. Then if i do

nvim shader.frag.glsl i get:

void main() {
  gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);      'assign' :  cannot convert from ' temp highp 4-component vector of float' to ' temp float'
  fragColor = colors[gl_VertexIndex];      '[]' : scalar integer expression required
}

which is pretty weird

pcrady commented 1 week ago

so with this:

EShLanguage find_language(const std::string& name)
{
    // As well as the one used in glslang, there are a number of different conventions used for naming GLSL shaders.
    // This function attempts to support the most common ones, by checking if the filename ends with one of a list of known extensions.
    // If a ".glsl" extension is found initially, it is first removed to allow for e.g. vs.glsl/vert.glsl naming.
    auto path = fs::path(name);
    auto ext_path = path.extension();
    if (ext_path == ".glsl")
        ext_path = path.replace_extension();

    const auto ext = ext_path.string();

    if (ext.ends_with("vert") || ext.ends_with("vs") || ext.ends_with("vsh"))
        return EShLangVertex;
    else if (ext.ends_with("tesc"))
        return EShLangTessControl;
    else if (ext.ends_with("tese"))
        return EShLangTessEvaluation;
    else if (ext.ends_with("geom") || ext.ends_with("gs") || ext.ends_with("gsh"))
        return EShLangGeometry;
    else if (ext.ends_with("frag") || ext.ends_with("fs") || ext.ends_with("fsh"))
        return EShLangFragment;
    else if (ext.ends_with("comp"))
        return EShLangCompute;
    throw std::invalid_argument("Unknown file extension!");
}

if you name it something.vert.glsl it removes the glsl and then goes to something.vert but that doesn't explain why something.vert doesnt work

pcrady commented 1 week ago

ok I figured it out. add this to init.lua

vim.filetype.add({
  extension = {
    vert = "glsl",
    tesc = "glsl",
    tese = "glsl",
    frag = "glsl",
    geom = "glsl",
    comp = "glsl",
  },
})

there is nothing wrong with glslls. vim isnt detecting the filetype correctly