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

index out of range, 142_save_by_filetype, line 5, proposed fix #98

Closed
stepds opened this issue Sep 21, 2014 · 10 comments
Closed

index out of range, 142_save_by_filetype, line 5, proposed fix #98

stepds opened this issue Sep 21, 2014 · 10 comments

Comments

@stepds
Copy link

stepds commented Sep 21, 2014

I think you could change something in file easytags.txt to avoid a run-time error.
File easytags.txt says about g:easytags_languages option
[...]

  let g:easytags_languages = {
  \   'language': {
  \     'cmd': g:easytags_cmd,
  \       'args': [],
  \       'fileoutput_opt': '-f',
  \       'stdout_opt': '-f-',
  \       'recurse_flag': '-R'
  \   }
  \}

Each key is a special language definition. The key is a Vim file type in
lowercase. The above snippet shows the defaults; you only need to specify
options that differ.

And so I did, I only specified options that differ, like so (Windows _vimrc):

  let g:easytags_languages = {
  \   'r': {
  \     'cmd': g:easytags_cmd,
  \       'args': [ '"--options='.$VIM.'\ctags\ctags.cnf" ],
  \       'fileoutput_opt': '-f',
  \       'stdout_opt': '-f-',
  \       'recurse_flag': '-R'
  \   }
  \}

But something was missing because when I ran :UpdateTags easytags output an error message

easytags.vim 3.7: Vim(let):E684: list index out of range: 4 (at function xolox#easytags#update..xolox#easytags#update#with_vim..<SNR>142_save_by_filetype, line 5)

I worked around this error by specifying more options for my custom command. I copied some options from the default call to ctags in function s:prep_cmdfile. So now easytags tags .r files just fine with the changed line in _vimrc:

  \       'args': [ '"--options='.$VIM.'\ctags\ctags.cnf" --fields=+l --sort=no' ],
@xolox
Copy link
Owner

xolox commented Nov 11, 2014

Hi @stepds and thanks for the feedback.

First I'll try to reply to your original point:

The idea behind the g:easytags_languages option is to add support for languages that are not supported by Exuberant Ctags, so using a custom tag extraction program that will probably have a completely different command line interface but with compatible output. In such cases the vim-easytags plug-in can't tell whether that program would support the required --fields=+l option (probably not though) so it can't add it automatically.

Side bar: This discussion does highlight a weak point (bug?) of vim-easytags: I don't use custom language definitions myself so never noticed, but I guess this feature does not go well together with vim-easytags' dependence on the language: field added by Exuberant Ctags but probably not by other tools.

Second I can't resist a more general reply:

I don't really get your example, because you're creating a definition for a custom tag generation command, but it's just using g:easytags_cmd, and I don't see any non-default options added except for the ctags.cnf file. If all you want to do is make sure your ctags.cnf file is loaded, why not put it somewhere where Exuberant Ctags finds it automatically? And why do that only for R, using a custom language definition?

@stepds
Copy link
Author

stepds commented Nov 13, 2014

Hi xolox,

why not put it somewhere where Exuberant Ctags finds it automatically?
Because I use vim in a self-contained, portable folder configuration on Windows. That includes an exuberant ctags folder. Exub. ctags can't automatically find its configuration file unless the file is in some fixed location - think of /etc/ctags.cnf in linux, but it's actually Windows. I can't put the configuration file in a fixed location, because it would be outside the self-contained, portable vim folder. So I need to resort to command-line switches to tell ctags where to find its cnf file.

And why do that only for R, using a custom language definition?
I do that for three more languages I use, the configuration I sent was a paired down example.
I only do it for three languages because those are the only ones I need that ctags can't automaticaly parse. For the ones it knows I don't need to pass a command-line option.

I don't see any non-default options added except for the ctags.cnf file.
That's the one I need to make it work, and it's a non-default option.

The idea behind the g:easytags_languages option is to add support for languages that are not supported by Exuberant Ctags...
...or that Exub ctags can support only through command-line options - you may consider. Admittedly, my portable vim on Windows requirement is outside the scope of your design, ATM - but you see that I can make it work regardless by working around the error message I reported.
Thanks xolox!

@xolox
Copy link
Owner

xolox commented Nov 13, 2014

Hi @stepds and thanks for the reply, I now have a better understanding of the reasoning that led to the issue you reported. I think I can help out fairly easily, I'll be back in a moment :-)

xolox added a commit that referenced this issue Nov 13, 2014
See also issue #98 on GitHub:
  #98
@xolox
Copy link
Owner

xolox commented Nov 13, 2014

I believe the new g:easytags_opts option can resolve your issue and simplify your Vim configuration significantly. Can you try it out?

@stepds
Copy link
Author

stepds commented Nov 21, 2014

Some issue, see if this tells you anything
_vimrc

let g:easytags_cmd = $VIM.'\ctags\ctags.exe'
let g:easytags_opts = '"--options='.$VIM.'\ctags\ctags.cnf"'

first and second runs (didn't try more)

:messages
Error detected while processing function xolox#easytags#register..xolox#easytags#get_tagsfile..xolox#easytags#filetypes#canonicalize..<SNR>151_discover_supported_filetypes..xolox#easytags#ctags_command:
line 6:
E712: Argument of map() must be a List or Dictionary
E712: Argument of extend() must be a List or Dictionary

@kopischke
Copy link

@xolox Just happened on this while browsing my issues stream. I'm currently deep in Vim script quirks and oddities terrirtory in a project of mine, and I had a kind of déjà-vu reading the error reports, so I thought I'd share my observations. Feel free to shoot me down if I'm off base, but here goes:

  • OP’s original 'args' value was missing a closing single quote; this kind of things makes Vim barf “out of index” errors when it happens in nested collections. The revised example with extra options closes its quotes correctly, which would explain why it worked.
  • didn't have times to root through the code, but considering the original dict 'args' value is a list, might the error reported by @stepds be due to the fact the new global option is a scalar, but the processing function still expects a list at some point before normalisation occurs?

@xolox
Copy link
Owner

xolox commented Nov 21, 2014

@stepds: As the documentation says the option expects a list of strings, just like the args entry for
languages defined via g:easytags_languages while the example you quoted defines a string:

let g:easytags_opts = '"--options='.$VIM.'\ctags\ctags.cnf"'

If you change the above to this it should work:

let g:easytags_opts = ['--options=$VIM\ctags\ctags.cnf']

As you may have noticed I just published vim-easytags 3.9.1, this new version contains two changes:

  1. Environment variables in the strings contained in g:easytags_opts are now expanded (so you don't have to do that manually anymore, you can see this in my example)
  2. I've tried to clarify the documentation with an example based on this issue.

@xolox
Copy link
Owner

xolox commented Nov 21, 2014

@kopischke wrote:

OP’s original 'args' value was missing a closing single quote; this kind of things makes Vim barf “out of index” errors when it happens in nested collections. The revised example with extra options closes its quotes correctly, which would explain why it worked.

The error in the example may well be caused by a copy/paste error, reformatting or typing out an example. If that error was in the OPs vimrc it would have caused an error at the definition site, not the error the OP quoted:

easytags.vim 3.7: Vim(let):E684: list index out of range: 4 (at function xolox#easytags#update..xolox#easytags#update#with_vim..<SNR>142_save_by_filetype, line 5)

Given the above, in my opinion this has nothing to do with Vim script quirks and oddities (although I do admit there are _a lot_ of those :-).

@stepds
Copy link
Author

stepds commented Nov 22, 2014

Brilliant, with the revised vimrc easytags works smoothly, thanks!
The updated example text is much improved, now it speaks to me, and hopefully to others, as to the benefit.
OT what's the markdown to quote someone's text, like in your reply above?

@xolox
Copy link
Owner

xolox commented Nov 22, 2014

@stepds: I'm glad to hear that the revised documentation helps and that you can now easily tell vim-easytags what to do without needing any creative hacks :-). About the Markdown quoting, you do that by starting a paragraph with a > symbol. I'm closing this issue now because your problem seems to be resolved :-). Happy Vimming!

@xolox xolox closed this as completed Nov 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants