Replies: 3 comments
-
I'm not aware of any official way of doing this but the simplest method is probably something like this: events.connect(events.CHAR_ADDED, function(code)
textadept.editing.autocomplete('word')
if buffer:auto_c_active() then return end
textadept.editing.autocomplete(buffer:get_lexer(true))
end) This will first try to autocomplete using words from the current buffer and if that fails it will attempt to autocomplete using completions from the language modul (if any). |
Beta Was this translation helpful? Give feedback.
-
Snoopy is right that there is no official way of doing this. You can expand on the given solution to include a 2 or 3 character check with something like this:
events.connect(events.CHAR_ADDED, function(code)
if buffer.current_pos - buffer:word_start_position(buffer.current_pos, true) < 3 then return end
if textadept.editing.autocomplete('word') then return end
textadept.editing.autocomplete(buffer:get_lexer(true))
end)
Note that `textadept.editing.autocomplete()` returns `true` if it succeeded, so we can utilize that.
|
Beta Was this translation helpful? Give feedback.
-
What @snoopy and @orbitalquark have posted is probably a good simple implementation but I just wanted to contribute my own auto-complete functionality in case it is useful to you. https://github.com/eric1234/.textadept/blob/main/modules/autocomplete.lua There is also a utility method in that module that is shared among a few modules which is defined here that you will need to copy into the module or load somewhere else: https://github.com/eric1234/.textadept/blob/main/modules/utilities.lua The functionality does pop-up as you type but it also does the following:
It's always a work in progress but if there is anything useful there feel free to take what you want. |
Beta Was this translation helpful? Give feedback.
-
I might be missing something obvious here but, how can I enable autocomplete as I type without having to press
Ctrl+Enter
or ^Esc on mac?I'd like the autocomplete prompt to show after typing 2 or 3 characters. How can I do that?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions