-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
175 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function! elin#compat#buffer#focus_by_win_nr(win_nr) abort | ||
execute printf('%dwincmd w', a:win_nr) | ||
endfunction | ||
|
||
function! elin#compat#buffer#focus_by_name(buf_name) abort | ||
let win_nr = bufwinnr(a:buf_name) | ||
if win_nr == -1 | ||
return | ||
endif | ||
return elin#compat#buffer#focus_by_win_nr(win_nr) | ||
endfunction | ||
|
||
function! elin#compat#buffer#is_visible(buf_name) abort | ||
return bufwinnr(a:buf_name) != -1 | ||
endfunction | ||
|
||
function! elin#compat#buffer#open(buf_name, option) abort | ||
let opt = type(a:option) == v:t_dict ? a:option : {} | ||
let mods = get(opt, 'mods', '') | ||
let opener = get(opt, 'opener', 'split') | ||
execute printf('%s %s %s', mods, opener, a:buf_name) | ||
endfunction | ||
|
||
function! elin#compat#buffer#append_line(buf_name, one_line) abort | ||
if has('nvim') | ||
return nvim_buf_set_lines(bufnr(a:buf_name), -1, -1, 0, [a:one_line]) | ||
else | ||
call appendbufline(a:buf_name, '$', a:one_line) | ||
endif | ||
endfunction | ||
|
||
function! s:delete_color_code(s) abort | ||
return substitute(a:s, '\[[0-9;]*m', '', 'g') | ||
endfunction | ||
|
||
function! s:scroll_to_bottom(nr) abort | ||
let current_window = winnr() | ||
let last_window = winnr('#') | ||
try | ||
let &eventignore = 'WinEnter,WinLeave,BufEnter,BufLeave' | ||
call elin#compat#buffer#focus_by_win_nr(bufwinnr(a:nr)) | ||
silent normal! G | ||
finally | ||
" Preserve the user's last visited window by focusing to it first (PR #187) | ||
call elin#compat#buffer#focus_by_win_nr(last_window) | ||
call elin#compat#buffer#focus_by_win_nr(current_window) | ||
let &eventignore = '' | ||
endtry | ||
endfunction | ||
|
||
function! elin#compat#buffer#append(buf_name, s, ...) abort | ||
let nr = bufnr(a:buf_name) | ||
if nr < 0 | return | endif | ||
let opt = get(a:, 1, {}) | ||
|
||
for line in split(s:delete_color_code(a:s), '\r\?\n') | ||
silent call elin#compat#buffer#append_line(a:buf_name, line) | ||
endfor | ||
|
||
if get(opt, 'scroll_to_bottom', v:false) | ||
\ && elin#compat#buffer#is_visible(a:buf_name) | ||
\ && bufnr('%') != nr | ||
call elin#util#start_lazily('scroll_to_bottom', 500, funcref('s:scroll_to_bottom', [nr])) | ||
endif | ||
endfunction | ||
|
||
function! elin#compat#buffer#clear(buf_name) abort | ||
return deletebufline(a:buf_name, 1, "$") | ||
endfunction |
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,99 @@ | ||
let s:buf_name = 'elin_info_buffer' | ||
let s:delimiter = ';; ----------' | ||
|
||
function! elin#internal#buffer#info#open() abort | ||
if elin#compat#buffer#is_visible(s:buf_name) | ||
return | ||
endif | ||
|
||
call elin#compat#buffer#open(s:buf_name, {}) | ||
"call elin#compat#buffer#focus_by_name(s:buf_name) | ||
endfunction | ||
|
||
function! elin#internal#buffer#info#ready() abort | ||
if bufnr(s:buf_name) != -1 | ||
return | ||
endif | ||
silent execute printf(':split %s', s:buf_name) | ||
silent execute ':q' | ||
|
||
call setbufvar(s:buf_name, 'lsp_diagnostics_enabled', 0) | ||
call setbufvar(s:buf_name, '&bufhidden', 'hide') | ||
call setbufvar(s:buf_name, '&buflisted', 0) | ||
call setbufvar(s:buf_name, '&buftype', 'nofile') | ||
call setbufvar(s:buf_name, '&filetype', 'clojure') | ||
call setbufvar(s:buf_name, '&swapfile', 0) | ||
call setbufvar(s:buf_name, '&wrap', 0) | ||
endfunction | ||
|
||
function! elin#internal#buffer#info#append(s) abort | ||
" let s = iced#util#delete_color_code(a:s) | ||
" let timer = iced#system#get('timer') | ||
|
||
call elin#compat#buffer#append(s:buf_name, a:s, {'scroll_to_bottom': v:true}) | ||
|
||
" call timer.start_lazily( | ||
" \ 'delete_old_lines', | ||
" \ g:iced#buffer#stdout#deleting_line_delay, | ||
" \ funcref('s:delete_old_lines'), | ||
" \ ) | ||
|
||
if a:s !=# s:delimiter | ||
call elin#util#start_lazily('append_delimiter', 500, {-> elin#internal#buffer#info#append(s:delimiter)}) | ||
endif | ||
" if g:iced#buffer#stdout#enable_delimiter | ||
" \ && a:s !=# g:iced#buffer#stdout#delimiter_line | ||
" call timer.start_lazily( | ||
" \ 'append_delimiter', | ||
" \ g:iced#buffer#stdout#delimiter_delay, | ||
" \ {-> (g:iced#buffer#stdout#enable_delimiter) | ||
" \ ? iced#buffer#stdout#append(g:iced#buffer#stdout#delimiter_line) | ||
" \ : ''}, | ||
" \ ) | ||
" endif | ||
|
||
" if ! iced#buffer#stdout#is_visible() | ||
" \ && g:iced#buffer#stdout#enable_notify | ||
" silent call iced#system#get('notify').notify(s, {'title': 'Stdout'}) | ||
" endif | ||
endfunction | ||
|
||
|
||
|
||
" import { Diced } from "../../types.ts"; | ||
" import * as vimBuf from "../../std/vim/buffer.ts"; | ||
" | ||
" export const bufName = "diced_info"; | ||
" | ||
" export async function open(diced: Diced): Promise<boolean> { | ||
" const denops = diced.denops; | ||
" const currentWin = await dpsFns.winnr(denops); | ||
" if (await vimBuf.isVisible(diced, bufName)) return false; | ||
" if (!await vimBuf.open(diced, bufName)) return false; | ||
" await vimBuf.focusByWinNr(diced, currentWin); | ||
" return true; | ||
" } | ||
" | ||
" export async function ready(diced: Diced): Promise<void> { | ||
" const denops = diced.denops; | ||
" if (await dpsFns.bufnr(denops, bufName) !== -1) return; | ||
" | ||
" dpsHelper.execute( | ||
" denops, | ||
" ` | ||
" silent execute ':split ${bufName}' | ||
" silent execute ':q' | ||
" | ||
" call setbufvar('${bufName}', 'lsp_diagnostics_enabled', 0) | ||
" call setbufvar('${bufName}', '&bufhidden', 'hide') | ||
" call setbufvar('${bufName}', '&buflisted', 0) | ||
" call setbufvar('${bufName}', '&buftype', 'nofile') | ||
" call setbufvar('${bufName}', '&filetype', 'clojure') | ||
" call setbufvar('${bufName}', '&swapfile', 0) | ||
" call setbufvar('${bufName}', '&wrap', 0) | ||
" `, | ||
" ); | ||
" | ||
" return; | ||
" } | ||
" |
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