Autocompletion across all opened files
N++ has autocomplete but it seems to be based on the content of the current file and the contents of the autoCompletion\LANG_TYPE.xml file for the given language of the current file. Writing in C++, I can think of times that autocompletion from all open files would be good - like a .cpp and .h file where I’m defining the function prototypes in the .h file and I’d like the names to autocomplete from the opened .cpp file.
I haven’t looked at the N++ code base, but I’m assuming this is done with the Scintilla Autocompletion calls? I wonder if there is a way to augment the dynamic list via plugin? Has anyone thought of this too? Has anyone tried it?
I use this technique together with jedi for python.
Can you describe how you have Jedi integrated with N++ for autocompletion? I’m not familiar with Jedi so just did a quick search. Found npp_pyjedi, do you use that? Or is it custom with PythonScript?
I see nppgtags has an autocomplete feature, but found the interface to TagLEET better to work with.
do you use that?
No, the one I linked :-)
Or is it custom with PythonScript?
Yes, Jedi is a bunch of python modules which will be accessed
by a python script plugin but for other languages it is the same I guess.
There is a need to have an “external” process running which constantly parses
your code and offers you the auto completion functionality.
What I did is this
def on_charadded(self, args): if self.is_python: c = args['ch'] if c in ['.', ' ', '(']: pos = editor.getCurrentPos() if (editor.getCurLine().find('#') > -1 or editor.getStyleAt(pos) in [3, 4, 6, 7]): return source = editor.getText() + c line = editor.lineFromPosition(pos) + 1 column = editor.getColumn(pos) script = jedi.Script(source, line, column, '') if c == '(': self.show_calltip(script, pos) else: if c == '.' and editor.callTipActive(): editor.callTipCancel() self.autocomplete(script, pos)
Whenever a charadded notification is sent I check if this is a python document and if it is
act according to the added char. If it is a ( I call a calltip and in case it is a . I ask for completion.
I could have done it for every single char but I don’t like to get a offer to autocomplete always.
I mostly been interested in methods and attributes from classes etc…
@Michael-Vincent I came looking for the same info. I started to use Atom because it picks up on the function names in any open files and offers it in autocomplete. I’m doing PHP. So I start a session by opening my database and helper function files. Then any file I open gets full access to the autocomplete.
I prefer N++ but have been using Atom more lately because I’m doing a HUGE site update and the new function names are not in the old code. It’s saving me a TON of typing.