Skip to content

Instantly share code, notes, and snippets.

@kuuote
Created October 19, 2024 14:29
Show Gist options
  • Save kuuote/b2c23a09105b5716826bb8505effb288 to your computer and use it in GitHub Desktop.
Save kuuote/b2c23a09105b5716826bb8505effb288 to your computer and use it in GitHub Desktop.
読書会util
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>
@kuuote
Copy link
Author

kuuote commented Oct 19, 2024

ライセンスはNYSLにしておきます

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