Skip to content

Commit

Permalink
add latex completions – fixes JuliaIDE/Julia-LT#21
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Jun 12, 2014
1 parent d20a17b commit 877871c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ const completions = Dict{String,Function}()

complete(f, s) = completions[s] = f

const latex_completions = [{:completion => completion, :text => text}
for (text, completion) in Base.REPLCompletions.latex_symbols]

handle("editor.julia.hints") do req, data
cur_line = lines(data["code"])[data["cursor"]["line"]]
cur_line |> isempty && return
pos = data["cursor"]["col"]

latex = get_latex_input(cur_line, pos)
if latex != ""
return editor_command(req, "hints", {:hints => latex_completions,
:notextual => true})
end

mod = get_module_name(data)

qualified = @> cur_line get_qualified_name(pos) split(".")
Expand Down
5 changes: 5 additions & 0 deletions src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ function get_qualified_name(str::String, index)
return pre * post
end
end

function get_latex_input(str::String, index)
pre = str[1:(index <= endof(str) ? index : end)]
match_or_empty(r"\\[a-zA-Z0-9_^]*$", pre)
end

0 comments on commit 877871c

Please sign in to comment.