Added emacs scripts
This commit is contained in:
89
.emacs.d/elpa/haskell-mode-13.12/snippets/README.md
Normal file
89
.emacs.d/elpa/haskell-mode-13.12/snippets/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Shnippet
|
||||
|
||||
|
||||
**Shnippet** is a collection of
|
||||
[YASnippet][yas]
|
||||
[Haskell][haskell] snippets for Emacs.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Clone repository:
|
||||
|
||||
$ cd ~/.emacs.d/snippets
|
||||
$ git clone https://github.com/LukeHoersten/shnippet
|
||||
OR
|
||||
$ hg clone https://bitbucket.org/LukeHoersten/shnippet
|
||||
|
||||
Add the cloned repository to YASnippet's `yas-snippet-dirs`:
|
||||
|
||||
(setq yas-snippet-dirs
|
||||
'("~/.emacs.d/snippets/shnippet"
|
||||
"/other/paths/"
|
||||
))
|
||||
|
||||
Snippets may have to be recompiled and reloaded in Emacs if YASnippet
|
||||
is already in use:
|
||||
|
||||
M-x yas-recompile-all
|
||||
M-x yas-reload-all
|
||||
|
||||
|
||||
Haskell snippts should now be available to use! In a `haskell-mode`
|
||||
buffer, type `fn<TAB>`. A prompt should appear asking which `fn`
|
||||
snippet to expand.
|
||||
|
||||
I **highly** recommend using YASnippet with [ido-mode]. Configure
|
||||
Emacs:
|
||||
|
||||
(setq-default yas-prompt-functions '(yas-ido-prompt yas-dropdown-prompt))
|
||||
|
||||
This is important so that alternatives (like `import` vs. `import
|
||||
qualified`) can quickly be selected with a single key stroke.
|
||||
|
||||
|
||||
## Available Expansion Keys
|
||||
|
||||
* `new` - newtype
|
||||
* `mod` - module [simple, exports]
|
||||
* `main ` - main module and funtion
|
||||
* `let` - let bindings
|
||||
* `lang` - language extension pragmas
|
||||
* `\` - lambda function
|
||||
* `inst` - instance declairation
|
||||
* `imp` - import modules [simple, qualified]
|
||||
* `if` - if conditional [inline, block]
|
||||
* `<-` - monadic get
|
||||
* `fn` - top level function [simple, guarded, clauses]
|
||||
* `data` - data type definition [inline, record]
|
||||
* `=>` - type constraint
|
||||
* `{-` - block comment
|
||||
* `case` - case statement
|
||||
|
||||
|
||||
## Design Ideals
|
||||
|
||||
* Keep snippet keys (the prefix used to auto-complete) to four
|
||||
characters or less while still being as easy to guess as possible.
|
||||
|
||||
* Have as few keys as possible. The more keys there are to remember,
|
||||
the harder snippets are to use and learn.
|
||||
|
||||
* Leverage [ido-mode][] when reasonable. For instance, to keep the
|
||||
number of snippet keys to a minimum as well as auto complete things
|
||||
like [Haskell Langauge Extension Pragmas][lang-pragma]. When
|
||||
multiple snippets share a key (ex: `fn`), the `ido-mode` prompts are
|
||||
unique to one character (ex: `guarded function` and `simple
|
||||
function` are `g` and `s` respectively).
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
This code is written and maintained by Luke Hoersten,
|
||||
<luke@hoersten.org>.
|
||||
|
||||
|
||||
[yas]: https://github.com/capitaomorte/yasnippet
|
||||
[ido-mode]: http://www.emacswiki.org/emacs/InteractivelyDoThings
|
||||
[lang-pragma]: http://hackage.haskell.org/packages/archive/Cabal/1.16.0.3/doc/html/Language-Haskell-Extension.html#t:KnownExtension
|
||||
[haskell]: http://haskell.org/
|
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: case
|
||||
# name: case
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
case ${1:x} of
|
||||
${2:Data} -> ${4:undefined}
|
||||
${3:Data} -> ${5:undefined}$0
|
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: {-
|
||||
# name: block comment
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
{- $0 -}
|
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: =>
|
||||
# name: Type constraint
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
(${1:Class} ${2:m}) => $0
|
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: data
|
||||
# name: inline data
|
||||
# condition: (= (length "data") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
data ${1:Type} = ${2:Data}$0 ${3:deriving (${4:Show, Eq})}
|
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: data
|
||||
# name: record data
|
||||
# condition: (= (length "data") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
data ${1:Type} = $1
|
||||
{ ${2:field} :: ${3:Type}
|
||||
, ${4:field} :: ${5:Type}$0
|
||||
} ${6:deriving (${7:Show, Eq})}
|
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fn
|
||||
# name: simple function
|
||||
# condition: (= (length "fn") (current-column))
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
${1:f} :: ${2:a} ${3:-> ${4:b}}
|
||||
$1 ${5:x} = ${6:undefined}$0
|
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fn
|
||||
# name: clause function
|
||||
# condition: (= (length "fn") (current-column))
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
${1:f} :: ${2:a} ${3:-> ${4:b}}
|
||||
$1 ${5:pattern} = ${7:undefined}
|
||||
$1 ${6:pattern} = ${8:undefined}$0
|
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fn
|
||||
# name: guarded function
|
||||
# condition: (= (length "fn") (current-column))
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
${1:f} :: ${2:a} ${3:-> ${4:b}}
|
||||
$1 ${5:x}
|
||||
| ${6:conditional} = ${8:undefined}
|
||||
| ${7:conditional} = ${9:undefined}$0
|
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: <-
|
||||
# name: monadic get
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
${1:x} <- ${2:undefined}$0
|
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: if
|
||||
# name: block if
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
if ${1:condition}
|
||||
then ${2:undefined}
|
||||
else ${3:undefined}$0
|
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: if
|
||||
# name: inline if
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
if ${1:condition} then ${2:undefined} else ${3:undefined}$0
|
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: imp
|
||||
# name: simple import
|
||||
# condition: (= (length "imp") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
import ${1:Module} ${2:(${3:f})}
|
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: imp
|
||||
# name: qualified import
|
||||
# condition: (= (length "imp") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
import qualified ${1:Module} as ${2:${1:$(let ((name (car (last (split-string yas-text "\\\.")))))
|
||||
(if (= 0 (length name)) ""
|
||||
(subseq name 0 1)))}}$0
|
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: inst
|
||||
# name: instance
|
||||
# condition: (= (length "inst") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
instance ${1:Class} ${2:Data} where
|
||||
${3:f} = ${4:undefined}$0
|
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: \
|
||||
# name: lambda
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
\\${1:x} -> ${2:undefined}$0
|
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: lang
|
||||
# name: language pragma
|
||||
# condition: (= (length "lang") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>, John Wiegley
|
||||
# --
|
||||
{-# LANGUAGE `(progn (require 'haskell-yas) (haskell-yas-complete "Extension: " haskell-yas-ghc-language-pragmas))` #-}
|
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: let
|
||||
# name: let
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
let ${1:x} = ${2:undefined}$0
|
13
.emacs.d/elpa/haskell-mode-13.12/snippets/haskell-mode/main
Normal file
13
.emacs.d/elpa/haskell-mode-13.12/snippets/haskell-mode/main
Normal file
@@ -0,0 +1,13 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: main
|
||||
# name: main module
|
||||
# condition: (= (length "main") (current-column))
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
module Main where
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
${1:undefined}$0
|
||||
return ()
|
@@ -0,0 +1,14 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: mod
|
||||
# name: simple module
|
||||
# condition: (= (length "mod") (current-column))
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
module ${1:`(if (not buffer-file-name) "Module"
|
||||
(let ((name (file-name-sans-extension (buffer-file-name))))
|
||||
(if (search "src/" name)
|
||||
(replace-regexp-in-string "/" "." (car (last (split-string name "src/"))))
|
||||
(file-name-nondirectory name))))`} where
|
||||
|
||||
$0
|
@@ -0,0 +1,17 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: mod
|
||||
# name: exports module
|
||||
# condition: (= (length "mod") (current-column))
|
||||
# expand-env: ((yas-indent-line 'fixed))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
module ${1:`(if (not buffer-file-name) "Module"
|
||||
(let ((name (file-name-sans-extension (buffer-file-name))))
|
||||
(if (search "src/" name)
|
||||
(replace-regexp-in-string "/" "." (car (last (split-string name "src/"))))
|
||||
(file-name-nondirectory name))))`}
|
||||
( ${3:export}
|
||||
${4:, ${5:export}}
|
||||
) where
|
||||
|
||||
$0
|
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: new
|
||||
# name: newtype
|
||||
# condition: (= (length "new") (current-column))
|
||||
# contributor: Luke Hoersten <luke@hoersten.org>
|
||||
# --
|
||||
newtype ${1:Type} = $1 { un$1 :: ${2:a} } ${3:deriving (${4:Show, Eq})}
|
Reference in New Issue
Block a user