Skip to content

Commit

Permalink
add data, newtype, and typeclass instances to Haskell jumper
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jun 14, 2021
1 parent 777344f commit 4afb8dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkgs/kak-tree-grepper/rc/kak-tree-grepper.kak
Expand Up @@ -68,7 +68,7 @@ define-command -override -docstring "jump somewhere in an Haskell file's definit
# do the magic!
# note: tree-sitter-haskell doesn't distinguish between imports and
# import-hidings, so we just show the entire import statements.
QUERY="(import)@import (signature)@signature (function name: (_)@function) (pat_name (_)@name)"
QUERY="(import)@import (signature)@signature (function name: (_)@function) (pat_name (_)@name) (adt (type)@data) (data_constructor)@constructor (newtype (type)@newtype) (newtype_constructor)@constructor (instance_head)@instance"

EDIT_LOCATION="$("$TREE_GREPPER" --language haskell "$QUERY" "$FILE" | fzf --with-nth 4.. --nth 2,1 --delimiter=: --query "$FZF_QUERY" --select-1 | cut -d : -f 1-3 | tr : ' ')"
printf "evaluate-commands -client %s edit %s\n" "$CLIENT" "$EDIT_LOCATION" | indiekak -p "$SESSION"
Expand Down
7 changes: 7 additions & 0 deletions sample-projects/haskell/Main.hs
Expand Up @@ -52,3 +52,10 @@ functionWithArgs a b = a ++ b
lambdaWithArgs :: String -> String -> String
-- (function name: (variable) rhs: (exp_lambda (pat_name (variable)) (pat_name (variable)) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))))
lambdaWithArgs = \a b -> a ++ b

data Union = Ctor1 Int | Ctor2 String

newtype Thing = Thing String

instance Show Thing where
show (Thing inner) = inner

0 comments on commit 4afb8dc

Please sign in to comment.