metakirby5 / codi.vim

:notebook_with_decorative_cover: The interactive scratchpad for hackers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does codi support coding inside a function

superhans opened this issue · comments

I have similar issues on Vim 8.1 (tested on MacOS Mojave and Ubuntu 16.04) as #31
Essentially, If I type
x=3
I get nothing on the codi pane.
But if I type just :
x on the next line, I get the output (I actually don't mind this behavior). This way, it only prints when I want it to.
codi1

But unfortunately, this behavior does not persist when I wrap the above code in a function. Say, I do

def main():
    x = 3
    x
main()

I don't get any output unless I do print(x) instead of just x (which is a pain to type and delete, as shown in figure below). Is there any way I can get the default behavior inside a function? Then I can use codi as part of my main workflow.

codi2

vimrc is

set nocompatible              " be iMproved, required    
filetype off                  " required                 
                                                         
"set autoindent                                          
set smartindent                                          
nnoremap <F3> :set invpaste paste?<CR>                   
set pastetoggle=<F3>                                     
set showmode                                             
set number                                               
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smartt
                                                         
colo desert                                              
syntax on                                                
:set backspace=indent,eol,start                          
                                                         
" since it is fullscreen, I'd like a 50/50 split         
let g:codi#width = 50.0                                  
let g:codi#rightalign = 0                                

The value does not show because your main() does not return any value, so the line in which it is called does not actually evaluate to a displayable expression. You can get the desired behavior by returning the value you want to display. Otherwise, such behavior will only work if the language supports implicit returns, like Ruby or CoffeeScript.

screen shot 2019-02-01 at 23 35 55