arcsector / vscode-splunk-search-syntax

VScode syntax highlighting for SPL
MIT License
9 stars 6 forks source link

Better comments #10

Closed dgcom closed 2 years ago

dgcom commented 2 years ago

Great and very useful extension, hope it can be improved with the following:

Currently, comments are inserted with File-Block Comment and Line comment are

`comment(" text ")`

It would be great to replace this with new comment style with three backs apostrophes as documented here Add comments to searches That is easy to implement - just change one line in language-configuration.json

But I find that (optionally, off by default) adding line comment in C style (//) helps even more - for people who use VS Code to keep SPL repository and not actually running queries from it. This requires a bit more work modifying tmLanguage files but I am not completely sure how to implement this optionally.

dgcom commented 2 years ago

I ended up with the following in language-configuration.json for now:

    "comments": {
        "blockComment": ["```\n", "\n```"],
        "lineComment": "``` ```"
    },

This allows me to have two hotkeys to write (or wrap) larger comments (ex. explaining SPL) and also quickly insert template for single line or embedded comment.

Would be great if something like this (perhaps configurable) can be added to the extension, so I won't lose the changes every time it is updated...

arcsector commented 2 years ago

I think that for backwards compatibility's sake, we'll make the lineComment the tradditional comment macro and the blockComment will be the backticks you've suggested:

    "comments": {
        "lineComment": "`comment(\" \")`",
        "blockComment": ["```\n", "\n```"],
    },
arcsector commented 2 years ago

Added in v1.5.2 at e05a16b

dgcom commented 2 years ago

That great, thanks a lot. Still, I think making this easily configurable (and preserved through updates) makes more sense, but I am not sure if that can be easily implemented.

arcsector commented 2 years ago

It might be possible to provide a quote setting that can be configured through vscode settings which toggles the legacy or new block/line comments.

dgcom commented 2 years ago

That would already be a great option for users!