11local uv = vim .uv
22local ci_build = vim .env .CI == ' true' or vim .env .GITHUB_ACTIONS == ' true'
33
4- local severity_type = {
5- { color = 31 , text = ' error' },
6- { color = 33 , text = ' warning' },
7- { color = 90 , text = ' info' },
8- { color = 36 , text = ' hint' },
9- }
10-
114local function lua_language_server_executable ()
125 local lua_language_server
136 if vim .env .LUA_LS_SERVER then
@@ -25,15 +18,15 @@ local function lua_language_server_executable()
2518 lua_language_server = vim .env .GITHUB_WORKSPACE
2619 .. [[ /tmp/lua_language_server/bin/lua-language-server]]
2720 io.write (
28- (' lua-language-server not found or not executable. CI build detected, falling back to %s\n ' ):format (
21+ (' lua-language-server not found or not executable. CI build detected, falling back to %s\n\n ' ):format (
2922 lua_language_server
3023 )
3124 )
3225 elseif lua_language_server == ' ' then
3326 lua_language_server = vim .fn .stdpath (' data' )
3427 .. ' /mason/packages/lua-language-server/lua-language-server'
3528 io.write (
36- (' lua-language-server not found or not executable. falling back to %s\n ' ):format (
29+ (' lua-language-server not found or not executable. falling back to %s\n\n ' ):format (
3730 lua_language_server
3831 )
3932 )
@@ -89,60 +82,5 @@ local lua_language_server = lua_language_server_executable()
8982local tmp_path = tmpfile ()
9083local command = check_command (lua_language_server , tmp_path )
9184local check_command_result = vim .system (command ):wait ()
92- local ok = check_command_result .code == 0
93- if not ok then
94- io.write ((' %s\n ' ):format (vim .inspect (check_command_result )))
95- os.exit (check_command_result .code )
96- end
97-
98- local input = vim .fn .readfile (tmp_path )
99- local diagnostics = vim .json .decode (table.concat (input ))
100- local formatted_diagnostics = {}
101- for filepath , file_diagnostics in pairs (diagnostics ) do
102- local path = filepath :gsub (' ^file://' , ' ' ):gsub (' /%./' , ' /' )
103- for _ , v in ipairs (file_diagnostics ) do
104- local item = {
105- file = path ,
106- message = v .message ,
107- severity = v .severity or 1 ,
108- line = v .range .start .line + 1 ,
109- col = v .range .start .character + 1 ,
110- }
111- table.insert (formatted_diagnostics , item )
112- end
113- end
114-
115- if vim .tbl_isempty (formatted_diagnostics ) then
116- io.write ((' %s' ):format (check_command_result .stdout ))
117- os.exit (0 )
118- else
119- for _ , v in ipairs (formatted_diagnostics ) do
120- if ci_build then
121- io.write (
122- (' %s:%s:%s %s %s\n ' ):format (
123- vim .fn .fnamemodify (v .file , ' :.' ),
124- v .line ,
125- v .col ,
126- (' %s:' ):format (severity_type [v .severity ].text ),
127- v .message
128- )
129- )
130- else
131- io.write (
132- (' \x1b ]8;;file://%s\x1b \\ %s\x1b ]8;;\x1b \\ :%s:%s %s %s\n ' ):format (
133- v .file ,
134- vim .fn .fnamemodify (v .file , ' :.' ),
135- v .line ,
136- v .col ,
137- (' \x1b [%sm%s:\x1b [0m' ):format (
138- severity_type [v .severity ].color ,
139- severity_type [v .severity ].text
140- ),
141- v .message
142- )
143- )
144- end
145- end
146- io.write ((' %s' ):format (check_command_result .stdout ))
147- os.exit (1 )
148- end
85+ io.write (check_command_result .stdout )
86+ os.exit (check_command_result .code )
0 commit comments