Skip to content

Commit

Permalink
feat: add snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacervello committed Mar 5, 2024
1 parent 082b8d5 commit 8fbe1c2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ defmodule NextLS do
_ -> []
end
end)
|> Enum.map(fn %{name: name, kind: kind} = symbol ->
|> Enum.reduce([], fn %{name: name, kind: kind} = symbol, results ->
{label, kind, docs} =
case kind do
:struct -> {name, GenLSP.Enumerations.CompletionItemKind.struct(), ""}
Expand All @@ -592,13 +592,21 @@ defmodule NextLS do
_ -> {name, GenLSP.Enumerations.CompletionItemKind.text(), ""}
end

%GenLSP.Structures.CompletionItem{
label: label,
kind: kind,
insert_text: name,
documentation: docs
}
completion_item =
%GenLSP.Structures.CompletionItem{
label: label,
kind: kind,
insert_text: name,
documentation: docs
}

case NextLS.Snippet.get(name, nil) do
nil -> [completion_item | results]
snippets when is_list(snippets) -> results ++ snippets
snippet -> [snippet | results]
end
end)
|> Enum.reverse()

{:reply, results, lsp}
rescue
Expand Down

0 comments on commit 8fbe1c2

Please sign in to comment.