Skip to content

Commit c4fc6a4

Browse files
committed
add emoji completions
1 parent 3b13cc5 commit c4fc6a4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/requests/completions.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function textDocument_completion_request(params::CompletionParams, server::Langu
5252

5353
if pt isa CSTParser.Tokens.Token && pt.kind == CSTParser.Tokenize.Tokens.BACKSLASH
5454
latex_completions(string("\\", CSTParser.Tokenize.untokenize(t)), state)
55-
elseif ppt isa CSTParser.Tokens.Token && ppt.kind == CSTParser.Tokenize.Tokens.BACKSLASH && pt isa CSTParser.Tokens.Token && pt.kind === CSTParser.Tokens.CIRCUMFLEX_ACCENT
55+
elseif ppt isa CSTParser.Tokens.Token && ppt.kind == CSTParser.Tokenize.Tokens.BACKSLASH && pt isa CSTParser.Tokens.Token && (pt.kind === CSTParser.Tokens.CIRCUMFLEX_ACCENT || pt.kind === CSTParser.Tokens.COLON)
5656
latex_completions(string("\\", CSTParser.Tokenize.untokenize(pt), CSTParser.Tokenize.untokenize(t)), state)
5757
elseif t isa CSTParser.Tokens.Token && t.kind == CSTParser.Tokenize.Tokens.COMMENT
5858
partial = is_latex_comp(t.val, state.offset - t.startbyte)
@@ -106,7 +106,7 @@ function get_partial_completion(state::CompletionState)
106106
end
107107

108108
function latex_completions(partial::String, state::CompletionState)
109-
for (k, v) in REPL.REPLCompletions.latex_symbols
109+
for (k, v) in Iterators.flatten((REPL.REPLCompletions.latex_symbols, REPL.REPLCompletions.emoji_symbols))
110110
if is_completion_match(string(k), partial)
111111
# t1 = TextEdit(Range(state.doc, (state.offset - sizeof(partial)):state.offset), v)
112112
add_completion_item(state, CompletionItem(k, 11, missing, v, v, missing, missing, missing, missing, missing, missing, texteditfor(state, partial, v), missing, missing, missing, missing))
@@ -343,13 +343,15 @@ is_latex_comp_char(c::Char) = UInt32(c) <= typemax(UInt8) ? is_latex_comp_char(U
343343
function is_latex_comp_char(u)
344344
# Checks whether a Char (represented as a UInt8) is in the set of those those used to trigger
345345
# latex completions.
346-
# from: UInt8.(sort!(unique(prod([k[2:end] for (k,_) in REPL.REPLCompletions.latex_symbols]))))
346+
# from: UInt8.(sort!(unique(prod([k[2:end] for (k,_) in Iterators.flatten((REPL.REPLCompletions.latex_symbols, REPL.REPLCompletions.emoji_symbols))]))))
347+
u === 0x21 ||
347348
u === 0x28 ||
348349
u === 0x29 ||
349350
u === 0x2b ||
350351
u === 0x2d ||
351352
u === 0x2f ||
352353
0x30 <= u <= 0x39 ||
354+
u === 0x3a ||
353355
u === 0x3d ||
354356
0x41 <= u <= 0x5a ||
355357
u === 0x5e ||

test/requests/completions.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ completion_test(line, char) = LanguageServer.textDocument_completion_request(Lan
88
"\\therefor"
99
\"\"\"\\therefor\"\"\"
1010
^\\therefor
11+
\\:water_buffal
1112
""")
1213
@test completion_test(0, 9).items[1].textEdit.newText == ""
1314
@test completion_test(0, 9).items[1].textEdit.range == LanguageServer.Range(0, 0, 0, 9)
@@ -26,6 +27,9 @@ completion_test(line, char) = LanguageServer.textDocument_completion_request(Lan
2627

2728
@test completion_test(5, 10).items[1].textEdit.newText == ""
2829
@test completion_test(5, 10).items[1].textEdit.range == LanguageServer.Range(5, 1, 5, 10)
30+
31+
@test completion_test(6, 14).items[1].textEdit.newText == "🐃"
32+
@test completion_test(6, 14).items[1].textEdit.range == LanguageServer.Range(6, 0, 6, 14)
2933
end
3034

3135
@testset "path completions" begin

0 commit comments

Comments
 (0)