From a803cd78500f1571289e84e7e191cf141ce0689b Mon Sep 17 00:00:00 2001 From: Risto Stevcev Date: Sun, 12 Jun 2016 01:40:21 +0200 Subject: [PATCH] Added idris support --- README.md | 1 + autoload/repl.vim | 2 ++ autoload/repl/idris.vim | 22 ++++++++++++++++++++++ plugin/repl.vim | 4 ++++ test/repl_vim.vim | 1 + 5 files changed, 30 insertions(+) create mode 100644 autoload/repl/idris.vim diff --git a/README.md b/README.md index 415feba..d0ff65f 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Run `:Repl` without saving the code on a file. * Erlang * JavaScript * Clojure +* Idris ## Installation diff --git a/autoload/repl.vim b/autoload/repl.vim index 4c088a6..7e19b2c 100644 --- a/autoload/repl.vim +++ b/autoload/repl.vim @@ -22,6 +22,8 @@ function! repl#run_repl() abort call repl#javascript#open_repl() elseif &filetype ==# 'clojure' call repl#clojure#open_repl() + elseif &filetype ==# 'idris' + call repl#idris#open_repl() else call repl#echo_error("Sorry, repl.vim didn't support this filetype") endif diff --git a/autoload/repl/idris.vim b/autoload/repl/idris.vim new file mode 100644 index 0000000..29ceb5f --- /dev/null +++ b/autoload/repl/idris.vim @@ -0,0 +1,22 @@ +scriptencoding utf-8 + +function! repl#idris#open_repl() abort + " Setting up the file for the current file + if &modified + " Create new file temporary + let l:module_file = tempname() . '.idr' + call writefile(getline(1, expand('$')), l:module_file) + else + let l:module_file = expand('%:p') + endif + + let l:repl = repl#get_filetype_repl('idris') + 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 diff --git a/plugin/repl.vim b/plugin/repl.vim index 3c05d8a..b671bf2 100644 --- a/plugin/repl.vim +++ b/plugin/repl.vim @@ -32,6 +32,10 @@ let g:repl#default_filetype_repl = { \ 'clojure' : { \ 'repl' : 'lein', \ 'opt' : 'repl' +\ }, +\ 'idris' : { +\ 'repl' : 'idris', +\ 'opt' : '' \ } \} diff --git a/test/repl_vim.vim b/test/repl_vim.vim index a05ae81..4036d4e 100644 --- a/test/repl_vim.vim +++ b/test/repl_vim.vim @@ -14,6 +14,7 @@ function! s:suite.do_not_throw_exception_when_open_repl() setfiletype python | Repl | new setfiletype javascript | Repl | new setfiletype clojure | Repl | new + setfiletype idris | Repl | new " repl.vim cannot open repl " but repl.vim don't throw some exception setfiletype unknown | Repl