Open otherjoel opened 6 years ago
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.
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?
@reedes is there any reason for removing _
at:
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?
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.
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?
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.
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.)
@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?
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-=$,%,&,#,-,',+
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.
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 myvimrc
as part of filetype detection for Scribble/Pollen docs, the syntax file setsiskeyword
and then Pencil clobbers it right away.Right now I can work around this by never using
pencil#init()
in myvimrc
and instead enabling it manually with:Pencil
after the file is open. However I would prefer to be able to passpencil#init()
a parameter to keep it from touchingiskeyword
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.