Comments (8)
@anntzer I agree.
@heaths I happen to use original casing nearly always, as do many others, obviously. Every best practice guide I've seen - including ones from Microsoft - strongly encourage developers to Use-FullCmdletNames; for example This one. At the very least it should be togglable as @anntzer suggested.
In fact, I was just looking at this the other day as I'd run into the same issue as @anntzer
from vim-ps1.
Instead of,
+syn match ps1Function
+ \ /\v(add|clear|close|copy|enter|exit|find|format|get|hide|join|lock|move|new|open|optimize|pop|push|redo|remove|rename|reset|search|select|Set|show|skip|split|step|switch|undo|unlock|watch)(-\w+)+/
Perhaps,
+syn match ps1Function /\v(add|clear|close|copy|enter|exit|find|format|get|hide|join|lock|move|new|open|optimize|pop|push|redo|remove|rename|reset|search|select|Set|show|skip|split|step|switch|undo|unlock|watch)(-\w+)+/
from vim-ps1.
Few scripts I've seen - and almost none I've written - use original casing for cmdlets. However, I'd be open to a change that only recognizes dashed words that start with an approved verb, i.e. output from get-verb
.
from vim-ps1.
Best practice guidance does not equate to practical usage. Camel casing is not required. If you want to submit a PR for users to opt into this behavior, I will consider it.
from vim-ps1.
Here's a patch that only highlights dashed-words that start with an approved verb, as suggested in #32 (comment).
diff --git i/syntax/ps1.vim w/syntax/ps1.vim
index 85150f6..2d67d9e 100644
--- i/syntax/ps1.vim
+++ w/syntax/ps1.vim
@@ -57,16 +57,28 @@ syn match ps1Constant +\$^+
syn keyword ps1Keyword class define from using var
" Function declarations
-syn keyword ps1Keyword function nextgroup=ps1FunctionDeclaration skipwhite
-syn keyword ps1Keyword filter nextgroup=ps1FunctionDeclaration skipwhite
-syn keyword ps1Keyword workflow nextgroup=ps1FunctionDeclaration skipwhite
-syn keyword ps1Keyword configuration nextgroup=ps1FunctionDeclaration skipwhite
-syn keyword ps1Keyword class nextgroup=ps1FunctionDeclaration skipwhite
-syn keyword ps1Keyword enum nextgroup=ps1FunctionDeclaration skipwhite
-syn match ps1FunctionDeclaration /\w\+\(-\w\+\)*/ contained
+syn keyword ps1Keyword function nextgroup=ps1Function skipwhite
+syn keyword ps1Keyword filter nextgroup=ps1Function skipwhite
+syn keyword ps1Keyword workflow nextgroup=ps1Function skipwhite
+syn keyword ps1Keyword configuration nextgroup=ps1Function skipwhite
+syn keyword ps1Keyword class nextgroup=ps1Function skipwhite
+syn keyword ps1Keyword enum nextgroup=ps1Function skipwhite
-" Function invocations
-syn match ps1FunctionInvocation /\w\+\(-\w\+\)\+/
+" Function declarations and invocations
+syn match ps1Function
+ \ /\v(add|clear|close|copy|enter|exit|find|format|get|hide|join|lock|move|new|open|optimize|pop|push|redo|remove|rename|reset|search|select|Set|show|skip|split|step|switch|undo|unlock|watch)(-\w+)+/
+syn match ps1Function
+ \ /\v(connect|disconnect|read|receive|send|write)(-\w+)+/
+syn match ps1Function
+ \ /\v(backup|checkpoint|compare|compress|convert|convertfrom|convertto|dismount|edit|expand|export|group|import|initialize|limit|merge|mount|out|publish|restore|save|sync|unpublish|update)(-\w+)+/
+syn match ps1Function
+ \ /\v(debug|measure|ping|repair|resolve|test|trace)(-\w+)+/
+syn match ps1Function
+ \ /\v(approve|assert|build|complete|confirm|deny|deploy|disable|enable|install|invoke|register|request|restart|resume|start|stop|submit|suspend|uninstall|unregister|wait)(-\w+)+/
+syn match ps1Function
+ \ /\v(block|grant|protect|revoke|unblock|unprotect)(-\w+)+/
+syn match ps1Function
+ \ /\v(use)(-\w+)+/
" Type declarations
syn match ps1Type /\[[a-z_][a-z0-9_.,\[\]]\+\]/
@@ -162,8 +174,7 @@ if version >= 508 || !exists("did_ps1_syn_inits")
HiLink ps1Escape SpecialChar
HiLink ps1InterpolationDelimiter Delimiter
HiLink ps1Conditional Conditional
- HiLink ps1FunctionDeclaration Function
- HiLink ps1FunctionInvocation Function
+ HiLink ps1Function Function
HiLink ps1Variable Identifier
HiLink ps1Boolean Boolean
HiLink ps1Constant Constant
To avoid the large repetition I merged psFunctionDeclaration and psFunctionInvocation together, but I can also just dupe the thing.
How does that look to you? If you agree with the approach I can turn this into a PR (or you can apply the patch directly).
from vim-ps1.
Looks good, though I think I prefer the block of adds as a single line per verb group (which, BTW, I love that you did!). Not a big deal, though. Just a little harder to read this way, IMO. Up to you. I would accept a PR either way.
Thank you!
from vim-ps1.
I'm confused, do you prefer one line by verb group (as in the patch) or not? Either way is fine for me.
from vim-ps1.
Effectively "closed" by #39.
from vim-ps1.
Related Issues (18)
- Why the name of filetype is "ps1"? HOT 5
- vim on mac doesn't like the newline in line 7 HOT 5
- Doesn't work on gvim 7.4? HOT 8
- FileType detection not working with Vim 8.0 HOT 14
- Add to vim package index (vim-pi) HOT 1
- Indentation not correct when in block HOT 11
- UTF-8 with BOM is not recommended HOT 7
- Please help me install this plugin HOT 1
- Syntax highlighting isn't activated based on shebang
- Invalid ^M in config files HOT 2
- Unexpected highlighting for System.Data
- How do I close the terminal? HOT 3
- highlighting on cmdlet parameters HOT 1
- Simplify files for easier migration to vim/vim
- Use better versioning for tags HOT 2
- Why is 'formatoptions' j not enabled by default? HOT 2
- Indenting issues with commented lines (beginning with "#") HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-ps1.