Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make regex definitions extendable #53

Open
JK-TC opened this issue May 19, 2017 · 2 comments
Open

Make regex definitions extendable #53

JK-TC opened this issue May 19, 2017 · 2 comments

Comments

@JK-TC
Copy link
Contributor

JK-TC commented May 19, 2017

I have a few code conventions that I'm sure nobody else needs in their definitions, but wanted to be able to extend the definitions to add them. I also see several language requests here; I'm sure that having the ability to add your own definitions would help some folks out.

I hacked out my own solution to this, which basically involves merging a user-defined regex set onto the base regex set. In my solution, I also converted the regex files to CSON as I believe they don't need the ability to execute any arbitrary code as full blown coffeescript.

Note: This would add an extensions folder to the package, which should not be tracked by git. Also, adding styles for new list items would be up to the user in styles.less, but perhaps a default style could be given.

Excerpt of lib/symbols-list.coffee:

{$}                    = require('atom-space-pen-views')
CSON                   = require('cson')
path                   = require 'path'

# Load System and User regex
RegexListBase = CSON.load(path.join(__dirname, ".", "symbols-list-regex.cson"))
try RegexListExt = CSON.load(path.join(__dirname, "..", "extensions", "symbols-list-regex.cson")) catch e then RegexListExt = {}
RegexList = $.extend(true, {}, RegexListBase, RegexListExt)

Example overrides file extensions/symbols-list-regex.cson:

#Removes todo and fixme; Adds a custom item used to denote sections in code
text:
    html:
        php:
            regex:
                todo: false
                fixme: false
                comment_heading: /\/\/[ ]![ ]*(.+?)(?:[\r\n])/gmi

I'm happy to submit a pull request for this, if interested.

@dimitrik-fr
Copy link

Wow ! this would be really great !!

I'm exactly also looking on solution to change the defaults according development needs -- sometimes you want to see less, sometimes more (or add some specific to you extensions, etc.) and such a feature will perfectly cover this !

please, push it when you can !
Thank you !

Rgds,
-Dimitri

@natezander
Copy link

Are there currently any other existing ways to customize what appears or doesn't appear in the symbols list sidebar? Thanks for the great plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants