Closed eater closed 7 years ago
Do you know which line causes the error? I could not find the code related to clever-f.vim in your gist.
At least it looks that you should use normal!
instead of normal
.
No, I'm not sure where the conflict is! I didn't write the function, I just found the gist. Changing it to normal!
is a good idea but doesn't fix the error.
Here's a simplified version of the function that still conflicts:
function! WordCount()
if line('$') == 1 && getline(1) == ''
return
elseif mode() == "i" || mode() == "n"
let s:old_status = v:statusmsg
exe "silent normal! g\<c-g>"
let b:word_count = str2nr(split(v:statusmsg)[11])
let v:statusmsg = s:old_status
endif
return b:word_count
endfunction
Thank you for reducing code. But I can still not identify the cause of this bug... Could you show me your status line configuration? I need to reproduce.
From .vimrc:
let mystatusline = ""
let mystatusline .= "\ %n\ %*" | " buffer number
let mystatusline .= "\ %<%F%*" | " full path
let mystatusline .= "\ %y%*" | " file type
let mystatusline .= " \%M" | " modified flag
let mystatusline .= "\ %#vimWarn#\%{(&key==\"\"?\"\":\"ENCR\")}%*" | " encrypted?
let mystatusline .= "\ \[%{v:register}\]" | " current register
let mystatusline .= "\ %{getcwd()} " " current working dir
let &statusline = mystatusline
autocmd FileType txt if &statusline !~ "WC: " | setlocal statusline+=\ \ WC:\ %{WordCount()}\
Thanks. I'll try it.
I could not see the error as below (it seems that it breaks cursor position when entering insert mode, but it looks not related to this issue)
Here's a longer set of error messages.
Error detected while processing function clever_f#find_with[12]..WordCount:
line 11:
E523: Not allowed here
Error detected while processing function clever_f#find_with[12]..WordCount:
line 17:
E684: list index out of range: 11
Error detected while processing function clever_f#find_with[12]..WordCount:
line 17:
E116: Invalid arguments for function str2nr(s:split_wc[11])
Error detected while processing function clever_f#find_with[12]..WordCount:
line 17:
E15: Invalid expression: str2nr(s:split_wc[11])
Error detected while processing function clever_f#find_with[12]..WordCount:
line 11:
E523: Not allowed here
Error detected while processing function clever_f#find_with[12]..WordCount:
line 17:
E684: list index out of range: 11
Error detected while processing function clever_f#find_with[12]..WordCount:
line 17:
E116: Invalid arguments for function str2nr(s:split_wc[11])
Error detected while processing function clever_f#find_with[12]..WordCount:
line 17:
E15: Invalid expression: str2nr(s:split_wc[11])
instead of using a selfmade wordcount function, you can use the builtin wordcount()
function, which has been included in Vim 7.4.1042
Amazing! Thanks, @chrisbra.
Thank you @chrisbra. @eater, did it solve this issue?
It looks it is a problem of implementation of the function WordCount()
. It seems to be called while clever-f.vim's f
is used because of status line update, but not related to this plugin directly. Closing this.
I use this function to keep a live wordcount in the statusline: https://gist.github.com/cormacrelf/d0bee254f5630b0e93c3
When I try to use Clever-f, I get an error
Is there an easy way to resolve the conflict?