Skip to content

Commit

Permalink
More autocomplete colors and sorting tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Mar 29, 2024
1 parent c649d22 commit 60a3132
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 1 addition & 3 deletions frontend/components/CellInput/LiveDocsFromCursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ export let get_selected_doc_from_state = (/** @type {EditorState} */ state, verb
if (
cursor.name === "Identifier" &&
parent.name === "ArgumentList" &&
(parent.parent.parent.name === "FunctionAssignmentExpression" ||
parent.parent.name === "FunctionDefinition")
(parent.parent.parent.name === "FunctionAssignmentExpression" || parent.parent.name === "FunctionDefinition")
) {
continue
}
Expand Down Expand Up @@ -297,7 +296,6 @@ export let get_selected_doc_from_state = (/** @type {EditorState} */ state, verb

if (VALID_DOCS_TYPES.includes(cursor.name) || keywords_that_have_docs_and_are_cool.includes(cursor.name)) {
if (!is_docs_searchable(cursor)) {
console.log("NOT DOCS SEARCHABLE")
return undefined
}

Expand Down
14 changes: 6 additions & 8 deletions frontend/components/CellInput/pluto_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const section_operators = {
rank: 1,
}

const field_rank_heuristic = (text) => (/^\p{Ll}/u.test(text) ? 3 : /^\p{Lu}/u.test(text) ? 2 : 1)
const field_rank_heuristic = (text, is_exported) => is_exported * 3 + (/^\p{Ll}/u.test(text) ? 2 : /^\p{Lu}/u.test(text) ? 1 : 0)

const julia_commit_characters = [".", ",", "(", "[", "{"]
const endswith_keyword_regex =
Expand Down Expand Up @@ -266,6 +266,8 @@ const julia_code_completions_to_cm =
let text_to_apply =
completion_type === "method" ? to_complete : is_field_expression ? override_text_to_apply_in_field_expression(text) ?? text : text

value_type = value_type === "Function" && text.startsWith("@") ? "Macro" : value_type

return {
label: text,
apply: text_to_apply,
Expand All @@ -277,14 +279,9 @@ const julia_code_completions_to_cm =
c_from_notebook: is_from_notebook,
}) ?? undefined,
section: section_regular,
// detail: completion_type,
boost:
completion_type === "keyword_argument"
? 1
: is_listing_all_fields_of_a_module
? is_exported
? field_rank_heuristic(text_to_apply)
: undefined
: undefined,
completion_type === "keyword_argument" ? 7 : is_field_expression ? field_rank_heuristic(text_to_apply, is_exported) : undefined,
// boost: 50 - i / results.length,
}
}),
Expand Down Expand Up @@ -434,6 +431,7 @@ const special_symbols_completion = (/** @type {() => Promise<SpecialSymbols?>} *
label,
apply: value != null && (!is_inside_string || is_emoji) ? value : label,
detail: value ?? undefined,
type: "c_special_symbol",
boost: label === "\\in" ? 3 : special_latex_examples.includes(label) ? 2 : special_emoji_examples.includes(value) ? 1 : 0,
}
})
Expand Down
7 changes: 7 additions & 0 deletions frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,10 @@ pluto-cell.errored .cm-editor .cm-lineNumbers .cm-gutterElement::after {
color: var(--cm-string-color);
}

.cm-completionIcon-completion_property::before {
color: var(--cm-property-color);
}

.cm-completionIcon-completion_keyword::before {
color: var(--cm-keyword-color);
}
Expand All @@ -3494,6 +3498,9 @@ pluto-popup code.auto_disabled_variable {
.cm-completionIcon-c_Function::before {
color: var(--cm-function-color);
}
.cm-completionIcon-c_Macro::before {
color: var(--cm-macro-color);
}

.cm-completionIcon-c_Array::before {
color: var(--cm-bracket-color);
Expand Down

0 comments on commit 60a3132

Please sign in to comment.