Add support to SWIProlog

This commit is contained in:
Diogo Cordeiro 2018-11-18 22:33:32 +00:00
parent 5c85b47c9d
commit 5ef34e26c4
6 changed files with 31 additions and 0 deletions

View File

@ -47,6 +47,7 @@ Run `:Repl` without saving the code on a file.
* Clojure * Clojure
* Idris * Idris
* Racket * Racket
* SWIProlog
## Installation ## Installation

View File

@ -26,6 +26,8 @@ function! repl#run_repl() abort
call repl#idris#open_repl() call repl#idris#open_repl()
elseif &filetype ==# 'scheme' elseif &filetype ==# 'scheme'
call repl#scheme#open_repl() call repl#scheme#open_repl()
elseif &filetype ==# 'swiprolog'
call repl#prolog#open_repl()
else else
call repl#echo_error("Sorry, repl.vim didn't support this filetype") call repl#echo_error("Sorry, repl.vim didn't support this filetype")
endif endif

22
autoload/repl/prolog.vim Normal file
View File

@ -0,0 +1,22 @@
scriptencoding utf-8
function! repl#prolog#open_repl() abort
" Setting up the file for the current file
if &modified
" Create new file temporary
let l:module_file = tempname() . '.hs'
call writefile(getline(1, expand('$')), l:module_file)
else
let l:module_file = expand('%:p')
endif
let l:repl = repl#get_filetype_repl('prolog')
let l:exec_name = split(l:repl['repl'], ' ')[0]
if !executable(l:exec_name)
call repl#echo_error(printf("You don't have repl: '%s'", l:exec_name))
return
endif
let l:args = printf('%s %s %s', l:repl['repl'], l:repl['opt'], l:module_file)
let l:vimshell_interactive = ':VimShellInteractive' . printf("--split='%s'", g:repl_split_command)
execute l:vimshell_interactive l:args
endfunction

View File

@ -76,6 +76,7 @@ https://github.com/user/repl.vim
* Javascript (node.js) * Javascript (node.js)
* Idris * Idris
* Scheme (racket) * Scheme (racket)
* Prolog (swipl)
============================================================================== ==============================================================================
使い方 *repl-usage* 使い方 *repl-usage*

View File

@ -40,6 +40,10 @@ let g:repl#default_filetype_repl = {
\ 'scheme' : { \ 'scheme' : {
\ 'repl' : 'racket', \ 'repl' : 'racket',
\ 'opt' : '-i' \ 'opt' : '-i'
\ },
\ 'prolog' : {
\ 'repl' : 'swipl',
\ 'opt' : ''
\ } \ }
\} \}

View File

@ -15,6 +15,7 @@ function! s:suite.do_not_throw_exception_when_open_repl()
setfiletype javascript | Repl | new setfiletype javascript | Repl | new
setfiletype clojure | Repl | new setfiletype clojure | Repl | new
setfiletype idris | Repl | new setfiletype idris | Repl | new
setfiletype swiprolog | Repl | new
" repl.vim cannot open repl " repl.vim cannot open repl
" but repl.vim don't throw some exception " but repl.vim don't throw some exception
setfiletype unknown | Repl setfiletype unknown | Repl