Skip to content

Commit

Permalink
semantic config keys use lower case in the first element
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon committed Jan 12, 2024
1 parent 6653b03 commit 4d11ac7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

module Ide.Plugin.SemanticTokens.SemanticConfig where

import Data.Char (toLower)
import Data.Default (def)
import qualified Data.Set as S
import qualified Data.Text as T
Expand Down Expand Up @@ -35,6 +36,10 @@ lspTokenTypeDescriptions =
allHsTokenTypes :: [HsSemanticTokenType]
allHsTokenTypes = enumFrom minBound

lowerFirst :: String -> String
lowerFirst [] = []
lowerFirst (x:xs) = toLower x : xs

allHsTokenNameStrings :: [String]
allHsTokenNameStrings = map (drop 1 . show) allHsTokenTypes

Expand All @@ -60,9 +65,9 @@ mkSemanticConfigFunctions = do
let semanticConfigPropertiesName = mkName "semanticConfigProperties"
let useSemanticConfigActionName = mkName "useSemanticConfigAction"
let
allLabels = map LabelE allHsTokenNameStrings
allLabels = map (LabelE . lowerFirst) allHsTokenNameStrings
allFieldsNames = map (mkName . toConfigName) allHsTokenNameStrings
allVariableNames = map (mkName . ("variable_" <>) . toConfigName) allHsTokenNameStrings
allVariableNames = map (mkName . ("_variable_" <>) . toConfigName) allHsTokenNameStrings
-- <- useSemanticConfigAction label pid config
mkGetProperty (variable, label) =
BindS
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-semantic-tokens-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ semanticTokensConfigTest = testGroup "semantic token config test" [
testCase "function to variable" $ do
let content = Text.unlines ["module Hello where", "go _ = 1"]
let fs = mkFs $ directFile "Hello.hs" content
let funcVar = object ["Function" .= var]
let funcVar = object ["function" .= var]
var :: String
var = "variable"
do
Expand Down

0 comments on commit 4d11ac7

Please sign in to comment.