diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa72a3..2225bd1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 19435ff..9115367 100755 --- a/README.md +++ b/README.md @@ -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` diff --git a/doc/haskell-snippets.txt b/doc/haskell-snippets.txt index 7a00c11..92e8c15 100644 --- a/doc/haskell-snippets.txt +++ b/doc/haskell-snippets.txt @@ -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) diff --git a/lua/haskell-snippets/expressions.lua b/lua/haskell-snippets/expressions.lua index 0616c75..7a981f9 100644 --- a/lua/haskell-snippets/expressions.lua +++ b/lua/haskell-snippets/expressions.lua @@ -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) @@ -49,6 +50,24 @@ 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 '), + dynamic(1, util.indent_newline_text('| ')), + insert(2), + text(' -> '), + insert(3), + dynamic(4, util.indent_newline_text('| ')), + insert(5), + text(' -> '), + insert(6), + dynamic(7, util.indent_newline_text('| otherwise -> ')), + insert(8), +}) +table.insert(expressions.all, expressions.if_expr_multiway) + expressions.case = s({ trig = 'case', dscr = 'Case expression (pattern match)',