7ute / symbols-list

An alternate symbol list sidebar for Atom.io text editor
GNU General Public License v3.0
32 stars 24 forks source link

Make regex definitions extendable #53

Open JK-TC opened 7 years ago

JK-TC commented 7 years ago

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 commented 6 years ago

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 commented 4 years ago

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!