oleg-shilo / sublime-codemap

CodeMap - is a ST3 plugin for showing the code tree representing the code structure of the active view/document
MIT License
41 stars 4 forks source link

universal mapper #8

Closed mg979 closed 6 years ago

mg979 commented 6 years ago

Hi, I've been working on an universal mapper for CodeMap (and also fixing some wrong stuff that I found in my first PR). Anyway about the new mapper it looks like this at the moment:

img

On the left, the universal mapper that catches python syntax, in the center the same file but with no extension(so in 'undefined' mode). For now the mapper is tuned on python but I want to let it understand most file types. (line numbers are wrong, I'll fix them)

I also included a 'depth' setting, to control the depth of the map, you should be able to control it with shortcuts (like ctrl+alt+m, ctrl+alt+left/right or similar). You can see it on the right with depth=1. Depth should be very useful for nested files like json.

I made settings so that you can define the syntaxes directly from the settings file, by catching the regex you define. The universal script will handle the rest.

oleg-shilo commented 6 years ago

Thank you. From now on I will work on your PR.

Sorry, I an on a business trip and going through that large PR will not be easy for the next 2-3 weeks. But we will get there :)

mg979 commented 6 years ago

Thank you, I know it's a large PR and I wouldn't like it to be merged in master, because there are still some things to fix and improve. I'm not asking you to work on my PR because there are many differences and it would take a lot of time from your part, If you could make a dev branch, and then merge it there, it would be safer and much less stressing. I still have to confront well old behaviour and new behaviours, and see if there's something that has got worse somehow, and still fix a couple of bugs, definitely it's not ready for a merge in master. Thank you for your time.

Acecool commented 6 years ago

You should probably code it like I'm coding mine - something which can be included in any mapper and then in the mapper you define rules - Take a look at some of the last posts to see what I'm talking about - https://forum.sublimetext.com/t/codemap-interactive-code-tree-plugin/26056/12

It'll handle a lot of different things simply by defining rules and there'll be config you can define to change the appearance...

-Josh 'Acecool' Moser Acecool Company Hendersonville, N.C. or Charleston, S.C. Tel.: +1.843.580.2134

This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute, or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. Therefore, the sender does not accept liability for any errors or omissions in the contents of this message, which may arise as a result of e-mail transmission.

On Sat, Sep 23, 2017 at 4:46 PM, mg979 notifications@github.com wrote:

Thank you, I know it's a large PR and I wouldn't like it to be merged in master, because there are still some things to fix and improve. I'm not asking you to work on my PR because there are many differences and it would take a lot of time from your part, If you could make a dev branch, and then merge it there, it would be safer and much less stressing. I still have to confront well old behaviour and new behaviours, and see if there's something that has got worse somehow, and still fix a couple of bugs, definitely it's not ready for a merge in master. Thank you for your time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oleg-shilo/sublime-codemap/issues/8#issuecomment-331668861, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-xyHsxgk60PpDLUWf8VMGhmLm9-WtKks5slW4tgaJpZM4Pf74j .

mg979 commented 6 years ago

@Acecool If I understood well, you're making a custom mapper for Lua, that's fine because the way I'm structuring the 'generalist' mapper is compatible with more specific custom mappers.

You can find my current script for the universal mapper here

The way I'm structuring it, is:

  1. read the settings file, where regexes for the universal mapper are stored. There you can also read how the mapper works.

  2. if extension isn't defined, look for a custom mapper

  3. if there is no custom mapper available, use the "universal" proper, a fallback for unknown file types.

Having custom mappers make things better, if a good custom mapper is included, but I want to give also an easier option to define or tweak the mappings through regexes defined in the settings. I also want to make it so, that for unknown wile types it will choose the best among the available options. Also, for now only this central mapper supports the depth system, so if you want to make use of it in your mapper you should code the support for it (it would simply involve detecting indent level and adding a check like here).

Then if you find the script for the generalist mapper could be better, make your suggestion. To have a better template for custom mappers would be also good, one that includes support for depth and multiple indent levels.