Git Product home page Git Product logo

Comments (11)

chrisbra avatar chrisbra commented on July 24, 2024 1

instead of using a selfmade wordcount function, you can use the builtin wordcount() function, which has been included in Vim 7.4.1042

from clever-f.vim.

rhysd avatar rhysd commented on July 24, 2024

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.

from clever-f.vim.

eater avatar eater commented on July 24, 2024

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

from clever-f.vim.

rhysd avatar rhysd commented on July 24, 2024

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 clever-f.vim.

eater avatar eater commented on July 24, 2024

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()}\ 

from clever-f.vim.

rhysd avatar rhysd commented on July 24, 2024

Thanks. I'll try it.

from clever-f.vim.

rhysd avatar rhysd commented on July 24, 2024

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)

tmp

from clever-f.vim.

eater avatar eater commented on July 24, 2024

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])

from clever-f.vim.

eater avatar eater commented on July 24, 2024

Amazing! Thanks, @chrisbra.

from clever-f.vim.

rhysd avatar rhysd commented on July 24, 2024

Thank you @chrisbra. @eater, did it solve this issue?

from clever-f.vim.

rhysd avatar rhysd commented on July 24, 2024

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.

from clever-f.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.