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

Optionally avoid mucking with iskeyword in autoload #66

Open
otherjoel opened this issue Dec 29, 2017 · 10 comments
Open

Optionally avoid mucking with iskeyword in autoload #66

otherjoel opened this issue Dec 29, 2017 · 10 comments

Comments

@otherjoel
Copy link

I am working on syntax highlighting for Scribble and Pollen, which are Racket/Scheme programming languages for writing prose. Being Racket languages, they have their own requirements for iskeyword.

When running pencil#init() from my vimrc as part of filetype detection for Scribble/Pollen docs, the syntax file sets iskeyword and then Pencil clobbers it right away.

Right now I can work around this by never using pencil#init() in my vimrc and instead enabling it manually with :Pencil after the file is open. However I would prefer to be able to pass pencil#init() a parameter to keep it from touching iskeyword at all. Please let me know if you would accept a pull request to that effect. Or, maybe there is already some way of avoiding this issue that I have overlooked.

@reedes
Copy link
Collaborator

reedes commented Mar 11, 2018

Sorry for the delay.

iskeyword is a bit of a pain in the neck. Pencil modifies it to support various punctuation in words, such as "$20 30% D&D #40 highest-rated O'Toole Mary's". Other conflicting cases are syntax plugins that support fenced code blocks which favor their own keyword definitions. Pencil clobbers theirs as well.

There's no arg (or global) to avoid it messing with iskeyword, but it'd be fairly harmless to add. Send a pull request that works for you. Thanks.

@BlueDrink9
Copy link
Contributor

I'm noticing that pencil seems to remove underscore (_) from iskeyword, which keeps messing up my flow. Is there a reason for removing the underscore?

@BlueDrink9
Copy link
Contributor

BlueDrink9 commented Sep 10, 2020

@reedes is there any reason for removing _ at:

https://github.com/reedes/vim-pencil/blob/236380f1afcc1df10ae78cbf2c6e958d29183eaa/autoload/pencil.vim#L326-L328

None is given in the comments, and it messes with things like LaTeX keywords. The only reason I can think for keeping it is to not treat Markdown _italic_ delimiters as words, but surely syntax-specific things should be left up to the user in that case...

The problem is that the bufenter autocmd you use there makes it impossible to overwrite the changes to iskeyword myself by re-adding _.
I'm unsure why it needs an autocmd, when it is setting a buffer-local option anyway.

Possibly adding a UserAu PencilInitDone would be useful for letting people customise their settings after pencil changes them?

@alerque
Copy link
Member

alerque commented Sep 10, 2020

I can't speak to the history of this so I'm unsure about just dropping it, but I agree a cleaner way to set this that was easier to override would be nice. You could do it right now I think just by appending your own AutoCmd to the same group (it's not clearing the group, but even if it was I think you could append to it yourself), but that's messier than it should be. I also don't see the reason for needing the BufEnter trigger given that there is no filtering being done at this stage for types of buffers or whatever. Directly setting the value should have the same effect.

@BlueDrink9
Copy link
Contributor

I hadn't considered adding to the group, but then is there any guarantee of running order for autocmds in the same group and event?

@alerque
Copy link
Member

alerque commented Sep 10, 2020

I did wonder about whether there was a guarantee on running order, but I think autocmds are run in the order added to the group. Hence if you do the adding to the group after the plugin is loaded it should work. Somebody would have to test that though, I could be wrong in my impression.

Either way I'd be game for a better implementation too, but some back story about what the _ business was about in the first place would be nice to have before we start changing things.

@reedes
Copy link
Collaborator

reedes commented Sep 10, 2020

Regarding excluding _ from iskeyword, I don’t recall the specifics, but likely due to behavior with markup for markdown, etc.

A solution that selectively clobbers will be tricky given the various use cases. (Eg, a callback function can reduce responsiveness for majority of users who don’t need it.)

@BlueDrink9
Copy link
Contributor

@reedes my proposal to solve it (or at least let users solve it themselves) is to add doautocmd User PencilInitDone after https://github.com/reedes/vim-pencil/blob/236380f1afcc1df10ae78cbf2c6e958d29183eaa/autoload/pencil.vim#L478

Is that what you meant by callback function?

@izaakm
Copy link

izaakm commented Sep 17, 2021

Is this still active? I'd also like a way to disable this.

Right now I'm doing this in my vimrc to override vim-pencil, but I'm not very familiar with vimscript so may have unintended side-effects:

au BufEnter * setl isk& | setl isk+=_ | setl isk-=$,%,&,#,-,',+

@alerque
Copy link
Member

alerque commented Sep 18, 2021

I'm sorry I don't have the bandwidth at the moment to work on this myself, but I am at least monitoring for contributions. If anybody comes up with a PR that addresses this I'll be happy to review it and if all is well facilitate it getting publish.

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

5 participants