├── .gitignore ├── README.md ├── assets └── ojosama.mp4 ├── autoload └── ojosama.vim └── plugin └── ojosama.vim /.gitignore: -------------------------------------------------------------------------------- 1 | ### Generated by gibo (https://github.com/simonwhitaker/gibo) 2 | ### https://raw.github.com/github/gitignore/e5323759e387ba347a9d50f8b0ddd16502eb71d4/Global/Vim.gitignore 3 | 4 | # Swap 5 | [._]*.s[a-v][a-z] 6 | !*.svg # comment out if you don't need vector files 7 | [._]*.sw[a-p] 8 | [._]s[a-rt-v][a-z] 9 | [._]ss[a-gi-z] 10 | [._]sw[a-p] 11 | 12 | # Session 13 | Session.vim 14 | Sessionx.vim 15 | 16 | # Temporary 17 | .netrwhist 18 | *~ 19 | # Auto-generated tag files 20 | tags 21 | # Persistent undo 22 | [._]*.un~ 23 | 24 | 25 | ### https://raw.github.com/github/gitignore/e5323759e387ba347a9d50f8b0ddd16502eb71d4/Global/macOS.gitignore 26 | 27 | # General 28 | .DS_Store 29 | .AppleDouble 30 | .LSOverride 31 | 32 | # Icon must end with two \r 33 | Icon 34 | 35 | # Thumbnails 36 | ._* 37 | 38 | # Files that might appear in the root of a volume 39 | .DocumentRevisions-V100 40 | .fseventsd 41 | .Spotlight-V100 42 | .TemporaryItems 43 | .Trashes 44 | .VolumeIcon.icns 45 | .com.apple.timemachine.donotpresent 46 | 47 | # Directories potentially created on remote AFP share 48 | .AppleDB 49 | .AppleDesktop 50 | Network Trash Folder 51 | Temporary Items 52 | .apdisk 53 | 54 | 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## vim-ojosama 2 | 3 | Vim plugin for [ojosama](https://github.com/jiro4989/ojosama). 4 | 5 | https://user-images.githubusercontent.com/56591/174468526-cc5935d5-70ec-401f-8bd1-9ec72be62a89.mp4 6 | 7 | ## Requirement 8 | 9 | - ojosama 10 | - Vim 8.2.4656+ 11 | - Follow the [guidelines](https://event.nijisanji.app/guidelines/) 12 | 13 | ## Usage 14 | 15 | ### Display 16 | 17 | ```console 18 | Ojosama ハーブです 19 | ``` 20 | 21 | Finally message shows in commandline area 22 | 23 | ```console 24 | ξ ゚⊿ ゚)ξ< おハーブですわ 25 | ``` 26 | 27 | ### Format 28 | 29 | Format current buffer by following command 30 | 31 | ```console 32 | Ojosama 33 | ``` 34 | 35 | ### Settings 36 | 37 | ```console 38 | g:ojosama_runtime = 'path/to/ojosama' 39 | g:ojosama_prompt = 'ξ゚⊿゚)ξ< ' 40 | ``` 41 | 42 | ## Disclaimer 43 | 44 | This program follow the guidelines. 45 | - [ANYCOLOR二次創作ガイドライン](https://event.nijisanji.app/guidelines/) 46 | -------------------------------------------------------------------------------- /assets/ojosama.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heavenshell/vim-ojosama/9528328845e99404c04869cb5f50e9a215b317c1/assets/ojosama.mp4 -------------------------------------------------------------------------------- /autoload/ojosama.vim: -------------------------------------------------------------------------------- 1 | vim9script 2 | scriptencoding utf-8 3 | 4 | g:ojosama_runtime = get(g:, 'ojosama_runtime', '') 5 | g:ojosama_prompt = get(g:, 'ojosama_prompt', 'ξ゚⊿゚)ξ< ') 6 | 7 | var _job: job 8 | var resutls: list 9 | 10 | def Callback(_channel: channel, msg: string): void 11 | add(resutls, msg) 12 | enddef 13 | 14 | def ExitCallback(_: job, msg: number, winsaveview: dict): void 15 | silent deletebufline('%', 1, '$') 16 | setline(1, resutls) 17 | winrestview(winsaveview) 18 | enddef 19 | 20 | def Execute(input: string, winsaveview: dict): void 21 | _job = job_start(g:ojosama_runtime, { 22 | callback: (c, m) => Callback(c, m), 23 | exit_cb: (c, m) => ExitCallback(c, m, winsaveview), 24 | in_mode: 'nl', 25 | }) 26 | 27 | const channel = job_getchannel(_job) 28 | if ch_status(channel) ==# 'open' 29 | ch_sendraw(channel, input) 30 | ch_close_in(channel) 31 | endif 32 | enddef 33 | 34 | def Echo(_, msg: string): void 35 | echomsg g:ojosama_prompt .. msg 36 | enddef 37 | 38 | export def Format(...args: list): void 39 | if exists('job') && job_status(_job) !=# 'stop' 40 | call job_stop(_job) 41 | endif 42 | resutls = [] 43 | const winsaveview = winsaveview() 44 | 45 | const bufnum = bufnr('%') 46 | const input = join(getbufline(bufnum, 1, '$'), "\n") .. "\n" 47 | 48 | Execute(input, winsaveview) 49 | enddef 50 | 51 | export def Say(...args: list): void 52 | if g:ojosama_runtime ==# '' 53 | Echo('', 'Please install ojosama from https://github.com/jiro4989/ojosama') 54 | return 55 | endif 56 | const input = args[0] 57 | if input ==# '' 58 | Format(args) 59 | return 60 | endif 61 | if exists('job') && job_status(_job) !=# 'stop' 62 | call job_stop(_job) 63 | endif 64 | _job = job_start(printf('%s -t %s', g:ojosama_runtime, input), {callback: Echo}) 65 | enddef 66 | -------------------------------------------------------------------------------- /plugin/ojosama.vim: -------------------------------------------------------------------------------- 1 | vim9script 2 | 3 | if v:version < 802 && has('patch-8.2.4656') 4 | echoerr 'ojosama.vim requires Vim version 9.0+.' 5 | finish 6 | endif 7 | 8 | import autoload 'ojosama.vim' 9 | 10 | command! -buffer -nargs=* -range=0 11 | \ Ojosama ojosama.Say(, , , ) 12 | --------------------------------------------------------------------------------