Skip to content

Instantly share code, notes, and snippets.

@MarkBorcherding
Created April 11, 2011 22:42
Show Gist options
  • Save MarkBorcherding/914528 to your computer and use it in GitHub Desktop.
Save MarkBorcherding/914528 to your computer and use it in GitHub Desktop.
Powershell ctags settings
--langdef=Powershell
--langmap=Powershell:.psm1
--langmap=Powershell:.ps1
--regex-Powershell=/function\s+(script:)?([a-zA-Z\-]+)/\2/m, method/i
--regex-Powershell=/\$(global:)?([a-zA-Z\-]+)/\2/v, variable/i
Copy link

ghost commented Dec 15, 2016

Hi, already some years old and was still valuable, at least for me ;) I had a small issue with the above config. The second langmap overwrites the first one. So my functions in the module weren't indexed. I put my change to your gist if someone else is also searching for that. I use Pester tests within the subfolder "test".

Either we use
--langmap=Powershell:.psm1 --langmap=Powershell:+.ps1

or directly with one langmap arg
--langmap=Powershell:.psm1.ps1

In a oneliner (functions and all occurences for $<..>)

ctags -R --langdef=Powershell --langmap=Powershell:.psm1.ps1 --regex-Powershell="/function\s+(script:)?([a-zA-Z\-]+)/\2/f, function/i" --regex-Powershell="/\$(global:)?([a-zA-Z\-]+)/\2/v, variable/i" --exclude=test

That gave me too much variable definitions, so a way around that would be to write the type directly in front of the variable name and use that to filter only for the variable definitions where it looks like [] $<..>...

ctags -R --langdef=Powershell --langmap=Powershell:.psm1.ps1 --regex-Powershell="/function\s+(script:)?([a-zA-Z\-]+)/\2/m, method/i" --regex-Powershell="/\s*\[.*\]\s*\$([a-zA-Z\-]+)/\1/v, variable/i" --regex-Powershell="/\$global:([a-zA-Z\-]+)/\1/v, globalvariable/i" --exclude=test

Hope it helps others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment