robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
a6827be98f
master
1if vim . g . loaded_man ~= nil then 2return 3end 4vim . g . loaded_man =true 5 6vim . api . nvim_create_user_command ( 'Man' , function ( params ) 7local man =require ( 'man' ) 8if params . bang then 9man . init_pager () 10else 11local _ , err =pcall ( man . open_page , params . count , params . smods , params . fargs ) 12if err then 13vim . notify ( 'man.lua: ' .. err , vim . log . levels . ERROR ) 14end 15end 16end , { 17bang =true , 18bar =true , 19range =true , 20addr ='other' , 21nargs ='*' , 22complete =function ( ... ) 23return require ( 'man' ). man_complete ( ... ) 24end , 25} ) 26 27local augroup =vim . api . nvim_create_augroup ( 'nvim.man' , {} ) 28 29vim . api . nvim_create_autocmd ( 'BufReadCmd' , { 30group =augroup , 31pattern ='man://*' , 32nested =true , 33callback =function ( params ) 34local err =require ( 'man' ). read_page ( assert ( params . match : match ( 'man://(.*)' ))) 35if err then 36vim . notify ( 'man.lua: ' .. err , vim . log . levels . ERROR ) 37end 38end , 39} ) 40 41vim . api . nvim_create_autocmd ( 'BufWinEnter' , { 42group =augroup , 43pattern ='man://*' , 44callback =function () 45local err =require ( 'man' ). refresh_page () 46if err then 47vim . notify ( 'man.lua: ' .. err , vim . log . levels . ERROR ) 48end 49end , 50} )