@@ -157,14 +157,18 @@ defmodule NextLS do
157
157
158
158
def handle_request ( % TextDocumentDocumentSymbol { params: % { text_document: % { uri: uri } } } , lsp ) do
159
159
symbols =
160
- try do
161
- lsp . assigns . documents [ uri ]
162
- |> Enum . join ( "\n " )
163
- |> NextLS.DocumentSymbol . fetch ( )
164
- rescue
165
- e ->
166
- GenLSP . error ( lsp , Exception . format_banner ( :error , e , __STACKTRACE__ ) )
167
- nil
160
+ if Path . extname ( uri ) in [ ".ex" , ".exs" ] do
161
+ try do
162
+ lsp . assigns . documents [ uri ]
163
+ |> Enum . join ( "\n " )
164
+ |> NextLS.DocumentSymbol . fetch ( )
165
+ rescue
166
+ e ->
167
+ GenLSP . error ( lsp , Exception . format_banner ( :error , e , __STACKTRACE__ ) )
168
+ nil
169
+ end
170
+ else
171
+ nil
168
172
end
169
173
170
174
{ :reply , symbols , lsp }
@@ -219,7 +223,7 @@ defmodule NextLS do
219
223
dispatch ( lsp . assigns . registry , :runtimes , fn entries ->
220
224
for { runtime , % { uri: wuri } } <- entries , String . starts_with? ( uri , wuri ) do
221
225
with { :ok , { formatter , _ } } <-
222
- Runtime . call ( runtime , { Mix.Tasks.Format , :formatter_for_file , [ ".formatter.exs" ] } ) ,
226
+ Runtime . call ( runtime , { Mix.Tasks.Format , :formatter_for_file , [ URI . parse ( uri ) . path ] } ) ,
223
227
{ :ok , response } when is_binary ( response ) or is_list ( response ) <-
224
228
Runtime . call ( runtime , { Kernel , :apply , [ formatter , [ Enum . join ( document , "\n " ) ] ] } ) do
225
229
{ :reply ,
0 commit comments