Function Parameters Hint very Limited for Python
I noticed that NPP’s function parameters hint is limited in Python in that it doesn’t show hints for functions outside of the basic built-ins like range() and other such functions.
In Python IDLE, I can type random.random() from the random module and it will still give me function parameter hints.
If I do the same in NPP, I dont get any function parameter hints. (random module was also imported here)
Here is an example of the hints working just to show that it does work for functions like range()
Is there a way for me to add this functionality so that I can get hints for built-in or even third-party modules?
This might be a better example from Python IDLE
The experience you get in IDLE and any other IDE comes from a language server. In other words, there is something in the background totally separate from the text editor itself that parses/interprets/compiles the document in real time as you are typing. The same is true of any other Python IDE you use, be it PyCharm, VSCode, etc., etc.
Let me reiterate - what you are talking about is not a component of the text editor. The only responsibility of a text editor like Notepad++ is to deal with rendering of text, find/replace functionality, making sure documents are saved to hard drive without data loss, and in some cases providing syntax coloring.
While there are various plugins to Notepad++ that can provide an IDE-like experience, the sort of thing you are asking for will almost certainly never be a core feature of Notepad++.
BTW, the reason you get any hints at all in Notepad++ is just that Notepad++ has built-in config files that provide hints for a subset of the built-in functions. Unfortunately this approach is impossible to scale to the vast array of Python functions even in the standard library alone, and literally useless for parsing functions that you define within your own file.
Let me reiterate - what you are talking about is not a component of the text editor.
I agree that the language server is not a component of the text editor. But if the text editor has an LSP client, then it can access that information and present it.
Notepad++ does not currently have an LSP client built in (though that would be nice, I doubt the developer is going to do that)… but there are a couple of Notepad++ users who have alpha/beta versions of LSP clients as plugins for Notepad++ – you can just search the forum for LSP and you will probably find a link to them; I don’t know if they will be functional enough for you yet or not.
Thank you both for your insight. I was mostly curious if there was some way I could expand the number of functions the hints work for.
I think I better understand the scope of how that feature works so I will probably continue on with Notepad++ as is for now (since it’s already very good for my use case).
Give generate-python-3-api a try which I authored.
Change the options or suggest initially to remain with default options within gen_python_3_api.py and then run it with Python to write out 4 files. Suggest to run the script in an empty directory so it will not overwrite any files with the preset names.
One of the files will be named python3.xml. This file can be renamed to python.xml and can replace Notepad++'s autoCompletion\python.xml.
The python.xml that comes with Notepad++ v8.5.4 is 61KB which I replaced with the generated python.xml which is 1418KB, using Python v3.11.4. The file size could increase if site packages, … are enabled in the scripts options.
This post is deleted!
Python function hints come from this XML configuration file. You will find it at one of the following places on your system:
%ProgramFiles%\Notepad++\autoCompletion\python.xml(64-bit, fully-installed Notepad++)
%ProgramFiles(x86)%\Notepad++\autoCompletion\python.xml(32-bit, fully-installed Notepad++)
$(Portable_Installation_Dir)\autoCompletion\python.xml(any portable Notepad++)
Additional functions can be added by editing the file, e.g. (note that
>is a named entity that will render as
Give generate-python-3-api a try
My bad for posting just behind the better answer!
Sounds good, I will give it a try. Thank you for your help