Skip to content

Commit

Permalink
Fixed a regression in formatter plugin loader
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Dec 30, 2024
1 parent 3041b15 commit aa02b83
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### Unreleased

### v0.26.1: 30 December 2024

#### Fixes

- Fixed regression in formatter plugin loader

### v0.26.0: 30 December 2024

#### Highlights
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.26.0
0.26.1
28 changes: 26 additions & 2 deletions apps/language_server/lib/language_server/source_file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule ElixirLS.LanguageServer.SourceFile do
alias ElixirLS.LanguageServer.Protocol.TextEdit

import ElixirLS.LanguageServer.Protocol
import ElixirLS.LanguageServer.JsonRpc
require ElixirSense.Core.Introspection, as: Introspection
require Logger

Expand Down Expand Up @@ -272,10 +273,33 @@ defmodule ElixirLS.LanguageServer.SourceFile do
config_mtime: MixProjectCache.config_mtime(),
mix_project: MixProjectCache.get(),
root: project_dir,
plugin_loader: fn _plugins ->
plugin_loader: fn plugins ->
for plugin <- plugins do
cond do
not Code.ensure_loaded?(plugin) ->
JsonRpc.show_message(
:warning,
"Formatter plugin #{inspect(plugin)} is not loaded and will be skipped. Please compile the project."
)

nil

not function_exported?(plugin, :features, 1) ->
JsonRpc.show_message(
:error,
"Formatter plugin #{inspect(plugin)} does not define features/1 and will be skipped."
)

nil

true ->
plugin
end
end
|> Enum.reject(&is_nil/1)

# we don't do any plugin loading as this may trigger compile
# TODO it may be safe to compile on 1.18+
:ok
end
]

Expand Down

0 comments on commit aa02b83

Please sign in to comment.