diff --git a/README.md b/README.md index 0d209de..f47cfd4 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,15 @@ Add the following to your Vim configuration (e.g. :set makeprg=seito ``` +#### Option 2: Set `makeprg`: + +Add the following to `~/.vim/after/ftplugin/haskell.vim`: + +```vim +let vim_config = system('seito --vim-config') +execute 'source ' . 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..efdcb15 100644 --- a/driver/seito.hs +++ b/driver/seito.hs @@ -5,10 +5,16 @@ 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 "" - L.putStr output - unless success exitFailure + getArgs >>= \ case + ["--vim-config"] -> do + getDataFileName "vim/sensei.vim" >>= putStr + args -> do + (success, output) <- client "" args + L.putStr output + unless success exitFailure diff --git a/ghc-9.10.1 b/ghc-9.10.1 new file mode 100644 index 0000000..482179d --- /dev/null +++ b/ghc-9.10.1 @@ -0,0 +1,16 @@ + +[46 of 54] Compiling Command +src/Command.hs:67:1: error: [GHC-44432] + The type signature for ‘oo’ lacks an accompanying binding + Suggested fix: Perhaps use ‘foo’ (Defined at src/Command.hs:68:1) + +src/Command.hs:70:1: error: [GHC-44432] + The type signature for ‘command_’ lacks an accompanying binding + Suggested fix: + Perhaps use one of these: + ‘ommand_’ (Defined at src/Command.hs:71:1), + ‘commands’ (Defined at src/Command.hs:147:1) + +Failed, 47 modules reloaded. + +driver/seito.hs:15:22: error: [GHC-58481] parse error on input ‘->’ 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/vim/sensei.vim b/vim/sensei.vim new file mode 100644 index 0000000..c9a24c7 --- /dev/null +++ b/vim/sensei.vim @@ -0,0 +1,5 @@ +set makeprg=seito +set errorformat=%A%f:%l:%c:\ %t%*[^:]:\ [GHC-%n] +set errorformat^=%+C\ %.%# +set errorformat^=%Z +set errorformat^=%-G\ \ \ \ Suggested\ fix:%.%# diff --git a/vim/test_sensei.vim b/vim/test_sensei.vim new file mode 100755 index 0000000..5c7c819 --- /dev/null +++ b/vim/test_sensei.vim @@ -0,0 +1,59 @@ +#!/bin/env -S vim -u NONE -S +" vim9script + +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 + +source vim/sensei.vim + + +cgetfile ghc-9.10.1 + +let errors = filter(getqflist(), 'v:val.valid') + +for error in errors + let file = bufname(error.bufnr) + if file != '' + SUCCESS file + else + FAILURE "none" + endif + echo error +endfor + +let err1 = errors[0] +call assert_equal("src/Command.hs", bufname(err1.bufnr)) +call assert_equal(67, err1.lnum) +call assert_equal(1, err1.col) +call assert_equal(0, err1.end_lnum) +call assert_equal(0, err1.end_col) +call assert_equal('e', err1.type) +call assert_equal(44432, err1.nr) + +let err2 = errors[1] +call assert_equal("src/Command.hs", bufname(err2.bufnr)) +call assert_equal(70, err2.lnum) +call assert_equal(1, err2.col) +call assert_equal(0, err2.end_lnum) +call assert_equal(0, err2.end_col) +call assert_equal('e', err2.type) +call assert_equal(44432, err2.nr) + +echo "\n" + +if !empty(v:errors) + FAILURE "FAILURES:\n\n" + for error in v:errors + FAILURE substitute(error, "^command line..script ", "", "") + endfor + cquit +else + SUCCESS "SUCCESS" + quit +endif