-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from liquidz/dev
ver 0.5.0
- Loading branch information
Showing
45 changed files
with
365 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,3 @@ endfunction | |
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.