oleg-shilo / codemap.vscode

Code map (syntax tree) of the active document
MIT License
84 stars 28 forks source link

Simplify mapping rules for Python #18

Closed egabrum closed 5 years ago

egabrum commented 5 years ago

I think the default mapping for Python can be improved (no need to show "class" or "def")

Maybe something like: (although I can't seem to be able to get rid of the first bracket after the class/function name)

   "codemap.py": [
      {
         "pattern": "(?<![^\\r\\n\\t\\f\\v .])class (.*?)[(|:]",
         "clear": "class|:|(",
         "prefix": "",
         "role": "class",
         "icon": "class"
      },
      {
         "pattern": "def (.*?)[(|:]",
         "clear": "def|:|(",
         "suffix": "",
         "role": "function",
         "icon": "function"
      }
   ],
egabrum commented 5 years ago

Works great for me on 1.10.0 There can be false detections if a doc string contains "class" and ":" in the same line, but this should be rare. Thanks!

oleg-shilo commented 5 years ago

Not a problem. Cheers.