Scite Auto Complete Any Language
This is a SciTE startup script that provides auto-completion for any file type. It scans the file for identifiers on save, open and buffer switch and uses those identifiers in auto-completion. It doesn't use any external files for lists of identifiers.
What constitutes an identifier is determined by the list of patterns in IDENTIFIER_PATTERNS. This example allows identifiers to include dots (e.g. to suggest a whole "object.member.property" string) and dashes, (e.g. "lisp-or-css-identifier").
This script may not behave well if you have auto-completion enabled in SciTE properties.
This allows any word in the document (whether they are variables, functions, labels, comments, etc.) to be auto-completed. I found this to be a step up from SciTE4AutoHotkey's auto-completion, which often annoys me by auto-completing the wrong word or interfering with my use of single-character variable names.
I took the script above and modified it to include everything from the current language's API files (such as AutoHotkey commands) and IMO improve the usability of the auto-complete popups. The following are features of my script (the ones I can remember):
- Automatically brings up an auto-complete list after typing a minimum of MIN_PREFIX_LEN characters, except while typing in a comment or quoted string. Ctrl+Space also triggers the auto-complete list.
- Auto-completes any word (greater than MIN_IDENTIFIER_LEN characters) saved in the document, except for words in comments or quoted strings. Only words consisting of alphanumeric characters and/or underscore are used, but this can be changed via IDENTIFIER_PATTERNS.
- Case is ignored by default.
- If INCREMENTAL is set to true, the list is narrowed down while typing, to show only the relevant items. This is disabled by default because current versions of SciTE destroy and recreate the auto-complete window when editor:AutoCShow() is called, and this doesn't look nice.
- If INCREMENTAL is set to true, the auto-complete popup is automatically dismissed if there's only one item and you type it in full.
- Pressing UP at the top or DOWN at the bottom of the list does one of the following:
- Wraps around to the other end of the list if WRAP_ARROW_KEYS is true.
- Cancels the list and allows the caret to move to the line above/below the current line.
- Other options are available in the script (in ALL_CAPS).
- The list is updated only on saving or opening the document.
- It is disabled for languages other than AutoHotkey and Lua, but this can be changed in the script (see setLexerSpecificStuff; or add the appropriate list of styles to IGNORE_STYLES).
- It should play nice with other scripts, such as the one included in SciTE4AutoHotkey.
To use this script with SciTE4AutoHotkey:
- Place AutoComplete.lua in your SciTE user settings folder (i.e. %A_MyDocuments%\AutoHotkey\SciTE).
- Add the following to UserLuaScript.lua:
- Restart SciTE.
Original topic: https://autohotkey.com/board/topic/7081 ... for-scite/