vim-pandoc / vim-pandoc-syntax

pandoc markdown syntax, to be installed alongside vim-pandoc
MIT License
425 stars 61 forks source link

Is it possible to configure options locally (on a per buffer basis) ? #368

Open lyndhurst opened 2 years ago

lyndhurst commented 2 years ago

Hi, I am using vim-pandoc along with vimwiki, and it is mostly working as expected so far.

I have the "conceal url" option set to 0 globally to avoid the erratic wrapping it causes, but I wanted to enable it for the vimwiki index pages since they consist mostly of list items made of links, it would improve the visual.

Unfortunately, I could not find a way in the documentation to set vim-pandoc-syntax options locally whereas vim-pandoc mentions the possibility to use the let b:pandoc... local variables to do so.

I am aware of the s:WithConceal() function, but for what I understood, it is designed to set up new specific concealment rules.

Since my index pages are all named index.wiki, I tried the following, but received an illegal variable error message:

augroup wiki_index_files
    autocmd!
    autocmd BufRead,BufNewFile */index.wiki
                \ setlocal nofoldenable |
                \ let b:pandoc#syntax#conceal#urls = 1
augroup END
fmoralesc commented 2 years ago

I don't think there is a local version of the conceal#urls setting, that would have to be implemented (need to think about how that would work).

user202729 commented 2 years ago

Making an autocmd command that checks the path of the current file and set the variable accordingly should work, as long as it's executed before the pandoc syntax file is loaded.

Because in vim :syn commands are already buffer-local.

lyndhurst commented 2 years ago

Making an autocmd command that checks the path of the current file and set the variable accordingly should work, as long as it's executed before the pandoc syntax file is loaded.

Thanks user202729, setting the global g:pandoc#syntax#conceal#urls with an autocmd does work, but then, all other pandoc files are affected too, I am trying to target index files only.

I don't think there is a local version of the conceal#urls setting, that would have to be implemented (need to think about how that would work).

Thank you fmoralesc, I look forward to it.