robin/ivy
my custom neovim config
git clone https://git.robinwobin.dev/robin/ivy
fe63ce7
main
1local components ={ 2{ 3name ="inlay_hint" , 4callback =function ( client , buf ) 5if client . server_capabilities . inlayHintProvider then 6vim . lsp . inlay_hint . enable ( true , { bufnr =buf } ) 7end 8end , 9} , 10{ 11name ="document_highlight" , 12callback =function ( client , buf ) 13if client . server_capabilities . documentHighlightProvider then 14local augroup =vim . augroup ( string . format ( "@ivy.lsp.document_highlight.%d" , buf ), true ) 15augroup ( { "CursorHold" , "CursorHoldI" } , { 16buffer =buf , 17desc ="highlight lsp reference" , 18} , function () 19vim . lsp . buf . clear_references () 20vim . lsp . buf . document_highlight () 21end ) 22augroup ( "CursorMoved" , { 23buffer =buf , 24desc ="clear lsp references" , 25} , function () 26vim . lsp . buf . clear_references () 27end ) 28end 29end , 30} , 31{ 32name ="linked_editing_range" , 33callback =function ( client , _ ) 34if client . server_capabilities . linkedEditingRangeProvider then 35vim . lsp . linked_editing_range . enable ( true , { client_id =client . id } ) 36end 37end , 38} , 39{ 40name ="document_color" , 41callback =function ( client , bufnr ) 42if client . server_capabilities . documentColorProvider then 43vim . lsp . document_color . enable ( true , bufnr ) 44end 45end , 46} , 47{ name ="user" , callback =vim . g . lsp_on_attach } , 48} 49 50vim . iter ( ipairs ( components )): each ( function ( _ , fn ) 51vim . on ( "LspAttach" , "@ivy.lsp." .. fn . name , function ( ev ) 52local client =vim . lsp . get_client_by_id ( ev . data . client_id ) 53if client == nil then 54return 55end 56local ok , result =pcall ( fn . callback , client , ev . buf ) 57if not ok then 58vim . notify ( 59( "unable to run attach events for lsp server '%s':\n\t%s" ): format ( client . name , vim . inspect ( result )), 60vim . log . levels . ERROR 61) 62return 63end 64end ) 65end )