preservim / vim-textobj-quote

Use ‘curly’ quote characters in Vim
Other
123 stars 6 forks source link

Need instructions for "Configurable to support international variations in quotation marks" #21

Open boydkelly opened 4 years ago

boydkelly commented 4 years ago

In French also there is a non breakable space between the quote mark and text. I just tried as a test to put u00a0 twice between the french quotes as below but it did' work. autocmd FileType *.adoc call textobj#quote#init({ 'double':'« »', 'single':'«»', 'educate': 1 }) Can textobj help me out here? Or any other suggestions?

alerque commented 4 years ago

I use vim-surround which handles (with and without) whites-pace inside parenthesis/brace/bracket/caret text objects (( example ) and (example)), so there must be a way to do this. I don't think this plugin is setup to do it now but somehow somebody should implement this for French!

boydkelly commented 4 years ago

Hi Caleb. Thanks for the comment. Just an FYI, I got something working; I found this mapping on an old 2011 forum post. http://vim.1045645.n5.nabble.com/Function-to-write-correctly-French-quotation-marks-td4259054.html

function! LanguageSettings()
      if &spelllang =~ 'fr'
         set keymap=french 
         :imap <expr> " getline('.')[col('.')-2]=~'\S' ?  ' »' : '« '
         :imap <expr> ' getline('.')[col('.')-2]=~'\S' ?  ' »' : '« '
      elseif &spelllang =~ 'en'
         :silent! iunmap  "
         :silent! iunmap  '
      endif
endfunction 

To complete this in my French keymap, I have the mappings for the question mark and exclamation mark including the nonbreakable space which also works fine:

loadkeymap
?   ?
!   !

My only issue now is I can't seem to get everything in one place. The keymap file doesn't seem to support an expression as with imap. And if I try to load the ?! mappings with imap (that include a tab and u-00a0 it totally hangs my terminal. Anyways it is possible now for me to painlessly type in French with my favorite editor! Cheers!

telemachus commented 2 years ago

I think that this is out of scope for this plugin.

I'd like to close the issue with a pointer to vim-sandwich, which could maybe handle something like what the OP wanted.

/ping @alerque

alerque commented 2 years ago

I'm not quite sure why this would be out of scope? Or perhaps I misunderstand what the OP wanted. Is the problem just that French quote styles include two characters on each end instead of one? Other than the series of glyphs used what is fundamentally different about what they want to accomplish?

telemachus commented 2 years ago

Sorry, I wasn't clear. By "out of scope," I meant that I didn't think that we would implement this directly in the plugin itself.

On the README, we offer advice about non-English quote characters, but I didn't think that we would ever directly implement them in the plugin. (We could, but so far nobody seems to have taken on that work.)

That said, I was mostly trying to clean up the issues that seemed stale to me. If you want to leave this open to gather other suggestions or as a note for a future enhancement, that makes sense too.