Skip to content

Commit

Permalink
seito: Add --vim-config
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Sep 14, 2024
1 parent 6a1b3a7 commit fbc8770
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 15 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions driver/seito.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions ghc-9.10.1
Original file line number Diff line number Diff line change
@@ -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 ‘->’
4 changes: 2 additions & 2 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ default-extensions:
- RecordWildCards
- ViewPatterns

other-extensions:
- NoFieldSelectors
data-files: vim/sensei.vim

dependencies:
- base >= 4.11 && < 5
Expand Down Expand Up @@ -62,6 +61,7 @@ executables:

seito:
source-dirs: driver
generated-other-modules: Paths_sensei
main: seito.hs

tests:
Expand Down
17 changes: 7 additions & 10 deletions sensei.cabal

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vim/sensei.vim
Original file line number Diff line number Diff line change
@@ -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:%.%#
59 changes: 59 additions & 0 deletions vim/test_sensei.vim
Original file line number Diff line number Diff line change
@@ -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 <args> | echohl none
command! -nargs=* SUCCESS echohl green | echo <args> | 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

0 comments on commit fbc8770

Please sign in to comment.