From 169b84f111aa16b4032c22861ce958f563f66dc7 Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Sat, 14 Sep 2024 16:37:30 +0700 Subject: [PATCH] seito: Add --vim-config --- .gitattributes | 1 + .github/workflows/build.yml | 27 ++- README.md | 18 +- driver/seito.hs | 4 +- package.yaml | 4 +- sensei.cabal | 17 +- src/Client.hs | 5 +- test/ClientSpec.hs | 12 +- vim/sensei.test.vim | 165 ++++++++++++++++++ vim/sensei.vim | 18 ++ vim/test/assets/generate.sh | 18 ++ vim/test/assets/hspec.hs | 6 + vim/test/assets/hspec.hs.errors | 14 ++ vim/test/assets/lexical-error.hs | 1 + .../assets/lexical-error.hs.ghc-9.10.1.errors | 4 + .../assets/lexical-error.hs.ghc-9.2.8.errors | 4 + .../assets/lexical-error.hs.ghc-9.4.8.errors | 4 + .../assets/lexical-error.hs.ghc-9.6.6.errors | 4 + .../assets/lexical-error.hs.ghc-9.8.2.errors | 4 + vim/test/assets/parse-error.hs | 2 + .../assets/parse-error.hs.ghc-9.10.1.errors | 5 + .../assets/parse-error.hs.ghc-9.2.8.errors | 5 + .../assets/parse-error.hs.ghc-9.4.8.errors | 5 + .../assets/parse-error.hs.ghc-9.6.6.errors | 5 + .../assets/parse-error.hs.ghc-9.8.2.errors | 5 + vim/test/assets/suggested-fix-multiline.hs | 5 + ...ggested-fix-multiline.hs.ghc-9.10.1.errors | 11 ++ ...uggested-fix-multiline.hs.ghc-9.2.8.errors | 9 + ...uggested-fix-multiline.hs.ghc-9.4.8.errors | 11 ++ ...uggested-fix-multiline.hs.ghc-9.6.6.errors | 11 ++ ...uggested-fix-multiline.hs.ghc-9.8.2.errors | 11 ++ vim/test/assets/suggested-fix.hs | 5 + .../assets/suggested-fix.hs.ghc-9.10.1.errors | 9 + .../assets/suggested-fix.hs.ghc-9.2.8.errors | 9 + .../assets/suggested-fix.hs.ghc-9.4.8.errors | 9 + .../assets/suggested-fix.hs.ghc-9.6.6.errors | 9 + .../assets/suggested-fix.hs.ghc-9.8.2.errors | 9 + vim/test/assets/type-error.hs | 2 + .../assets/type-error.hs.ghc-9.10.1.errors | 6 + .../assets/type-error.hs.ghc-9.2.8.errors | 8 + .../assets/type-error.hs.ghc-9.4.8.errors | 8 + .../assets/type-error.hs.ghc-9.6.6.errors | 6 + .../assets/type-error.hs.ghc-9.8.2.errors | 6 + vim/test/run.vim | 31 ++++ vim/test/watch.sh | 6 + 45 files changed, 511 insertions(+), 27 deletions(-) create mode 100644 vim/sensei.test.vim create mode 100644 vim/sensei.vim create mode 100755 vim/test/assets/generate.sh create mode 100644 vim/test/assets/hspec.hs create mode 100644 vim/test/assets/hspec.hs.errors create mode 100644 vim/test/assets/lexical-error.hs create mode 100644 vim/test/assets/lexical-error.hs.ghc-9.10.1.errors create mode 100644 vim/test/assets/lexical-error.hs.ghc-9.2.8.errors create mode 100644 vim/test/assets/lexical-error.hs.ghc-9.4.8.errors create mode 100644 vim/test/assets/lexical-error.hs.ghc-9.6.6.errors create mode 100644 vim/test/assets/lexical-error.hs.ghc-9.8.2.errors create mode 100644 vim/test/assets/parse-error.hs create mode 100644 vim/test/assets/parse-error.hs.ghc-9.10.1.errors create mode 100644 vim/test/assets/parse-error.hs.ghc-9.2.8.errors create mode 100644 vim/test/assets/parse-error.hs.ghc-9.4.8.errors create mode 100644 vim/test/assets/parse-error.hs.ghc-9.6.6.errors create mode 100644 vim/test/assets/parse-error.hs.ghc-9.8.2.errors create mode 100644 vim/test/assets/suggested-fix-multiline.hs create mode 100644 vim/test/assets/suggested-fix-multiline.hs.ghc-9.10.1.errors create mode 100644 vim/test/assets/suggested-fix-multiline.hs.ghc-9.2.8.errors create mode 100644 vim/test/assets/suggested-fix-multiline.hs.ghc-9.4.8.errors create mode 100644 vim/test/assets/suggested-fix-multiline.hs.ghc-9.6.6.errors create mode 100644 vim/test/assets/suggested-fix-multiline.hs.ghc-9.8.2.errors create mode 100644 vim/test/assets/suggested-fix.hs create mode 100644 vim/test/assets/suggested-fix.hs.ghc-9.10.1.errors create mode 100644 vim/test/assets/suggested-fix.hs.ghc-9.2.8.errors create mode 100644 vim/test/assets/suggested-fix.hs.ghc-9.4.8.errors create mode 100644 vim/test/assets/suggested-fix.hs.ghc-9.6.6.errors create mode 100644 vim/test/assets/suggested-fix.hs.ghc-9.8.2.errors create mode 100644 vim/test/assets/type-error.hs create mode 100644 vim/test/assets/type-error.hs.ghc-9.10.1.errors create mode 100644 vim/test/assets/type-error.hs.ghc-9.2.8.errors create mode 100644 vim/test/assets/type-error.hs.ghc-9.4.8.errors create mode 100644 vim/test/assets/type-error.hs.ghc-9.6.6.errors create mode 100644 vim/test/assets/type-error.hs.ghc-9.8.2.errors create mode 100755 vim/test/run.vim create mode 100755 vim/test/watch.sh diff --git a/.gitattributes b/.gitattributes index 4d08d7f..b9fd748 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.cabal linguist-generated=true +/vim/test/assets/*.errors linguist-generated=true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d006000..10396a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: true matrix: os: - ubuntu-latest @@ -30,7 +31,8 @@ jobs: - os: macos-12 ghc: system steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - uses: hspec/setup-haskell@v1 with: ghc-version: ${{ matrix.ghc }} @@ -47,7 +49,7 @@ jobs: # https://github.com/actions/runner-images/blob/macOS-12/20230416.1/images/macos/macos-12-Readme.md#tools # # (on Linux this is a noop) - run: ghcup install cabal 3.10 --set + run: ghcup install cabal latest --set - shell: bash run: git config --global init.defaultBranch main @@ -66,6 +68,23 @@ jobs: env: HSPEC_OPTIONS: --color + - run: vim/test/run.vim + if: runner.os == 'Linux' + + - run: vim/test/assets/generate.sh + if: ${{ runner.os == 'Linux' && matrix.ghc != '9.4' }} + + - run: git diff --exit-code + + - shell: bash + run: | + untracked=$(git ls-files --others --exclude-standard) + if [ -n "$untracked" ]; then + echo "Untracked files:" + echo "$untracked" + exit 1 + fi + success: needs: build runs-on: ubuntu-latest @@ -75,6 +94,6 @@ jobs: - run: false if: needs.build.result != 'success' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check for trailing whitespace - run: '! git grep -I "\s\+$"' + run: "! git grep -nI '[[:blank:]]$' -- . ':!vim/test/assets'" diff --git a/README.md b/README.md index 0d209de..f7cf4d8 100644 --- a/README.md +++ b/README.md @@ -51,13 +51,14 @@ instead: ### Vim integration -You can use `sensei` to load the result of the last test run into your quickfix +You can use `seito` to load the results of the last test run into your quickfix list by executing `:make` in Vim. -For this to work, you can either create a `Makefile` or set `makeprg` to a -custom value. +For this to work, you can choose one out of three options: -(In both cases, `sed` is used to strip ANSI color sequences.) +1. Create a `Makefile` +2. Set `makeprg` to a custom value +3. Use [`sensei.vim`](vim/sensei.vim) #### Option 1: Create a `Makefile` @@ -78,6 +79,15 @@ Add the following to your Vim configuration (e.g. :set makeprg=seito ``` +#### Option 3: Use `sensei.vim`: + +Add the following to your Vim configuration (e.g. +`~/.vim/after/ftplugin/haskell.vim`): + +```vim +execute 'source ' . system('seito --vim-config') +``` + ### Emacs integration Similarly, you can use `sensei` to load the result of the last test run into an diff --git a/driver/seito.hs b/driver/seito.hs index 7c1f760..44a815b 100644 --- a/driver/seito.hs +++ b/driver/seito.hs @@ -5,10 +5,12 @@ import System.Environment import Control.Monad import qualified Data.ByteString.Lazy as L +import Paths_sensei (getDataFileName) + import Client main :: IO () main = do - (success, output) <- getArgs >>= client "" + (success, output) <- getArgs >>= client getDataFileName "" L.putStr output unless success exitFailure diff --git a/package.yaml b/package.yaml index 5f4548d..92c9369 100644 --- a/package.yaml +++ b/package.yaml @@ -17,8 +17,7 @@ default-extensions: - RecordWildCards - ViewPatterns -other-extensions: - - NoFieldSelectors +data-files: vim/sensei.vim dependencies: - base >= 4.11 && < 5 @@ -62,6 +61,7 @@ executables: seito: source-dirs: driver + generated-other-modules: Paths_sensei main: seito.hs tests: diff --git a/sensei.cabal b/sensei.cabal index 061e932..702199d 100644 --- a/sensei.cabal +++ b/sensei.cabal @@ -1,6 +1,6 @@ -cabal-version: 1.12 +cabal-version: 2.0 --- This file has been generated from package.yaml by hpack version 0.36.0. +-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack @@ -14,6 +14,8 @@ maintainer: Simon Hengel license: MIT license-file: LICENSE build-type: Simple +data-files: + vim/sensei.vim source-repository head type: git @@ -36,6 +38,9 @@ executable seito Session Trigger Util + Paths_sensei + autogen-modules: + Paths_sensei hs-source-dirs: src driver @@ -47,8 +52,6 @@ executable seito OverloadedStrings RecordWildCards ViewPatterns - other-extensions: - NoFieldSelectors ghc-options: -Wall -threaded build-depends: aeson @@ -105,8 +108,6 @@ executable sensei OverloadedStrings RecordWildCards ViewPatterns - other-extensions: - NoFieldSelectors ghc-options: -Wall -threaded build-depends: aeson @@ -163,8 +164,6 @@ executable sensei-web OverloadedStrings RecordWildCards ViewPatterns - other-extensions: - NoFieldSelectors ghc-options: -Wall -threaded build-depends: aeson @@ -236,8 +235,6 @@ test-suite spec OverloadedStrings RecordWildCards ViewPatterns - other-extensions: - NoFieldSelectors ghc-options: -Wall -threaded cpp-options: -DTEST build-tool-depends: diff --git a/src/Client.hs b/src/Client.hs index b3dc721..609dc7d 100644 --- a/src/Client.hs +++ b/src/Client.hs @@ -11,11 +11,12 @@ import qualified Data.ByteString.Lazy as L import HTTP (newSocket, socketName) -client :: FilePath -> [String] -> IO (Bool, L.ByteString) -client dir args = case args of +client :: (FilePath -> IO FilePath) -> FilePath -> [String] -> IO (Bool, L.ByteString) +client getDataFileName dir args = case args of [] -> hIsTerminalDevice stdout >>= run ["--no-color"] -> run False ["--color"] -> run True + ["--vim-config"] -> (,) True . fromString <$> getDataFileName "vim/sensei.vim" _ -> do hPutStrLn stderr $ "Usage: seito [ --color | --no-color ]" return (False, "") diff --git a/test/ClientSpec.hs b/test/ClientSpec.hs index 38dcfcd..21727c3 100644 --- a/test/ClientSpec.hs +++ b/test/ClientSpec.hs @@ -24,17 +24,21 @@ spec = do describe "client" $ do it "accepts --color" $ do withSuccess $ \ dir -> do - client dir ["--color"] `shouldReturn` (True, fromString $ withColor Green "success") + client return dir ["--color"] `shouldReturn` (True, fromString $ withColor Green "success") it "accepts --no-color" $ do withSuccess $ \ dir -> do - client dir ["--no-color"] `shouldReturn` (True, "success") + client return dir ["--no-color"] `shouldReturn` (True, "success") it "indicates failure" $ do withFailure $ \ dir -> do - client dir [] `shouldReturn` (False, "failure") + client return dir [] `shouldReturn` (False, "failure") context "when server socket is missing" $ do it "reports error" $ do withTempDirectory $ \ dir -> do - client dir [] `shouldReturn` (False, "could not connect to " <> fromString (socketName dir) <> "\n") + client return dir [] `shouldReturn` (False, "could not connect to " <> fromString (socketName dir) <> "\n") + + context "with --vim-config" $ do + it "returns a path to a Vim support file" $ do + client return undefined ["--vim-config"] `shouldReturn` (True, "vim/sensei.vim") diff --git a/vim/sensei.test.vim b/vim/sensei.test.vim new file mode 100644 index 0000000..06f109f --- /dev/null +++ b/vim/sensei.test.vim @@ -0,0 +1,165 @@ +source vim/sensei.vim + +function Require(actual, required) + for i in range(len(a:required)) + if a:actual[i] > a:required[i] + return 1 + elseif a:actual[i] < a:required[i] + return 0 + endif + endfor + return 1 +endfunction + +function GhcVersion(name) + return matchlist(a:name, '\vghc-(\d+)\.(\d+)\.(\d+)\.errors')[1:3] +endfunction + +function PopulateQuickFixList(name) + SUCCESS a:name + execute "cgetfile " . a:name + return filter(getqflist(), 'v:val.valid') +endfunction + +function GhcErrorsFor(name) + let errors = glob("vim/test/assets/" . a:name . ".*.errors", v:true, v:true) + call ShouldBe(len(errors), 5) + return errors +endfunction + +for name in GhcErrorsFor("lexical-error.hs") + let errors = PopulateQuickFixList(name) + call ShouldBe(len(errors), 1) + + let err = errors[0] + call ShouldBe(bufname(err.bufnr), "lexical-error.hs") + call ShouldBe(err.lnum, 1) + call ShouldBe(err.col, 11) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,6]) + call ShouldBe(err.nr, 21231) + else + call ShouldBe(err.nr, -1) + endif + call ShouldBe(err.text, "\n lexical error in string/character literal at character '\\n'") +endfor + +for name in GhcErrorsFor("parse-error.hs") + let errors = PopulateQuickFixList(name) + call ShouldBe(len(errors), 1) + + let err = errors[0] + call ShouldBe(bufname(err.bufnr), "parse-error.hs") + call ShouldBe(err.lnum, 1) + call ShouldBe(err.col, 1) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,8]) + call ShouldBe(err.nr, 25277) + else + call ShouldBe(err.nr, -1) + endif + call ShouldBe(err.text, "\n Parse error: module header, import declaration\n or top-level declaration expected.") +endfor + +for name in GhcErrorsFor("type-error.hs") + let errors = PopulateQuickFixList(name) + call ShouldBe(len(errors), 1) + + let err = errors[0] + call ShouldBe(bufname(err.bufnr), "type-error.hs") + call ShouldBe(err.lnum, 2) + call ShouldBe(err.col, 7) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,6]) + call ShouldBe(err.nr, 83865) + call ShouldBe(err.text, "\n Couldn't match type ‘Int’ with ‘[Char]’\n Expected: String\n Actual: Int") + else + call ShouldBe(err.nr, -1) + call ShouldBe(err.text, "\n • Couldn't match type ‘Int’ with ‘[Char]’\n Expected: String\n Actual: Int\n • In the expression: 23 :: Int\n In an equation for ‘foo’: foo = 23 :: Int") + endif +endfor + +for name in GhcErrorsFor("suggested-fix.hs") + let errors = PopulateQuickFixList(name) + call ShouldBe(len(errors), 2) + + let err = errors[0] + call ShouldBe(bufname(err.bufnr), "suggested-fix.hs") + call ShouldBe(err.lnum, 1) + call ShouldBe(err.col, 1) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,6]) + call ShouldBe(err.nr, 44432) + else + call ShouldBe(err.nr, -1) + endif + call ShouldBe(err.text, "\n The type signature for ‘foo’ lacks an accompanying binding") + + let err = errors[1] + call ShouldBe(bufname(err.bufnr), "suggested-fix.hs") + call ShouldBe(err.lnum, 4) + call ShouldBe(err.col, 1) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,6]) + call ShouldBe(err.nr, 44432) + else + call ShouldBe(err.nr, -1) + endif + call ShouldBe(err.text, "\n The type signature for ‘bar’ lacks an accompanying binding") +endfor + +for name in GhcErrorsFor("suggested-fix-multiline.hs") + let errors = PopulateQuickFixList(name) + call ShouldBe(len(errors), 2) + + let err = errors[0] + call ShouldBe(bufname(err.bufnr), "suggested-fix-multiline.hs") + call ShouldBe(err.lnum, 1) + call ShouldBe(err.col, 1) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,6]) + call ShouldBe(err.nr, 44432) + else + call ShouldBe(err.nr, -1) + endif + call ShouldBe(err.text, "\n The type signature for ‘foo’ lacks an accompanying binding") + + let err = errors[1] + call ShouldBe(bufname(err.bufnr), "suggested-fix-multiline.hs") + call ShouldBe(err.lnum, 4) + call ShouldBe(err.col, 1) + call ShouldBe(err.end_lnum, 0) + call ShouldBe(err.end_col, 0) + call ShouldBe(err.type, 'e') + if Require(GhcVersion(name), [9,6]) + call ShouldBe(err.nr, 44432) + else + call ShouldBe(err.nr, -1) + endif + call ShouldBe(err.text, "\n The type signature for ‘bar’ lacks an accompanying binding") +endfor + +let errors = PopulateQuickFixList("vim/test/assets/hspec.hs.errors") +call ShouldBe(len(errors), 1) + +let err = errors[0] +call ShouldBe(bufname(err.bufnr), "vim/test/assets/hspec.hs") +call ShouldBe(err.lnum, 6) +call ShouldBe(err.col, 11) +call ShouldBe(err.end_lnum, 0) +call ShouldBe(err.end_col, 0) +call ShouldBe(err.type, '') +call ShouldBe(err.nr, -1) +call ShouldBe(err.text, "") diff --git a/vim/sensei.vim b/vim/sensei.vim new file mode 100644 index 0000000..2d843d3 --- /dev/null +++ b/vim/sensei.vim @@ -0,0 +1,18 @@ +setlocal makeprg=seito + +" GHC +setlocal errorformat=%A%f:%l:%c:\ %t%*[^:]:\ [GHC-%n] +setlocal errorformat^=%A%f:%l:%c:\ %t%*[^:]: " GHC 9.6 + +" lines that start with a space continue the previous message +setlocal errorformat^=%+C\ %.%# + +" empty lines terminate a message +setlocal errorformat^=%Z + +" ignore this part of the message +setlocal errorformat^=%-G\ \ \ \ Suggested\ fix:%.%# +setlocal errorformat^=%-G\ \ \ \ \ \ Perhaps\ you\ meant\ %.%# " GHC 9.2 + +" Hspec +setlocal errorformat^=\ \ %f:%l:%c:\ .%# diff --git a/vim/test/assets/generate.sh b/vim/test/assets/generate.sh new file mode 100755 index 0000000..4a9604b --- /dev/null +++ b/vim/test/assets/generate.sh @@ -0,0 +1,18 @@ +#!/bin/bash +cabal exec -- runhaskell vim/test/assets/hspec.hs --expert --seed 0 --no-color > vim/test/assets/hspec.hs.errors +sed -i 's/Finished in 0.[0-9][0-9][0-9][0-9] seconds/Finished in 0.0005 seconds/' vim/test/assets/hspec.hs.errors + +cd vim/test/assets + +for name in $(ls *.hs | grep -v hspec); do + for ghc in ghc-9.6 ghc-9.8 ghc-9.10; do + if command -v "$ghc" >/dev/null 2>&1; then + $ghc -fno-diagnostics-show-caret -fno-show-error-context "$name" &> "$name.ghc-$($ghc --numeric-version).errors" + fi + done + for ghc in ghc-9.2 ghc-9.4; do + if command -v "$ghc" >/dev/null 2>&1; then + $ghc -fno-diagnostics-show-caret "$name" &> "$name.ghc-$($ghc --numeric-version).errors" + fi + done +done diff --git a/vim/test/assets/hspec.hs b/vim/test/assets/hspec.hs new file mode 100644 index 0000000..1522bfa --- /dev/null +++ b/vim/test/assets/hspec.hs @@ -0,0 +1,6 @@ +import Test.Hspec + +main :: IO () +main = hspec $ do + it "foo" $ do + "foo" `shouldBe` "bar" diff --git a/vim/test/assets/hspec.hs.errors b/vim/test/assets/hspec.hs.errors new file mode 100644 index 0000000..04cf9d6 --- /dev/null +++ b/vim/test/assets/hspec.hs.errors @@ -0,0 +1,14 @@ + +foo [✘] + +Failures: + + vim/test/assets/hspec.hs:6:11: + 1) foo + expected: "bar" + but got: "foo" + +Randomized with seed 0 + +Finished in 0.0005 seconds +1 example, 1 failure diff --git a/vim/test/assets/lexical-error.hs b/vim/test/assets/lexical-error.hs new file mode 100644 index 0000000..281b9f6 --- /dev/null +++ b/vim/test/assets/lexical-error.hs @@ -0,0 +1 @@ +foo = "bar diff --git a/vim/test/assets/lexical-error.hs.ghc-9.10.1.errors b/vim/test/assets/lexical-error.hs.ghc-9.10.1.errors new file mode 100644 index 0000000..a13ccdb --- /dev/null +++ b/vim/test/assets/lexical-error.hs.ghc-9.10.1.errors @@ -0,0 +1,4 @@ +[1 of 2] Compiling Main ( lexical-error.hs, lexical-error.o ) +lexical-error.hs:1:11: error: [GHC-21231] + lexical error in string/character literal at character '\n' + diff --git a/vim/test/assets/lexical-error.hs.ghc-9.2.8.errors b/vim/test/assets/lexical-error.hs.ghc-9.2.8.errors new file mode 100644 index 0000000..acf64f9 --- /dev/null +++ b/vim/test/assets/lexical-error.hs.ghc-9.2.8.errors @@ -0,0 +1,4 @@ +[1 of 1] Compiling Main ( lexical-error.hs, lexical-error.o ) + +lexical-error.hs:1:11: error: + lexical error in string/character literal at character '\n' diff --git a/vim/test/assets/lexical-error.hs.ghc-9.4.8.errors b/vim/test/assets/lexical-error.hs.ghc-9.4.8.errors new file mode 100644 index 0000000..f25f041 --- /dev/null +++ b/vim/test/assets/lexical-error.hs.ghc-9.4.8.errors @@ -0,0 +1,4 @@ +[1 of 2] Compiling Main ( lexical-error.hs, lexical-error.o ) + +lexical-error.hs:1:11: error: + lexical error in string/character literal at character '\n' diff --git a/vim/test/assets/lexical-error.hs.ghc-9.6.6.errors b/vim/test/assets/lexical-error.hs.ghc-9.6.6.errors new file mode 100644 index 0000000..309c74d --- /dev/null +++ b/vim/test/assets/lexical-error.hs.ghc-9.6.6.errors @@ -0,0 +1,4 @@ +[1 of 2] Compiling Main ( lexical-error.hs, lexical-error.o ) + +lexical-error.hs:1:11: error: [GHC-21231] + lexical error in string/character literal at character '\n' diff --git a/vim/test/assets/lexical-error.hs.ghc-9.8.2.errors b/vim/test/assets/lexical-error.hs.ghc-9.8.2.errors new file mode 100644 index 0000000..309c74d --- /dev/null +++ b/vim/test/assets/lexical-error.hs.ghc-9.8.2.errors @@ -0,0 +1,4 @@ +[1 of 2] Compiling Main ( lexical-error.hs, lexical-error.o ) + +lexical-error.hs:1:11: error: [GHC-21231] + lexical error in string/character literal at character '\n' diff --git a/vim/test/assets/parse-error.hs b/vim/test/assets/parse-error.hs new file mode 100644 index 0000000..e187a3a --- /dev/null +++ b/vim/test/assets/parse-error.hs @@ -0,0 +1,2 @@ +foo : Int +foo = 23 diff --git a/vim/test/assets/parse-error.hs.ghc-9.10.1.errors b/vim/test/assets/parse-error.hs.ghc-9.10.1.errors new file mode 100644 index 0000000..7b02f96 --- /dev/null +++ b/vim/test/assets/parse-error.hs.ghc-9.10.1.errors @@ -0,0 +1,5 @@ +[1 of 2] Compiling Main ( parse-error.hs, parse-error.o ) +parse-error.hs:1:1: error: [GHC-25277] + Parse error: module header, import declaration + or top-level declaration expected. + diff --git a/vim/test/assets/parse-error.hs.ghc-9.2.8.errors b/vim/test/assets/parse-error.hs.ghc-9.2.8.errors new file mode 100644 index 0000000..0e64749 --- /dev/null +++ b/vim/test/assets/parse-error.hs.ghc-9.2.8.errors @@ -0,0 +1,5 @@ +[1 of 1] Compiling Main ( parse-error.hs, parse-error.o ) + +parse-error.hs:1:1: error: + Parse error: module header, import declaration + or top-level declaration expected. diff --git a/vim/test/assets/parse-error.hs.ghc-9.4.8.errors b/vim/test/assets/parse-error.hs.ghc-9.4.8.errors new file mode 100644 index 0000000..4d91b8f --- /dev/null +++ b/vim/test/assets/parse-error.hs.ghc-9.4.8.errors @@ -0,0 +1,5 @@ +[1 of 2] Compiling Main ( parse-error.hs, parse-error.o ) + +parse-error.hs:1:1: error: + Parse error: module header, import declaration + or top-level declaration expected. diff --git a/vim/test/assets/parse-error.hs.ghc-9.6.6.errors b/vim/test/assets/parse-error.hs.ghc-9.6.6.errors new file mode 100644 index 0000000..4d91b8f --- /dev/null +++ b/vim/test/assets/parse-error.hs.ghc-9.6.6.errors @@ -0,0 +1,5 @@ +[1 of 2] Compiling Main ( parse-error.hs, parse-error.o ) + +parse-error.hs:1:1: error: + Parse error: module header, import declaration + or top-level declaration expected. diff --git a/vim/test/assets/parse-error.hs.ghc-9.8.2.errors b/vim/test/assets/parse-error.hs.ghc-9.8.2.errors new file mode 100644 index 0000000..1b46eff --- /dev/null +++ b/vim/test/assets/parse-error.hs.ghc-9.8.2.errors @@ -0,0 +1,5 @@ +[1 of 2] Compiling Main ( parse-error.hs, parse-error.o ) + +parse-error.hs:1:1: error: [GHC-25277] + Parse error: module header, import declaration + or top-level declaration expected. diff --git a/vim/test/assets/suggested-fix-multiline.hs b/vim/test/assets/suggested-fix-multiline.hs new file mode 100644 index 0000000..5a9f494 --- /dev/null +++ b/vim/test/assets/suggested-fix-multiline.hs @@ -0,0 +1,5 @@ +foo :: Int +foo_ = 23 + +bar :: Int +bar_ = 23 diff --git a/vim/test/assets/suggested-fix-multiline.hs.ghc-9.10.1.errors b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.10.1.errors new file mode 100644 index 0000000..e329b97 --- /dev/null +++ b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.10.1.errors @@ -0,0 +1,11 @@ +[1 of 2] Compiling Main ( suggested-fix-multiline.hs, suggested-fix-multiline.o ) +suggested-fix-multiline.hs:1:1: error: [GHC-44432] + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘foo_’ (Defined at suggested-fix-multiline.hs:2:1) + +suggested-fix-multiline.hs:4:1: error: [GHC-44432] + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘bar_’ (Defined at suggested-fix-multiline.hs:5:1) + diff --git a/vim/test/assets/suggested-fix-multiline.hs.ghc-9.2.8.errors b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.2.8.errors new file mode 100644 index 0000000..6374000 --- /dev/null +++ b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.2.8.errors @@ -0,0 +1,9 @@ +[1 of 1] Compiling Main ( suggested-fix-multiline.hs, suggested-fix-multiline.o ) + +suggested-fix-multiline.hs:1:1: error: + The type signature for ‘foo’ lacks an accompanying binding + Perhaps you meant ‘foo_’ (Defined at suggested-fix-multiline.hs:2:1) + +suggested-fix-multiline.hs:4:1: error: + The type signature for ‘bar’ lacks an accompanying binding + Perhaps you meant ‘bar_’ (Defined at suggested-fix-multiline.hs:5:1) diff --git a/vim/test/assets/suggested-fix-multiline.hs.ghc-9.4.8.errors b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.4.8.errors new file mode 100644 index 0000000..c9cfd23 --- /dev/null +++ b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.4.8.errors @@ -0,0 +1,11 @@ +[1 of 2] Compiling Main ( suggested-fix-multiline.hs, suggested-fix-multiline.o ) + +suggested-fix-multiline.hs:1:1: error: + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘foo_’ (Defined at suggested-fix-multiline.hs:2:1) + +suggested-fix-multiline.hs:4:1: error: + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘bar_’ (Defined at suggested-fix-multiline.hs:5:1) diff --git a/vim/test/assets/suggested-fix-multiline.hs.ghc-9.6.6.errors b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.6.6.errors new file mode 100644 index 0000000..46e4b98 --- /dev/null +++ b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.6.6.errors @@ -0,0 +1,11 @@ +[1 of 2] Compiling Main ( suggested-fix-multiline.hs, suggested-fix-multiline.o ) + +suggested-fix-multiline.hs:1:1: error: [GHC-44432] + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘foo_’ (Defined at suggested-fix-multiline.hs:2:1) + +suggested-fix-multiline.hs:4:1: error: [GHC-44432] + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘bar_’ (Defined at suggested-fix-multiline.hs:5:1) diff --git a/vim/test/assets/suggested-fix-multiline.hs.ghc-9.8.2.errors b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.8.2.errors new file mode 100644 index 0000000..46e4b98 --- /dev/null +++ b/vim/test/assets/suggested-fix-multiline.hs.ghc-9.8.2.errors @@ -0,0 +1,11 @@ +[1 of 2] Compiling Main ( suggested-fix-multiline.hs, suggested-fix-multiline.o ) + +suggested-fix-multiline.hs:1:1: error: [GHC-44432] + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘foo_’ (Defined at suggested-fix-multiline.hs:2:1) + +suggested-fix-multiline.hs:4:1: error: [GHC-44432] + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: + Perhaps use ‘bar_’ (Defined at suggested-fix-multiline.hs:5:1) diff --git a/vim/test/assets/suggested-fix.hs b/vim/test/assets/suggested-fix.hs new file mode 100644 index 0000000..5a9f494 --- /dev/null +++ b/vim/test/assets/suggested-fix.hs @@ -0,0 +1,5 @@ +foo :: Int +foo_ = 23 + +bar :: Int +bar_ = 23 diff --git a/vim/test/assets/suggested-fix.hs.ghc-9.10.1.errors b/vim/test/assets/suggested-fix.hs.ghc-9.10.1.errors new file mode 100644 index 0000000..255a19f --- /dev/null +++ b/vim/test/assets/suggested-fix.hs.ghc-9.10.1.errors @@ -0,0 +1,9 @@ +[1 of 2] Compiling Main ( suggested-fix.hs, suggested-fix.o ) +suggested-fix.hs:1:1: error: [GHC-44432] + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: Perhaps use ‘foo_’ (Defined at suggested-fix.hs:2:1) + +suggested-fix.hs:4:1: error: [GHC-44432] + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: Perhaps use ‘bar_’ (Defined at suggested-fix.hs:5:1) + diff --git a/vim/test/assets/suggested-fix.hs.ghc-9.2.8.errors b/vim/test/assets/suggested-fix.hs.ghc-9.2.8.errors new file mode 100644 index 0000000..e38b124 --- /dev/null +++ b/vim/test/assets/suggested-fix.hs.ghc-9.2.8.errors @@ -0,0 +1,9 @@ +[1 of 1] Compiling Main ( suggested-fix.hs, suggested-fix.o ) + +suggested-fix.hs:1:1: error: + The type signature for ‘foo’ lacks an accompanying binding + Perhaps you meant ‘foo_’ (Defined at suggested-fix.hs:2:1) + +suggested-fix.hs:4:1: error: + The type signature for ‘bar’ lacks an accompanying binding + Perhaps you meant ‘bar_’ (Defined at suggested-fix.hs:5:1) diff --git a/vim/test/assets/suggested-fix.hs.ghc-9.4.8.errors b/vim/test/assets/suggested-fix.hs.ghc-9.4.8.errors new file mode 100644 index 0000000..8c6c093 --- /dev/null +++ b/vim/test/assets/suggested-fix.hs.ghc-9.4.8.errors @@ -0,0 +1,9 @@ +[1 of 2] Compiling Main ( suggested-fix.hs, suggested-fix.o ) + +suggested-fix.hs:1:1: error: + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: Perhaps use ‘foo_’ (Defined at suggested-fix.hs:2:1) + +suggested-fix.hs:4:1: error: + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: Perhaps use ‘bar_’ (Defined at suggested-fix.hs:5:1) diff --git a/vim/test/assets/suggested-fix.hs.ghc-9.6.6.errors b/vim/test/assets/suggested-fix.hs.ghc-9.6.6.errors new file mode 100644 index 0000000..5e2b04a --- /dev/null +++ b/vim/test/assets/suggested-fix.hs.ghc-9.6.6.errors @@ -0,0 +1,9 @@ +[1 of 2] Compiling Main ( suggested-fix.hs, suggested-fix.o ) + +suggested-fix.hs:1:1: error: [GHC-44432] + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: Perhaps use ‘foo_’ (Defined at suggested-fix.hs:2:1) + +suggested-fix.hs:4:1: error: [GHC-44432] + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: Perhaps use ‘bar_’ (Defined at suggested-fix.hs:5:1) diff --git a/vim/test/assets/suggested-fix.hs.ghc-9.8.2.errors b/vim/test/assets/suggested-fix.hs.ghc-9.8.2.errors new file mode 100644 index 0000000..5e2b04a --- /dev/null +++ b/vim/test/assets/suggested-fix.hs.ghc-9.8.2.errors @@ -0,0 +1,9 @@ +[1 of 2] Compiling Main ( suggested-fix.hs, suggested-fix.o ) + +suggested-fix.hs:1:1: error: [GHC-44432] + The type signature for ‘foo’ lacks an accompanying binding + Suggested fix: Perhaps use ‘foo_’ (Defined at suggested-fix.hs:2:1) + +suggested-fix.hs:4:1: error: [GHC-44432] + The type signature for ‘bar’ lacks an accompanying binding + Suggested fix: Perhaps use ‘bar_’ (Defined at suggested-fix.hs:5:1) diff --git a/vim/test/assets/type-error.hs b/vim/test/assets/type-error.hs new file mode 100644 index 0000000..5b28234 --- /dev/null +++ b/vim/test/assets/type-error.hs @@ -0,0 +1,2 @@ +foo :: String +foo = 23 :: Int diff --git a/vim/test/assets/type-error.hs.ghc-9.10.1.errors b/vim/test/assets/type-error.hs.ghc-9.10.1.errors new file mode 100644 index 0000000..caec5f1 --- /dev/null +++ b/vim/test/assets/type-error.hs.ghc-9.10.1.errors @@ -0,0 +1,6 @@ +[1 of 2] Compiling Main ( type-error.hs, type-error.o ) +type-error.hs:2:7: error: [GHC-83865] + Couldn't match type ‘Int’ with ‘[Char]’ + Expected: String + Actual: Int + diff --git a/vim/test/assets/type-error.hs.ghc-9.2.8.errors b/vim/test/assets/type-error.hs.ghc-9.2.8.errors new file mode 100644 index 0000000..8679f74 --- /dev/null +++ b/vim/test/assets/type-error.hs.ghc-9.2.8.errors @@ -0,0 +1,8 @@ +[1 of 1] Compiling Main ( type-error.hs, type-error.o ) + +type-error.hs:2:7: error: + • Couldn't match type ‘Int’ with ‘[Char]’ + Expected: String + Actual: Int + • In the expression: 23 :: Int + In an equation for ‘foo’: foo = 23 :: Int diff --git a/vim/test/assets/type-error.hs.ghc-9.4.8.errors b/vim/test/assets/type-error.hs.ghc-9.4.8.errors new file mode 100644 index 0000000..3af9865 --- /dev/null +++ b/vim/test/assets/type-error.hs.ghc-9.4.8.errors @@ -0,0 +1,8 @@ +[1 of 2] Compiling Main ( type-error.hs, type-error.o ) + +type-error.hs:2:7: error: + • Couldn't match type ‘Int’ with ‘[Char]’ + Expected: String + Actual: Int + • In the expression: 23 :: Int + In an equation for ‘foo’: foo = 23 :: Int diff --git a/vim/test/assets/type-error.hs.ghc-9.6.6.errors b/vim/test/assets/type-error.hs.ghc-9.6.6.errors new file mode 100644 index 0000000..ee038f6 --- /dev/null +++ b/vim/test/assets/type-error.hs.ghc-9.6.6.errors @@ -0,0 +1,6 @@ +[1 of 2] Compiling Main ( type-error.hs, type-error.o ) + +type-error.hs:2:7: error: [GHC-83865] + Couldn't match type ‘Int’ with ‘[Char]’ + Expected: String + Actual: Int diff --git a/vim/test/assets/type-error.hs.ghc-9.8.2.errors b/vim/test/assets/type-error.hs.ghc-9.8.2.errors new file mode 100644 index 0000000..ee038f6 --- /dev/null +++ b/vim/test/assets/type-error.hs.ghc-9.8.2.errors @@ -0,0 +1,6 @@ +[1 of 2] Compiling Main ( type-error.hs, type-error.o ) + +type-error.hs:2:7: error: [GHC-83865] + Couldn't match type ‘Int’ with ‘[Char]’ + Expected: String + Actual: Int diff --git a/vim/test/run.vim b/vim/test/run.vim new file mode 100755 index 0000000..be6cc08 --- /dev/null +++ b/vim/test/run.vim @@ -0,0 +1,31 @@ +#!/bin/env -S vim -u NONE -S + +set t_ti= +set t_te= + +highlight red ctermfg=red +highlight green ctermfg=green + +command -nargs=* FAILURE echohl red | echo | echohl none +command -nargs=* SUCCESS echohl green | echo | echohl none + +function ShouldBe(actual, expected) + if !(a:actual ==# a:expected) + throw "expected: " . a:expected . "\n but got: " . a:actual + endif +endfunction + +try + for name in glob("**/*.test.vim", v:true, v:true) + SUCCESS "running " . name + execute "source " . name + endfor +catch + FAILURE substitute(substitute(v:throwpoint, '^command line..script ', '', ''), expand('