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

adapt educate to &spelllang #2

Open
Konfekt opened this issue Apr 10, 2014 · 8 comments
Open

adapt educate to &spelllang #2

Konfekt opened this issue Apr 10, 2014 · 8 comments

Comments

@Konfekt
Copy link

Konfekt commented Apr 10, 2014

A feature request: If Educate is set, it changes quotes according to the current &spelllang. That is, if for example &spelllang = "de", the setting

let g:textobj#quote#doubleDefault = '„“' " „doppel“
let g:textobj#quote#singleDefault = '‚‘' " ‚einzel‘

is used.

@reedes
Copy link
Collaborator

reedes commented Apr 10, 2014

The defaults could be set from &spelllang, but we'd need a good mapping of possible &spelllang values to the corresponding quotes for each language.

Here is one reference, but I can't vouch for its accuracy: http://en.wikipedia.org/wiki/International_variation_in_quotation_marks

For example, on that page under "Spanish" guillemets  are the primary, but an Argentinian friend said they aren't that common.

Without a verified mapping, I'm hesitant to force arbitrary defaults on users.

@Konfekt
Copy link
Author

Konfekt commented Apr 12, 2014

Ok,

So something that would not enforce anything but would still be helpful is a global
dictionary variable between languages and quotation marks. Set to sensible
defaults, but as a global variable modifiable by the user.

Then your educate function, as well as i/aq would look up the quotes
corresponding to the current spellcheck language by this dictionary.

@mcepl
Copy link

mcepl commented Jan 11, 2017

Without a verified mapping, I'm hesitant to force arbitrary defaults on users.

And how do you propose we would make such list? (BTW, as a native Czech, I can confirm that the Wikipedia page is correct for Czech, except the alternative quotes (»«) are really archaic, and I saw them used like twice in my life in old books.

@reedes
Copy link
Collaborator

reedes commented Jan 12, 2017

As another temporary option you can define a command that'll change a number of settings, as shown in my Lexical plugin...

https://github.com/reedes/vim-lexical/blob/master/README.markdown#define-your-own-commands

@mcepl
Copy link

mcepl commented Jun 16, 2017

The defaults could be set from &spelllang, but we'd need a good mapping of possible &spelllang values to the corresponding quotes for each language.

Also, what kind of event one should use when the &spelllang is set in the modeline (FileType is too early, isn't it?). Could I do something horrible like:

function! TextObjSettings()
  if &spelllang == 'cs'
     call textobj#quote#init({ 'double':'„“', 'single':'‚‘' })
  elseif &spelllang == 'en'
      call textobj#quote#init({ 'double':'“”', 'single':'‘’' })
  endif
endfunction

autocmd FileType markdown, rst :au InsertEnter :call TextObjSettings()<CR>

(this particularly doesn't work; why?)

@Konfekt
Copy link
Author

Konfekt commented Jun 16, 2017

That's the new OptionSet autocmd that takes hold of settings set in the mode line.

@mcepl
Copy link

mcepl commented Jan 18, 2018

Note, that OptionSet is not activated on entering the buffer, so one needs as well to add

autocmd OptionSet spelllang call TextObjSettings()
autocmd BufEnter *.rst call TextObjSettings()

@alerque
Copy link
Member

alerque commented Feb 11, 2022

I believe this information be derived from Unicode CLDR data, but it will take bit of fiddling. Unless we want to add a Lua dependency (e.g. I could add this data to cldr-lua) the thing to do is probably have an update script that fetches and parses the data and stores it in something cheap to process from viml.

If somebody wants to work on making this configurable so that instead of using a value it calls a function for the desired language, uses the function return value if present, or falls back to a default — then I would help with getting the lang → quotation character map imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants