Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot call AutoCorrect in vimrc #5

Closed
laike9m opened this issue Dec 17, 2014 · 10 comments
Closed

cannot call AutoCorrect in vimrc #5

laike9m opened this issue Dec 17, 2014 · 10 comments

Comments

@laike9m
Copy link

laike9m commented Dec 17, 2014

I installed the plugin, really great tool! Calling AutoCorrect() after launching vim had no problem, but When I put call AutoCorrect() into .vimrc, it keeps warning me

Error detected while processing /Users/laike9m/.vimrc:
line   52:
E117: Unknown function: AutoCorrect
Press ENTER or type command to continue

Here's my .vimrc file, everything is OK if I remove the last line which is call AutoCorrect().

set nocompatible              " be iMproved
filetype off                  " required!
set nu
syntax on                     " 开启语法高亮
set fileencodings=utf-8,gbk   " 解决中文编码问题
set backspace=indent,eol,start " 保证退格键可以正常工作
set noswapfile                " 不产生swp文件
set autoread                  " 文件变化时可以实时刷新
set hlsearch                  " 高亮搜索文本
set omnifunc=syntaxcomplete#Complete " omni-complete

:set shiftwidth=4 tabstop=4
autocmd FileType html setlocal shiftwidth=2 tabstop=2
:set modifiable
:colorscheme desert

filetype plugin indent on     " required!

set rtp+=~/.vim/bundle/vundle/ " Vundle setting
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'

" My bundles here:
Bundle 'scrooloose/nerdtree'
let NERDTreeShowHidden=1
let NERDTreeShowBookmarks=1                 " 显示书签
let NERDTreeIgnore=['\.\.$', '\.$', '\~$']  " 不显示.和..路径
Bundle 'jistr/vim-nerdtree-tabs'
Bundle 'klen/python-mode'
Bundle 'panozzaj/vim-autocorrect'

" set font
if has("gui_running")
    if has("gui_gtk2")
        set lines=999 columns=999     " Linux 最大化窗口
        set guifont=Inconsolata\ 12
    elseif has("gui_macvim")
        set guifont=Menlo\ Regular:h14
    elseif has("gui_win32")
        set rtp+=~/vimfiles/bundle/vundle/ " Vundle setting
        let path='~/vimfiles/bundle'
        call vundle#rc(path)
        au GUIEnter * simalt ~x       " Windows 最大化窗口
        set guifont=Consolas:h11:cANSI
    endif
endif

call AutoCorrect()

Thank you!

@panozzaj
Copy link
Owner

Hi Yao, thanks for the kind words and reaching out. I can take a look at
this more as early as next week. I'm sorry for the delay but I have some
work stuff that I need to finish up before then. I am not as familiar with
Vundle, I use Pathogen, but maybe there is something up with the plugin. It
seems like if you can call it when you have Vim fully loaded it should work
equivalently to at the end of your .vimrc, but it is probably due to me not
understanding something with the load order or paths.

On Wed, Dec 17, 2014 at 10:57 AM, Yao Zuo notifications@github.com wrote:

I installed the plugin, really great tool! Calling AutoCorrect() after
launching vim had no problem, but When I put call AutoCorrect() into
.vimrc, it keeps warning me

Error detected while processing /Users/laike9m/.vimrc:
line 52:
E117: Unknown function: AutoCorrect
Press ENTER or type command to continue

. Here's my .vimrc, everything is OK if I remove the last line which is call
AutoCorrect().

set nocompatible " be iMproved
filetype off " required!
set nu
syntax on " 开启语法高亮
set fileencodings=utf-8,gbk " 解决中文编码问题
set backspace=indent,eol,start " 保证退格键可以正常工作
set noswapfile " 不产生swp文件
set autoread " 文件变化时可以实时刷新
set hlsearch " 高亮搜索文本
set omnifunc=syntaxcomplete#Complete " omni-complete

:set shiftwidth=4 tabstop=4
autocmd FileType html setlocal shiftwidth=2 tabstop=2
:set modifiable
:colorscheme desert

filetype plugin indent on " required!

set rtp+=~/.vim/bundle/vundle/ " Vundle setting
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'

" My bundles here:
Bundle 'scrooloose/nerdtree'
let NERDTreeShowHidden=1
let NERDTreeShowBookmarks=1 " 显示书签
let NERDTreeIgnore=['..$', '.$', '~$'] " 不显示.和..路径
Bundle 'jistr/vim-nerdtree-tabs'
Bundle 'klen/python-mode'
Bundle 'panozzaj/vim-autocorrect'

" set font
if has("gui_running")
if has("gui_gtk2")
set lines=999 columns=999 " Linux 最大化窗口
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set rtp+=/vimfiles/bundle/vundle/ " Vundle setting
let path='
/vimfiles/bundle'
call vundle#rc(path)
au GUIEnter * simalt ~x " Windows 最大化窗口
set guifont=Consolas:h11:cANSI
endif
endif

call AutoCorrect()

Thank you!


Reply to this email directly or view it on GitHub
#5.

@panozzaj
Copy link
Owner

panozzaj commented Feb 7, 2015

Sorry, I have not had much time to take a look at this. Is this still an issue for you?

@laike9m
Copy link
Author

laike9m commented Feb 8, 2015

Not really. If you don't have time, that's fine.

@panozzaj
Copy link
Owner

panozzaj commented Feb 8, 2015

I am not sure what version of Vundle you are using, but the latest Vundle README says that you need to call vundle#begin(), declare your plugins, and then call vundle#end(). It seems like they are in the process of changing the Vundle interface. It seems like plugins will only be available after the end. Maybe Vundle has some sort of auto-end if it doesn't see one, and that is why it works when you do it after fully loading Vim, but won't work inside of the .vimrc.

A couple of tangential notes, as penance for taking so long with replying.. :) I don't think you need : at the beginning of .vimrc lines. You might also check the path of your Windows include at the end, based on http://stackoverflow.com/questions/20048032/configuration-doesnt-work-for-using-vundle-on-vim.

@laike9m
Copy link
Author

laike9m commented Feb 9, 2015

I've checked I'm using the latest version of Vundle(0.10.2).
I've modified my .vimrc adding call vundle#begin() and call vundle#end() but if I put call AutoCorrect() in vimrc the error still exists.

P.S. I'm using Mac so this error has nothing to do with windows path. Maybe you could reproduce it?

@panozzaj
Copy link
Owner

panozzaj commented Feb 9, 2015

OK, thanks for that information. Yes, I should be able to repro locally.

On Sun, Feb 8, 2015 at 11:33 PM, Yao Zuo notifications@github.com wrote:

I've checked I'm using the latest version of Vundle(0.10.2).

I've modified my .vimrc adding call vundle#begin() and call vundle#end()
but if I put call AutoCorrect() in vimrc the error still exists.

P.S. I'm using Mac so this error has nothing to do with windows path.
Maybe you could reproduce it?


Reply to this email directly or view it on GitHub
#5 (comment)
.

@panozzaj
Copy link
Owner

I was able to reproduce the issue locally. I think the solution is one of the following:

  1. call AutoCorrect() manually when you want to use autocorrect. This is the preferred method since it takes a couple of seconds to load the corrections, and so will slow down Vim every time you try to use it. This is my approach, and is probably why I have not run into this.
  2. source ~/.vim/bundle/vim-autocorrect/plugin/autocorrect.vim in your ~/.vimrc above the call AutoCorrect(), which will execute that function and make it available.
  3. Try something somewhat convoluted like http://vim.wikia.com/wiki/How_to_initialize_plugins (see augroup). Basically you need to defer calling the function until the plugin is loaded.

Hope that helps!

@daum1234
Copy link

Hi, panozzaj!

first off, thanks for your great plugin!!
and I had same issue like as laike9m ,but I got fixed it with your #2 solution

@panozzaj
Copy link
Owner

FYI: I will leave this open for now until I update the documentation.

@hrai
Copy link

hrai commented Feb 1, 2021

I tried below and it now works like a charm.

augroup autocorrect
    autocmd filetype * call AutoCorrect()
augroup END

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants