LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.29k stars 305 forks source link

[Req] Support in ignoring lines starting with # #2681

Closed rostok closed 4 months ago

rostok commented 4 months ago

Hello, Is there a way to configure LuaLS to completely ignore lines starting with #, in particular lines like this #include mapcarTutorialRaw.lua ?

I tried writing my own plugin but commenting such line still triggers diagnostic warnings

function OnSetText(uri, text)
    local diffs = {}

    for start, line in text:gmatch("()([^\n]*)\n?") do
        if line and line:match("^#include") then
            local text = "-- "..line
            diffs[#diffs + 1] = {
                start = start,
                finish = start+line:len(),
                text = text
            }
        end
    end

    return diffs
end

Also putting ---@diagnostic disable-next-line: exp-in-action, undefined-global before such line still gives warnings I don't know how to suppress

[Warn type:1], `#` can not start
[Warn type:1], expression cannot be used as a statement
[Warn type:1], expression cannot be used as a statement
rostok commented 4 months ago

Sorry for the issue. [Warn type:1] was caused by LuaHelper (yinfei.luahelper) extension