Skip to content

Commit

Permalink
feat: add multi-way if
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorias committed Dec 4, 2023
1 parent ae6266e commit 1d0dce8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Expressions: Add multi-way if snippet (`ifmw`).

## [1.2.0] - 2023-11-12

### Added
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ ls.add_snippets('haskell', haskell_snippets, { key = 'haskell' })

![tty](https://github.com/mrcjkb/haskell-snippets.nvim/assets/12857160/8d0fbfeb-00c2-4644-b7a4-9d5993a852ea)

#### `haskell-snippets.expressions.if_expr_multiway`

- Trigger: `ifmw`

#### `haskell-snippets.expressions.lambdacase`

- Trigger: `\case`
Expand Down
1 change: 1 addition & 0 deletions doc/haskell-snippets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ExpressionSnippetCollection *ExpressionSnippetCollection*
Fields: ~
{if_expr} (Snippet) if expression
{if_expr_multiline} (Snippet) if expression (multi-line)
{if_expr_multiway} (Snippet) if expression (multi-way)
{case} (Snippet) case expression (pattern match)
{lambdacase} (Snippet) lambda case (pattern match)

Expand Down
18 changes: 18 additions & 0 deletions lua/haskell-snippets/expressions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
---@class ExpressionSnippetCollection
---@field if_expr Snippet if expression
---@field if_expr_multiline Snippet if expression (multi-line)
---@field if_expr_multiway Snippet if expression (multi-way)
---@field case Snippet case expression (pattern match)
---@field lambdacase Snippet lambda case (pattern match)

Expand Down Expand Up @@ -49,6 +50,23 @@ expressions.if_expr_multiline = s({
})
table.insert(expressions.all, expressions.if_expr_multiline)

expressions.if_expr_multiway = s({
trig = 'ifmw',
dscr = 'If expression (multi-way)',
}, {
text('if | '),
insert(1),
text(' -> '),
insert(2),
text { '', ' | ' },
insert(3),
text(' -> '),
insert(4),
text { '', ' | otherwise -> ' },
insert(5),
})
table.insert(expressions.all, expressions.if_expr_multiway)

expressions.case = s({
trig = 'case',
dscr = 'Case expression (pattern match)',
Expand Down

0 comments on commit 1d0dce8

Please sign in to comment.