Function list is coming up empty



  • So I’m pretty new to notepad++ and newer to coding in general. Forgive me if I’m off base or misunderstanding how this is supposed to work.

    What led me here is my preferred theme (twilight) not having an option to modify powershell syntax coloring. After importing some lexertype stuff from stylers.xml to twilight.xml I could adjust the coloring.

    At that point I noticed the powershell functions were not being highlighted with a foreground color at all. I was shooting for coloring similar to the powershell ISE and so I tracked down the functions being apparently referenced (and presumably identified/colored) based on being found in a powershell.xml inside a functionList folder.

    Now I do use the portable version, however the folder and the powershell.xml therein are present.

    I opened a powershell script in notepad++ and opened the view > function list and it was empty and devoid of anything. Unsure if this is intended/normal until some type of user intervention or?

    29c21796-be82-4eff-baea-79cafaac8d11-image.png

    d0dcdf6c-706f-42a8-ab08-3b19a1a6d073-image.png



  • @klepp0906 said in Function list is coming up empty:

    So I’m pretty new to notepad++ and newer to coding in general. Forgive me if I’m off base or misunderstanding how this is supposed to work.

    What led me here is my preferred theme (twilight) not having an option to modify powershell syntax coloring. After importing some lexertype stuff from stylers.xml to twilight.xml I could adjust the coloring.

    Good job, most themes in the themes subdirectory are not fully complete - that is they don’t have all the languages found in stylers.model.xml. You need to manually edit them by copy/paste from stylers.model.xml and then adjust colors to your liking. Sounds like you figured that out.

    At that point I noticed the powershell functions were not being highlighted with a foreground color at all. I was shooting for coloring similar to the powershell ISE and so I tracked down the functions being apparently referenced (and presumably identified/colored) based on being found in a powershell.xml inside a functionList folder.

    That is incorrect, if I correctly understand what you’re saying. Notepad++ directory structure:

    notepad++
    |-- autoCompletion
    |-- functionList
    |-- localization
    |-- plugins
    |-- themes
    |-- updater
    `-- userDefineLangs
    
    • themes as you found has the syntax highlighting (lexing) for different color palettes. The default plain white theme is in the file stylers.xml at the root of the Notepad++ directory tree.
    • the keywords - in this case - Powershell function names - are found in langs.xml at the root of the Notepad++ directory tree. I searched mine and the function names you put yellow boxes around are not in that file so they are not recognized as Powershell functions and thus not lexed. You can remedy this from the Settings => Style Configurator… menu item:

    f907874f-e8c0-47d4-81c6-2a67d07b6949-image.png

    Just add new user-defined or updated Powershell CMDLETs to the “User-defined keywords” section, space separated.

    • functionList contains files with a regular expression syntax embedded in XML to define how to parse functions from files and put them in the Function List panel. If you overwrote this file, put back the original one - can be found in the portable edition ZIP file under the functionList directory.

    • autocomplete stores files that help you autocomplete when typing. I don’t believe there is a default powershell.xml in that directory, but mine can be found here.

    I hope this helps.

    Cheers.



  • Ah yes, i think we misunderstood one another. You are correct in that the keywords are in the langs.xml, i found those too. However thats where things diverge (or so i thought).

    The reason I presumed functions were kept separate and located in the functionslist folder (apart from my view functionlist showing up empty) is the fact that those colors (in the langs.xml) and also shown in your screenshot are as labled, cmdlets. (also incomplete but thats neither here nor there).

    functions are something else alltogether.

    Get-NetAdapterInterface is a function

    Write-Host is a cmdlet

    you can see an entire list and their category ala Get-Command from powershell.

    The cmdlets are getting colored, the functions are not and should have a different color as they do in the ISE.

    Not sure what the solution is there as from some really introductory reading, theres no way to add a new “category” to the langs.xml to define said things. Its hardcoded on some level or some such.

    thank you for the reply, I will make use of that autocompletion file :)



  • also, those user defined keywords (didnt notice that section, very helpful!) where would that be saved upon entering?



  • @klepp0906 said in Function list is coming up empty:

    Get-NetAdapterInterface is a function
    Write-Host is a cmdlet

    I understand now. From Notepad++ perspective, they (Get-NetAdapterInterface and Write-Host) are just keywords that need to be lexed by the Powershell lexer. So put them under CMDLET and they will lex the same. If you want them different colors I’m afraid you’re out of luck.

    The function list shows “functions” - like so:

    
    function Get-WmiKey {
        $Class = [WmiClass]$args[0]
        $Class.Properties | `
            Select @{Name="PName";Expression={$_.name}} -Expand Qualifiers | `
            Where {$_.Name -eq "key"} | `
            foreach {$_.Pname}
    }
    
    Get-WmiKey Win32_LogicalDisk
    

    3caf426a-6412-44cc-8c13-fc5bee1ca113-image.png

    Hope that clears things up.

    Cheers.



  • @Michael-Vincent ok, fair enough. thats entirely acceptable to me. Now i know it is what it is, and I know how to get some color applied to em which is more important than “what” color as far as them being different.

    I appreciate the replies!


Log in to reply