Created
October 19, 2024 14:29
-
-
Save kuuote/b2c23a09105b5716826bb8505effb288 to your computer and use it in GitHub Desktop.
読書会util
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:contain_lines = v:false | |
function! s:open() abort range | |
GinCd | |
let file = expand('%:.') | |
if a:firstline == a:lastline | |
let line = printf('L%d', a:firstline) | |
else | |
let line = printf('L%d+%d', a:firstline, a:lastline - a:firstline) | |
endif | |
let lines = getline(a:firstline, a:lastline) | |
tabonly! | |
tabnew | |
setlocal buftype=nofile bufhidden=hide noswapfile | |
call ddc#custom#patch_buffer({ | |
\ 'sources': ['skkeleton'], | |
\ 'specialBufferCompletion': v:true, | |
\ }) | |
call setline(1, printf('%s#%s ', file, line)) | |
if s:contain_lines | |
let a = flatten([['```'], lines, ['```']]) | |
call setline(2, a) | |
endif | |
call feedkeys('ggA', 'n') | |
endfunction | |
nnoremap I :call <SID>open()<CR> | |
xnoremap I :call <SID>open()<CR> | |
nno gy <cmd>Gina browse --yank --exact :<cr><cmd>let @+ = @+ .. '#L' .. line('.')<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ライセンスはNYSLにしておきます