1.. _ctags-lang-elm(7): 2 3============================================================== 4ctags-lang-elm 5============================================================== 6------------------------------------------------------------------- 7Random notes about tagging Elm source code with Universal Ctags 8------------------------------------------------------------------- 9:Version: @VERSION@ 10:Manual group: Universal Ctags 11:Manual section: 7 12 13SYNOPSIS 14-------- 15| **@CTAGS_NAME_EXECUTABLE@** ... --languages=+Elm ... 16| **@CTAGS_NAME_EXECUTABLE@** ... --language-force=Elm ... 17| **@CTAGS_NAME_EXECUTABLE@** ... --map-Elm=+.elm ... 18 19DESCRIPTION 20----------- 21The Elm parser is a PEG parser using PackCC, which is part of the 22ctags infrastructure. It should correctly process all top level 23statements, however there is a limitation with functions embedded 24in let/in blocks. They will mostly be fine, but sometimes a 25function in a let/in block will be omitted. 26 27EXAMPLES 28-------- 29 30Imports 31~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 33Imported modules are tagged, and their role is "imported", not "def". 34Types, functions, etc which are exposed via imported module have their 35role as "exposed". 36 37Exposed items are marked as being in the scope of their own module, 38not the module that's doing the importing. 39 40"input.elm" 41 42.. code-block:: Elm 43 44 module SomeMod exposing (..) 45 46 import MyMod exposing 47 ( map 48 , Maybe 49 , Result(..) 50 , MyList(Empty) 51 ) 52 53"output.tags" 54with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" 55 56.. code-block:: tags 57 58 SomeMod input.elm /^module SomeMod exposing (..)$/;" m roles:def 59 MyMod input.elm /^import MyMod exposing$/;" m roles:imported 60 map input.elm /^ ( map$/;" f module:MyMod roles:exposed 61 Maybe input.elm /^ , Maybe$/;" t module:MyMod roles:exposed 62 Result input.elm /^ , Result(..)$/;" t module:MyMod roles:exposed 63 MyList input.elm /^ , MyList(Empty)$/;" t module:MyMod roles:exposed 64 Empty input.elm /^ , MyList(Empty)$/;" c type:MyMod.MyList roles:exposed 65 66Namespaces 67~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 69Namespaces are tagged and their role is "def". 70 71"input.elm" 72 73.. code-block:: Elm 74 75 module AMod exposing (..) 76 77 import MyImport as NSpace exposing (impFunc) 78 79"output.tags" 80with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" 81 82.. code-block:: tags 83 84 AMod input.elm /^module AMod exposing (..)$/;" m roles:def 85 NSpace input.elm /^import MyImport as NSpace exposing (impFunc)$/;" n module:AMod roles:def moduleName:MyImport 86 MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported 87 impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:exposed 88 89Type names 90~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 91 92Constructors top level functions will have type names. 93 94"input.elm" 95 96.. code-block:: Elm 97 98 funcA : Int -> Int 99 funcA a = a + 1 100 101 type B 102 = B1Cons 103 { x : Float 104 , y : Float 105 } 106 | B2Cons String Integer 107 | B3Cons 108 109"output.tags" 110with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" 111 112.. code-block:: tags 113 114 funcA input.elm /^funcA a = a + 1$/;" f typeref:typename:Int -> Int roles:def 115 B input.elm /^type B$/;" t roles:def 116 B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:typename:{ x : Float , y : Float } -> B roles:def 117 B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:typename:String -> Integer -> B roles:def 118 B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:typename:B roles:def 119 120Function parameter lists 121~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 123Function parameter lists can be extracted into the tags file 124signature field. They are not really function signatures, but 125it's the closest concept available in ctags. 126Use "--fields=+S". 127 128.. code-block:: Elm 129 130 funcA a1 a2 = 131 a1 + a2 132 133"output.tags" 134with "--sort=no --extras=+r --fields=+rS" 135 136.. code-block:: tags 137 138 funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def 139 140KNOWN LIMITATIONS 141----------------- 142The ctags signature field is used for function parameter lists, even 143though it's not an idea field. See above. 144 145Elm requires all statements at the same logical level to have the 146same indentation. If there is additional indentation that line is part 147of the previous one. Therefore without over-complicating the 148PEG parser we have the following limitations... 149 150Sometimes functions in let/in blocks will be omitted. 151 152Functions in let/in blocks will be marked as being in the scope of their 153outer function, regardless of how deeply nested the let/in block is. 154 155Functions in let/in blocks won't have type names. 156 157SEE ALSO 158-------- 159ctags(1), ctags-client-tools(7) 160