Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
tags
26 changes: 12 additions & 14 deletions plugin/vikube.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ endf
fun! g:VTable.help()
endf

fun! g:VTable.update()
fun! g:VTable.update() dict
let cmd = self.command()
let b:job = job_start(cmd, {"close_cb": self.outputHandler })
let b:job = jobstart(cmd, {"on_stdout": self.outputHandler, "stdout_buffered":v:true})
let b:source_changed = 0
endf

fun! g:VTable.outputHandler(channel)
let lines = []
while ch_status(a:channel, {'part': 'out'}) == 'buffered'
call add(lines, ch_read(a:channel))
endwhile
let b:source_cache = join(lines, "\n") . "\n"
call self.render()
fun! g:VTable.outputHandler(channel, data, event) dict
let l:lines = []
let b:source_cache = join(a:data, "\n") . "\n"
" `self.render()` not working because self refers to callback options in this case
call s:render()
endf

fun! g:VTable.render()
fun! g:VTable.render() dict
let save_cursor = getcurpos()
if b:source_changed || !exists('b:source_cache')
call self.update()
Expand Down Expand Up @@ -90,10 +88,10 @@ endif

let g:VikubeExplorer = copy(g:VTable)

fun! g:VikubeExplorer.update()
fun! g:VikubeExplorer.update() dict
let cmd = self.command()
let shellcmd = ["bash", "-c", cmd . " | awk 'NR == 1; NR > 1 {print $0 | \"sort -b -k1\"}'"]
let b:job = job_start(shellcmd, {"close_cb": self.outputHandler })
let b:job = jobstart(shellcmd, {"on_stdout": self.outputHandler, "stdout_buffered":v:true})
let b:source_changed = 0
endf

Expand Down Expand Up @@ -377,7 +375,7 @@ fun! s:deleteResources(keys)
let cmd = s:cmdbase() . ' delete ' . b:resource_type . ' ' . keyargs
redraw | echomsg cmd

let job = job_start(["bash", "-c", cmd], {
let job = jobstart(["bash", "-c", cmd], {
\ "out_io": "buffer",
\ "out_name": "",
\ })
Expand Down Expand Up @@ -513,7 +511,7 @@ fun! s:handleFollowLogs()
endif
let cont = s:chooseContainer(containers)
let cmd = s:cmdbase() . " logs --follow --tail=" . g:vikube_default_logs_tail . " --namespace=" . b:namespace . " --timestamps --container=" . cont . ' ' . resource_type . '/' . key
exec "botright terminal ++kill=term " . cmd
exec "botright terminal " . cmd
endf


Expand Down