Skip to content

Commit

Permalink
feat: initialize user_jisyo
Browse files Browse the repository at this point in the history
  • Loading branch information
kawarimidoll committed Nov 23, 2023
1 parent 15807b5 commit 9e1368c
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions k.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ let s:keys_to_unmaps = []
let s:henkan_marker = ""
let s:select_marker = ""

let s:user_jisyo_path = expand('~/.cache/vim/SKK-JISYO.user')

let s:jisyo_list = [
\ { 'path': expand('~/.cache/vim/SKK-JISYO.L'), 'encoding': 'euc-jp' },
\ { 'path': s:user_jisyo_path, 'encoding': 'utf-8' },
\ { 'path': expand('~/.cache/vim/SKK-JISYO.geo'), 'encoding': 'euc-jp' },
\ { 'path': expand('~/.cache/vim/SKK-JISYO.emoji'), 'encoding': 'utf-8' },
\ ]

function! k#is_enable() abort
return s:is_enable
endfunction
Expand Down Expand Up @@ -84,6 +93,20 @@ endfunction
function! k#initialize() abort
let raw = json_decode(join(readfile('./kana_table.json'), "\n"))

if glob(s:user_jisyo_path)->empty()
call fnamemodify(s:user_jisyo_path, ':p:h')
\ ->iconv(&encoding, &termencoding)
\ ->mkdir('p')
let user_jisyo_lines = [
\ ';; フォーマット',
\ ';; yomi /(henkan(;setsumei)?/)+',
\ ';;',
\ ';; okuri-ari entries.',
\ ';; okuri-nasi entries.',
\ ]
call writefile(user_jisyo_lines, s:user_jisyo_path)
endif

let s:start_keys = {}
let s:end_keys = {}

Expand Down Expand Up @@ -230,12 +253,6 @@ function! s:get_insert_spec(key, henkan = v:false) abort
return get(kana_dict, '', a:key)
endfunction

let s:jisyo_list = [
\ { 'path': expand('~/.cache/vim/SKK-JISYO.L'), 'encoding': 'euc-jp' },
\ { 'path': expand('~/.cache/vim/SKK-JISYO.geo'), 'encoding': 'euc-jp' },
\ { 'path': expand('~/.cache/vim/SKK-JISYO.emoji'), 'encoding': 'utf-8' },
\ ]

function! k#get_henkan_list(str) abort
let henkan_list = []
for jisyo in s:jisyo_list
Expand Down

0 comments on commit 9e1368c

Please sign in to comment.