Skip to content

Commit

Permalink
Merge pull request #37 from liquidz/dev
Browse files Browse the repository at this point in the history
ver 0.5.0
  • Loading branch information
liquidz authored Oct 3, 2018
2 parents 413a13e + 65856cd commit b380b98
Show file tree
Hide file tree
Showing 45 changed files with 365 additions and 155 deletions.
6 changes: 5 additions & 1 deletion .aspell.en.pws
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
personal_ws-1.1 en 149
personal_ws-1.1 en 153
grimoire
IcedGrep
IcedDocumentOpen
cljfmt
vlime
dbg
IcedStdoutBufferClear
IcedEvalNs
Expand All @@ -28,6 +29,7 @@ IcedEvalRepl
IcedQuitCljsRepl
hardbreaks
clj
ncat
liquidz
macroexpand
IcedDefJump
Expand Down Expand Up @@ -99,10 +101,12 @@ eastwood
CursorMoved
nREPL
nrepl
IcedTestRerunLast
Iizuka
IcedJumpToPrevSign
concat
IcedToggleSrcAndTest
neovim
BufWritePost
linters
IcedLintCurrentFile
Expand Down
15 changes: 11 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
+++
<h4 align="center">
<img src="logo.svg" alt="logo" /><br />
Clojure Interactive Development Environment for Vim8.
Clojure Interactive Development Environment for Vim8/Neovim.
</h4>
<p align="center">
<a href="releases">
<a href="https://github.com/liquidz/vim-iced/releases">
<img src="https://img.shields.io/github/release/liquidz/vim-iced.svg" alt="GitHub release" />
</a>
<a href="https://circleci.com/gh/liquidz/vim-iced">
Expand All @@ -26,9 +26,11 @@

== Requirements

* Vim 8.1 or later
* Vim 8.1 or later, Neovim 0.3.1 or later
** Neovim support is *VERY EXPERIMENTAL*
* Clojure & Java
* https://github.com/guns/vim-sexp[vim-sexp]
* https://nmap.org/ncat/[ncat] command (only for Neovim user)
* No python!

== Features
Expand All @@ -45,7 +47,7 @@
|[%hardbreaks]
run test under cursor
run tests in namespace
re run failed test
re run failed/last test

|:rocket:
|Refactoring
Expand Down Expand Up @@ -112,6 +114,11 @@ NOTE: https://github.com/ctrlpvim/ctrlp.vim[ctrlp.vim] is required when selectin

* See `Manual Install` section in link:./doc/vim-iced.txt[vim-iced.txt].

=== Neovim

* To imitate Vim8's `channel` feature, vim-iced uses https://nmap.org/ncat/[ncat] command like https://github.com/l04m33/vlime[l04m33/vlime].
* Install https://nmap.org/ncat/[ncat] command to use vim-iced in neovim at first.

== Usage

. Start repl via `iced` command
Expand Down
4 changes: 2 additions & 2 deletions autoload/ctrlp/iced.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let g:loaded_ctrlp_iced = 1

let s:config = {
\ 'candidates': [],
\ 'accept': v:none,
\ 'accept': '',
\ }

if exists('g:loaded_ctrlp')
Expand Down Expand Up @@ -35,7 +35,7 @@ function! ctrlp#iced#accept(mode, line) abort
let config = copy(s:config)
let s:config = {}

let Callback = get(config, 'accept', v:none)
let Callback = get(config, 'accept', '')
if iced#util#is_function(Callback)
call Callback(a:mode, a:line)
endif
Expand Down
16 changes: 8 additions & 8 deletions autoload/iced/buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let s:V = vital#iced#new()
let s:B = s:V.import('Vim.Buffer')
let s:BM = s:V.import('Vim.BufferManager')

let s:manager = v:none
let s:manager = ''
let s:info = {}

function! s:focus_window(bufwin_num) abort
Expand Down Expand Up @@ -41,7 +41,7 @@ function! iced#buffer#init(bufname, ...) abort
let manager = s:buffer_manager()
let s:info[a:bufname] = manager.open(a:bufname)

let InitFn = get(a:, 1, v:none)
let InitFn = get(a:, 1, '')
if iced#util#is_function(InitFn)
call InitFn(s:bufnr(a:bufname))
endif
Expand Down Expand Up @@ -95,7 +95,7 @@ function! iced#buffer#append(bufname, s, ...) abort
let opt = get(a:, 1, {})

for line in split(a:s, '\r\?\n')
silent call appendbufline(nr, '$', line)
silent call iced#compat#appendbufline(nr, '$', line)
endfor

if get(opt, 'scroll_to_bottom', v:false) && iced#buffer#is_visible(a:bufname)
Expand All @@ -109,17 +109,17 @@ endfunction
function! iced#buffer#set_contents(bufname, s) abort
let nr = s:bufnr(a:bufname)

silent call deletebufline(nr, 1, '$')
silent call iced#compat#deletebufline(nr, 1, '$')
for line in split(a:s, '\r\?\n')
silent call appendbufline(nr, '$', line)
silent call iced#compat#appendbufline(nr, '$', line)
endfor
silent call deletebufline(nr, 1)
silent call iced#compat#deletebufline(nr, 1)
endfunction

function! iced#buffer#clear(bufname, ...) abort
let nr = s:bufnr(a:bufname)
silent call deletebufline(nr, 1, '$')
let InitFn = get(a:, 1, v:none)
silent call iced#compat#deletebufline(nr, 1, '$')
let InitFn = get(a:, 1, '')
if iced#util#is_function(InitFn)
call InitFn(nr)
endif
Expand Down
6 changes: 3 additions & 3 deletions autoload/iced/buffer/stdout.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let s:default_init_text = join([
let g:iced#buffer#stdout#init_text = get(g:, 'iced#buffer#stdout#init_text', s:default_init_text)
let g:iced#buffer#stdout#mods = get(g:, 'iced#buffer#stdout#mods', '')
let g:iced#buffer#stdout#max_line = get(g:, 'iced#buffer#stdout#max_line', 512)
let g:iced#buffer#stdout#file = get(g:, 'iced#buffer#stdout#file', v:none)
let g:iced#buffer#stdout#file = get(g:, 'iced#buffer#stdout#file', '')

function! s:initialize(bufnr) abort
call setbufvar(a:bufnr, '&buflisted', 0)
Expand All @@ -22,9 +22,9 @@ function! s:initialize(bufnr) abort
call setbufvar(a:bufnr, '&swapfile', 0)

for line in split(g:iced#buffer#stdout#init_text, '\r\?\n')
silent call appendbufline(a:bufnr, '$', line)
silent call iced#compat#appendbufline(a:bufnr, '$', line)
endfor
silent call deletebufline(a:bufnr, 1)
silent call iced#compat#deletebufline(a:bufnr, 1)

if !empty(g:iced#buffer#stdout#file)
call writefile(getbufline(a:bufnr, 1, '$'), g:iced#buffer#stdout#file)
Expand Down
2 changes: 1 addition & 1 deletion autoload/iced/cache.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function! iced#cache#set(k, v) abort
endfunction

function! iced#cache#get(k, ...) abort
let default = get(a:, 1, v:none)
let default = get(a:, 1, '')
return get(s:cache, a:k, default)
endfunction

Expand Down
6 changes: 5 additions & 1 deletion autoload/iced/channel.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ let s:save_cpo = &cpo
set cpo&vim

function! iced#channel#new() abort
return iced#channel#vim#new()
if has('nvim')
return iced#channel#neovim#new()
else
return iced#channel#vim#new()
endif
endfunction

let &cpo = s:save_cpo
Expand Down
66 changes: 66 additions & 0 deletions autoload/iced/channel/neovim.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
let s:save_cpo = &cpo
set cpo&vim

let s:ch = {
\ 'env': 'neovim',
\ }

function! s:handle(job_id) abort
return {'job_id': a:job_id}
endfunction

function! s:job_id(handle) abort
return a:handle['job_id']
endfunction

function! s:data_rely(data) abort
if type(a:data) == type([])
return join(a:data, "\n")
endif
return a:data
endfunction

function! s:ch.open(address, options) abort
if !executable('nc')
return
endif

let [host, port] = split(a:address, ':')
let opts = {}

if has_key(a:options, 'callback')
let Cb = {job_id, data, _ -> a:options.callback(s:handle(job_id), s:data_rely(data))}
let opts['on_stdout'] = Cb
let opts['on_stderr'] = Cb
endif

let id = jobstart(['nc', host, port], opts)
let handle = s:handle(id)
let handle['address'] = a:address
return handle
endfunction

function! s:ch.close(handle) abort
return jobstop(s:job_id(a:handle))
endfunction

function! s:ch.status(handle) abort
let id = s:job_id(a:handle)
try
return (jobpid(id) > 0) ? 'open' : 'closed'
catch /E900:/
return 'closed'
endtry
endfunction

function! s:ch.sendraw(handle, string) abort
let id = s:job_id(a:handle)
return jobsend(id, a:string)
endfunction

function! iced#channel#neovim#new() abort
return s:ch
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo
1 change: 0 additions & 1 deletion autoload/iced/channel/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ endfunction

let &cpo = s:save_cpo
unlet s:save_cpo

46 changes: 46 additions & 0 deletions autoload/iced/compat.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
let s:save_cpo = &cpo
set cpo&vim

let s:V = vital#iced#new()
let s:S = s:V.import('Data.String')

function! iced#compat#trim(s) abort
if has('nvim')
return s:S.trim(a:s)
else
return trim(a:s)
endif
endfunction

function! iced#compat#appendbufline(expr, lnum, text) abort
if has('nvim')
let lnum = (a:lnum ==# '$') ? -1 : a:lnum
return nvim_buf_set_lines(a:expr, lnum, lnum, 0, [a:text])
else
return appendbufline(a:expr, a:lnum, a:text)
endif
endfunction

function! iced#compat#deletebufline(expr, first, ...) abort
let last = get(a:, 1, '')

if has('nvim')
if empty(last)
let last = a:first
endif
if last ==# '$'
let last = -1
endif

return nvim_buf_set_lines(a:expr, a:first, last, 0, [])
else
if empty(last)
return deletebufline(a:expr, a:first)
else
return deletebufline(a:expr, a:first, last)
endif
endif
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo
4 changes: 2 additions & 2 deletions autoload/iced/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function! s:context() abort
return join(codes, "\n")
catch /E684:/
" index out of range
return v:none
return ''
finally
let @@ = reg_save
call winrestview(view)
Expand All @@ -121,7 +121,7 @@ function! iced#complete#omni(findstart, base) abort
let candidates = []

" vars in current namespace
let tmp = s:ns_var_candidates(ns, a:base, v:none)
let tmp = s:ns_var_candidates(ns, a:base, '')
if !empty(tmp)
let candidates = candidates + tmp
endif
Expand Down
2 changes: 1 addition & 1 deletion autoload/iced/grep.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function! iced#grep#exe(kw) abort

let user_dir = iced#nrepl#system#user_dir()
let separator = iced#nrepl#system#separator()
if user_dir == v:none || separator == v:none | return | endif
if empty(user_dir) || empty(separator) | return | endif

let kw = empty(a:kw) ? expand('<cword>') : a:kw
let target = g:iced#grep#target
Expand Down
11 changes: 1 addition & 10 deletions autoload/iced/let.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,19 @@ function! iced#let#move_to_let(...) abort
let form = iced#util#del_indent(indent, form)
let name = get(a:, 1, '')
if empty(name)
let name = trim(input('Name: '))
let name = iced#compat#trim(input('Name: '))
endif
if empty(name)
return iced#message#echom('canceled')
endif

if iced#let#goto() == 0
" re-select form
call iced#paredit#get_outer_list_raw()
" 6 means `len('(let [')`
let form = iced#util#add_indent(len(name)+1+6, form)
let @@ = iced#util#add_indent(
\ indent, printf("(let [%s %s]\n %s)", name, form, name))
silent normal! gvp
else
" re-select form
" FIXME too redundant!!
let tmp = winsaveview()
call winrestview(view)
call iced#paredit#get_outer_list_raw()
call winrestview(tmp)

let pos = getcurpos()
let @@ = name
silent normal! gvp
Expand Down
Loading

0 comments on commit b380b98

Please sign in to comment.