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

iskeyword clobbered when restoring #26

Open
unphased opened this issue Aug 24, 2016 · 4 comments
Open

iskeyword clobbered when restoring #26

unphased opened this issue Aug 24, 2016 · 4 comments

Comments

@unphased
Copy link

unphased commented Aug 24, 2016

My C++ files end up loading up (when restoring with vim -S or nvim -S) with iskeyword having gained a - which causes problems for various reasons.

What's confusing to me is that the Session.vim file has no mention of iskeyword inside of it. And using verbose set iskeyword? does NOT show me where it got set/changed.

I also acknowledge that this is likely not an error with or caused by obsession... but hopefully someone has a clue for me.

@tpope
Copy link
Owner

tpope commented Aug 26, 2016

Are you loading only C++ files? My hunch is that some rogue runtime file is mucking with the global value, and the session is only relevant because that triggers it at startup.

@unphased
Copy link
Author

unphased commented Aug 26, 2016

Well, I'm still confused, but I can verify that it happens with vim as well as nvim so that means something specific and potentially tractable is likely at the root of this.

I'm working on reproducing this with a more "minimal" Session.vim file.

@unphased
Copy link
Author

unphased commented Aug 26, 2016

OK I found what I believe is the culprit. Whenever the session I'm restoring includes both C++ and JS files, this happens, because my ~/.vim/after/ftplugin/javascript.js contains the line set iskeyword+=-.

For whatever reason (maybe the cause are the argglobal or some other such thing strewn about these Session.vim files), that appears to be getting run on the filetypes that it isn't intended for.

I have also tested that if I replace my after/ftplugin tweaks to iskeyword using setlocal that this solves the problem!

I don't know enough about setlocal or ftplugin or Vim and Vim best practices in general to say whether this is a problem with Vim's mksession stuff, this plugin, or whatever else. All I can tell is that iskeyword is supposedly local to a buffer (that's what help says), therefore the use of setlocal theoretically is redundant, but clearly is not in this scenario.

For now I will be changing all these type of tweaks to setlocal and I can happily resume using sessions again.

@benknoble
Copy link

@unphased (Buffer-)Local options are only changed locally when using setlocal; otherwise, they are set globally. It is generally good practice to prefer setlocal (and *map <local>, &c.) in ftplugin files for this reason.

This can probably be closed.

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