Skip to content

Instantly share code, notes, and snippets.

@groteck
Last active February 21, 2019 11:03
Show Gist options
  • Save groteck/85462b3576c23682fb3f6b2194c57bce to your computer and use it in GitHub Desktop.
Save groteck/85462b3576c23682fb3f6b2194c57bce to your computer and use it in GitHub Desktop.
Elm ctags
port module Main exposing (..)
import List
import Maybe exposing (withDefault)
import Json.Encode as Je
type Thing
= One
| Two Int
type Param a
= Cons a
| Other a
type alias Num =
Int
port outward : String -> Cmd a
port inward : (b -> a) -> Sub a
foo : Int -> Int
foo a =
a + 1
fooMultiLine :
Int
-> Int
fooMiltiLine a =
a + 1
bar =
let
bas =
1
in
bas
--langdef=unknown
--map-unknown=+.unknown
--kinddef-unknown=m,module,Module
--kinddef-unknown=n,namespace,Renamed Imported Module
--kinddef-unknown=p,port,Port
--kinddef-unknown=t,type,Type Definition
--kinddef-unknown=c,constructor,Type Constructor
--kinddef-unknown=a,alias,Type Alias
--kinddef-unknown=f,function,Functions
--_roledef-unknown=m.imported,imported module
--_fielddef-unknown=signature,signatures
--regex-unknown=/^(port[[:blank:]]+)?module[[:blank:]]+([[:upper:]][[:alnum:]_.]*)/\2/m/{scope=push}{exclusive}
--regex-unknown=/^import[[:blank:]]+[[:alnum:]_.]+[[:blank:]]+as[[:blank:]]+([[:alnum:]]+)/\1/n/{scope=clear}{exclusive}
#
# Following two patterns are just for clearing scope stack.
# X in "import X" should be captured as a reference tag in the future.
#
# Ideal Regexp to get the signature with multi line function signatures:
# ^([[:lower:]][[:alnum:]_]+)[[:blank:]]:((\n[[:blank:]].*)+|[[:blank:]].*)\n(([[:lower:]][[:alnum:]_]+).*)=
--regex-unknown=/^import[[:blank:]]+([[:alnum:]_.]+)[[:blank:]]exposing/\1/m/{scope=clear}{exclusive}{_role=imported}
--regex-unknown=/^import[[:blank:]]+([[:alnum:]_.]+)/\1/m/{scope=clear}{exclusive}{_role=imported}
--regex-unknown=/^port[[:blank:]]+([[:lower:]][[:alnum:]_]*).*/\1/p/{scope=clear}{exclusive}
--regex-unknown=/^type +([[:upper:]][[:alnum:]_]*.*)/\1/t/{scope=set}{exclusive}
--regex-unknown=/^[[:blank:]]+[|=][[:blank:]]+([[:upper:]][[:alnum:]_]*.*)$/\1/c/{scope=ref}{exclusive}
--regex-unknown=/^type[[:blank:]]+alias[[:blank:]]+([[:upper:]][[:alnum:]_]*[[:blank:][:alnum:]_]*)/\1/a/{scope=set}{exclusive}
--mline-regex-unknown=/^([[:lower:]][[:alnum:]_]+)[[:blank:]]:((\n[[:blank:]].*)+|[[:blank:]].*)\n(([[:lower:]][[:alnum:]_]+).*)=/\4/f/{mgroup=2}{_field=signature:(\2)}{scope=clear}{exclusive}
--regex-unknown=/^[[:blank:]]+([[:lower:]_][[:alnum:]_]*)[^=]*=$/\1/f/{scope=ref}
--fields-unknown=+{signature}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment