Closed athom closed 11 years ago
great! I'm also coming to like the language :)
but one thing I want to say is, why do you add cfi#echo_func_name()? Could you specify the use case of this function?
Could you specify the use case of this function? just to show the function name in the status bar.
I guess the cfi#format(fmt, default) is doing the same thing? Would you show the usage of cfi#format?
I guess the cfi#format(fmt, default) is doing the same thing?
If you want to do the same thing as call cfi#echo_func_name()
,
you can write like this:
echo cfi#format("%s", "")
you can also specify format the result string:
echo cfi#format("[%s()]", "")
Hi, I removed the duplicated function. But I have a problem in invoking the echo func name function.
In the .vimrc file,
This works,
nmap <C-g> :echo cfi#format("%s\n", "")<CR>
while this is silent
nmap <C-g> :echo cfi#format("%s", "")<CR>
Do you have any idea?
Maybe it's a MacVim bug
But I change it from
nmap <C-g> :echo cfi#format("%s", "")<CR>
to
nmap <C-g> :echo "x"<CR>
It did show something in the status bar, that's really weird.
hmm, certainly weird.
what does :set stl
output?
and I think <C-g>
could be a little bit frustrating depending on your set timeout? timeoutlen?
value.
<C-g>
is the prefix key of many many default vim keymappings.
I change the key map, and it does not work neither.
nmap <C-@>f :set stl=%!Echo_fun_name()<CR>
function! Echo_fun_name()
call cfi#format("%s", "")
endfunction
How do you use the cfi plugin? Maybe that's better way I could learn about.
hi, tyru.
I found the reason.
In the cfi#get_func_name function:
let orig_view = winsaveview()
try
let val = s:finder[filetype].find()
return type(val) == type("") ? val : NONE
finally
call winrestview(orig_view)
endtry
the winresetview(orig_view) cause this bug.
I want to echo the the return value in the status line, so it break the win view. when the winresetview
function was called in the finnally block. It bring the current win view to normal status. So the expected function name in the status line was gone.
The subtle point is if the function name is more than 1 line, it will shows up in the status bar again. It make me confused so I dive into the macvim code, I found when the status line is more than one line, it equals contains <cr>
and will trigger the wait_return function, which will redraw the window again.
Another riddle is why vim is OK while MacVim is not OK?
here is the root cause, but I don't know why the author do this, looks like a patch.
Well, Let's go back to the plugin code. Why winsaveview and winresetview is needed here? I guess they are unnecessary, for the try block dose not do anything affecting the screen, right?
Thanks for the info.
yeah I've seen many many different behavior of MacVim with other Vim versions...
maybe you should report the winrestview()
problem to MacVim team.
nmap <C-@>f :set stl=%!Echo_fun_name()<CR>
function! Echo_fun_name()
call cfi#format("%s", "")
endfunction
:set stl=%!Echo_fun_name()
means "set Echo_fun_name()'s return value to 'statusline' option."
(By the way, Echo_fun_name()'s return value is 0
, because you don't :return
cfi#format("%s", "")
's value instead of :call
)
so :set stl=%!Echo_fun_name()
is evaluated only once when the Ex command is executed.
maybe this is not what you want to do.
If you want to call cfi#format("%s", "")
each when 'statusline' is changed,
you can contain cfi#format("%s", "")
expression in your statusline:
let &stl = '... your favorite statusline config ...'
" Append current function name to statusline
let &stl .= ' %{cfi#format("%s", "")}'
or if you want to show current function name when you press <C-@>f
,
you can write:
nnoremap <C-@>f :echo cfi#format("%s", "")<CR>
Hope this helps you :smile:
Got it.
I don't want to get the function name info too frequently every time status line changed, a shortcut to get the name is just what I need.
nnoremap <C-@>f :echo cfi#format("%s", "")<CR>
Still not works on MacVim. Anyway, thanks for you info.
I will report it to the MacVim team.
By the way, now I noticed you added README.md file. Thanks! :)
Please change README.md a little bit. (Or I do it after merge if you hope)
After the change, I would be going to merge this pull req.
nmap <C-g> :echo cfi#format("%s\n", "")<CR>
nnoremap <C-g>f :echo cfi#format("%s", "")<CR>
As your wish :smile:
Thanks for your work! :satisfied:
Hi @tyru, Thanks for your work, this plugin is very helpful to me. However it does not support go which is my daily language, so I made one:)