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

Unable to set ledger binary #83

Closed
anjannath opened this issue Aug 28, 2019 · 8 comments
Closed

Unable to set ledger binary #83

anjannath opened this issue Aug 28, 2019 · 8 comments
Labels

Comments

@anjannath
Copy link

I am using hledger and would like to set it using g:ledger_bin, but when add it to my .vimrc, there are errors:

"2019-Sept.journal" [New File]
Error detected while processing /home/noone/.vim/plugged/vim-ledger/compiler/ledger.vim:
line   28:
E121: Undefined variable: g:ledger_extra_options
E116: Invalid arguments for function substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ source\ %:S'
Press ENTER or type command to continue
let g:ledger_bin = '/usr/bin/hledger'`
@gainhad
Copy link

gainhad commented Oct 6, 2019

Do you have g:ledger_extra_options set? I set it to an empty string and that fixed the issue for me.

@alerque alerque added the bug label Oct 6, 2019
@alerque
Copy link
Member

alerque commented Oct 6, 2019

Thanks for noting that @gainhad, if that's really the case that's clearly a bug. It shouldn't require that option to be set.

@alerque
Copy link
Member

alerque commented Oct 8, 2019

@gainhad The workaround you describe seems to be contraindicated by this code:

if !exists('g:ledger_extra_options')
let g:ledger_extra_options = ''
endif

In other words the plugin is already setting it to an empty string if it is not set. The only way your workaround would fix anything is if your configuration was setting it to something invalid first, then clearing it would help. Not being set at all should not be an issue.

I still don't know what the problem is here, but that doesn't seem to be it.

@alerque
Copy link
Member

alerque commented Oct 8, 2019

@anjannath and @gainhad I'm wondering if you guys even have the ledger file type set properly. The only way I can think of to get that error is if you try to call a function of the plugin (the source of which will autoload) before having loaded the filetype definition (which sets up those variables).

When you open one of your journals, what is the output of :set ft?

@gainhad
Copy link

gainhad commented Oct 8, 2019

@alerque :set ft outputs filetype=ledger

I think I might know the issue. :help ledger-tips recommends setting g:ledger_bin in the .vimrc, which results in errors unless g:ledger_extra_options is set. If I set g:ledger_bin in /after/ftplugin/ledger.vim instead, then g:ledger_extra_options does not need to be set and there are no errors.

@alerque
Copy link
Member

alerque commented Oct 8, 2019

@gainhad That's some sort of race condition, vimrc should be the correct place to set that.

Thanks for the info though.

@gainhad
Copy link

gainhad commented Oct 8, 2019

@alerque No problem. Let me know if there's any other info that might be useful.

alerque added a commit to alerque/vim-ledger that referenced this issue Oct 26, 2019
@alerque
Copy link
Member

alerque commented Oct 26, 2019

@anjannath and @gainhad this should be fixed now, please let me know if it gives you any trouble. If you don't need g:ledger_extra_options for anything you should be able to drop it from you rc files with no trouble. Also in #88 I tweaked a few things so detecting g:ledger_bin is a little more robust and you may or may not need to set it manually. Again feel free to raise issues if you have any.

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

No branches or pull requests

3 participants