elm-mode icon indicating copy to clipboard operation
elm-mode copied to clipboard

Proposal: highlight exposed functions

Open BuddhiLW opened this issue 3 years ago • 1 comments

Although imports itself are colored, the elements exposed are not. This makes the code look very "monotonic".

Example of what I'm saying. Html.Events is highlighted, but the onClick is not. I would appreciate if I could modulate the color of these exposed functions.

pic-selected-220131-1435-21

In text format:

import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Random


urlPrefix : String
urlPrefix =
    "http://elm-in-action.com/"


type Msg
    = ClickedPhoto String
    | ClickedSize ThumbnailSize
    | ClickedSurpriseMe


view : Model -> Html Msg
view model =
    div [ class "content" ]
        [ h1 [] [ text "Photo Groove" ]
        , button [ Html.Events.onClick ClickedSurpriseMe ] [ text "Surprise Me!" ]
        ]

Also, self-made functions and imported ones could have close colors, but slightly different.

Maybe to be considered in the same vein: self-declared variables, like urlPrefix in my code, which has color only when being declared, but not in the code itself. Local and global variables in a file could be colored with slightly different colors.

As it is, my code is monotonically white... These two excerpts-images I linked have both examples of all the things I mentioned, urlPrefix, model, onClick etc.

pic-selected-220131-1446-44

In text format:

view : Model -> Html Msg
view model =
    div [ class "content" ]
        [ h1 [] [ text "Photo Groove" ]
        , button [ Html.Events.onClick ClickedSurpriseMe ] [ text "Surprise Me!" ]
        , h3 [] [ text "Thumbnail Size:" ]
        , div [ id "choose-size" ]
            (List.map viewSizeChooser [ Small, Medium, Large ])
        , div [ id "thumbnails", class (sizeToString model.chosenSize) ]
            (List.map (viewThumbnail model.selectedUrl) model.photos)
        , img
            [ class "large"
            , src (urlPrefix ++ "large/" ++ model.selectedUrl)
            ]
            []
        ]

BuddhiLW avatar Jan 31 '22 17:01 BuddhiLW

I don't think it would be practical to get into any colouring that would require semantic analysis. Presumably you'd want "onClick" to be highlighted the same whether it was imported qualified or unqualified, and that would be hard!

purcell avatar Feb 01 '22 10:02 purcell