Giter Club home page Giter Club logo

Comments (8)

RepeatDaily avatar RepeatDaily commented on August 30, 2024 2

@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.

heaths avatar heaths commented on August 30, 2024 1

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.

heaths avatar heaths commented on August 30, 2024

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.

heaths avatar heaths commented on August 30, 2024

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.

anntzer avatar anntzer commented on August 30, 2024

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.

heaths avatar heaths commented on August 30, 2024

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.

anntzer avatar anntzer commented on August 30, 2024

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.

anntzer avatar anntzer commented on August 30, 2024

Effectively "closed" by #39.

from vim-ps1.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.