streamlit-code-editor icon indicating copy to clipboard operation
streamlit-code-editor copied to clipboard

Option to disable “local” buffer completions

Open martin-foka opened this issue 8 months ago • 1 comments

Hi there! I discovered streamlit-code-editor a few days ago and have been integrating it to live-edit Jinja2 templates. Everything works beautifully, but I can’t figure out how to disable the “local” suggestions that pop up in the autocomplete dropdown.

When typing, those buffered completions appear alongside my hardcoded snippets - I'd love to only see suggestions from my snippets, with no “local” entries. Any options?


Environment

❯ uv pip list | grep streamlit
streamlit                 1.45.0
streamlit-code-editor     0.1.22

Steps to reproduce

Simplified version to show the issue:

from code_editor import code_editor

initial = """<div>
  <h1>Hello world</h1>
  {% if xyz %}
    <div class="text-green-700 divide-x"><p>Xyz is true</p></div>
  {% else %}
    <div class="text-orange-300 divide-y"><p>It does not matter</p></div>
  {% endif %}
</div>"""

snippets = [
    [
        {"name": "div", "code": "<div>${0}</div>"},
        {"name": "p",   "code": "<p>${0}</p>"},
        {"name": "if",  "code": "{% if ${1:condition} %}\n  ${0}\n{% endif %}"},
        {"name": "for", "code": "{% for ${1:item} in ${2:iterable} %}\n  ${0}\n{% endfor %}"}
    ],
    ""
]

code_editor(
    code=initial,
    lang="django",
    height=350,
    snippets=snippets,
    options={
        "behavioursEnabled": False,
        "enableBasicAutocompletion": False,
        "enableLiveAutocompletion": True,
        "enableSnippets": False
    }
)

Focus the editor and start typing di

Actual behavior

The autocomplete dropdown includes entries labelled “local” (variables and class names detected from the current buffer). These unwanted “local” suggestions appear interleaved with the desired HTML/snippet entries.

Expected behavior

Only HTML tags (div, p, etc.) and custom Jinja2 snippets (if, for) appear in the autocomplete dropdown. No “local” buffer-derived suggestions (e.g. xyz, divide-x, text-green-700, etc.) should be shown.

martin-foka avatar May 10 '25 17:05 martin-foka

Late reply here...

I misunderstood what you wanted originally so I thought that this would require a new feature or enhancement. Correct me if I am wrong but you only want to see snippet suggestions or do you just want to remove local suggestions only and leave global and snippets etc?

bouzidanas avatar Jul 22 '25 02:07 bouzidanas