Skip to content

Commit aa02b83

Browse files
committed
Fixed a regression in formatter plugin loader
1 parent 3041b15 commit aa02b83

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
### Unreleased
22

3+
### v0.26.1: 30 December 2024
4+
5+
#### Fixes
6+
7+
- Fixed regression in formatter plugin loader
8+
39
### v0.26.0: 30 December 2024
410

511
#### Highlights

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.26.0
1+
0.26.1

apps/language_server/lib/language_server/source_file.ex

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule ElixirLS.LanguageServer.SourceFile do
22
alias ElixirLS.LanguageServer.Protocol.TextEdit
33

44
import ElixirLS.LanguageServer.Protocol
5+
import ElixirLS.LanguageServer.JsonRpc
56
require ElixirSense.Core.Introspection, as: Introspection
67
require Logger
78

@@ -272,10 +273,33 @@ defmodule ElixirLS.LanguageServer.SourceFile do
272273
config_mtime: MixProjectCache.config_mtime(),
273274
mix_project: MixProjectCache.get(),
274275
root: project_dir,
275-
plugin_loader: fn _plugins ->
276+
plugin_loader: fn plugins ->
277+
for plugin <- plugins do
278+
cond do
279+
not Code.ensure_loaded?(plugin) ->
280+
JsonRpc.show_message(
281+
:warning,
282+
"Formatter plugin #{inspect(plugin)} is not loaded and will be skipped. Please compile the project."
283+
)
284+
285+
nil
286+
287+
not function_exported?(plugin, :features, 1) ->
288+
JsonRpc.show_message(
289+
:error,
290+
"Formatter plugin #{inspect(plugin)} does not define features/1 and will be skipped."
291+
)
292+
293+
nil
294+
295+
true ->
296+
plugin
297+
end
298+
end
299+
|> Enum.reject(&is_nil/1)
300+
276301
# we don't do any plugin loading as this may trigger compile
277302
# TODO it may be safe to compile on 1.18+
278-
:ok
279303
end
280304
]
281305

0 commit comments

Comments
 (0)