vimfn.lua 408 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144
  1. --- @meta _
  2. -- THIS FILE IS GENERATED
  3. -- DO NOT EDIT
  4. error('Cannot require a meta file')
  5. --- Return the absolute value of {expr}. When {expr} evaluates to
  6. --- a |Float| abs() returns a |Float|. When {expr} can be
  7. --- converted to a |Number| abs() returns a |Number|. Otherwise
  8. --- abs() gives an error message and returns -1.
  9. --- Examples: >vim
  10. --- echo abs(1.456)
  11. --- < 1.456 >vim
  12. --- echo abs(-5.456)
  13. --- < 5.456 >vim
  14. --- echo abs(-4)
  15. --- < 4
  16. ---
  17. --- @param expr number
  18. --- @return number
  19. function vim.fn.abs(expr) end
  20. --- Return the arc cosine of {expr} measured in radians, as a
  21. --- |Float| in the range of [0, pi].
  22. --- {expr} must evaluate to a |Float| or a |Number| in the range
  23. --- [-1, 1].
  24. --- Returns NaN if {expr} is outside the range [-1, 1]. Returns
  25. --- 0.0 if {expr} is not a |Float| or a |Number|.
  26. --- Examples: >vim
  27. --- echo acos(0)
  28. --- < 1.570796 >vim
  29. --- echo acos(-0.5)
  30. --- < 2.094395
  31. ---
  32. --- @param expr number
  33. --- @return number
  34. function vim.fn.acos(expr) end
  35. --- Append the item {expr} to |List| or |Blob| {object}. Returns
  36. --- the resulting |List| or |Blob|. Examples: >vim
  37. --- let alist = add([1, 2, 3], item)
  38. --- call add(mylist, "woodstock")
  39. --- <Note that when {expr} is a |List| it is appended as a single
  40. --- item. Use |extend()| to concatenate |Lists|.
  41. --- When {object} is a |Blob| then {expr} must be a number.
  42. --- Use |insert()| to add an item at another position.
  43. --- Returns 1 if {object} is not a |List| or a |Blob|.
  44. ---
  45. --- @param object any
  46. --- @param expr any
  47. --- @return any # Resulting |List| or |Blob|, or 1 if {object} is not a |List| or a |Blob|.
  48. function vim.fn.add(object, expr) end
  49. --- Bitwise AND on the two arguments. The arguments are converted
  50. --- to a number. A List, Dict or Float argument causes an error.
  51. --- Also see `or()` and `xor()`.
  52. --- Example: >vim
  53. --- let flag = and(bits, 0x80)
  54. --- <
  55. ---
  56. --- @param expr number
  57. --- @param expr1 number
  58. --- @return integer
  59. vim.fn['and'] = function(expr, expr1) end
  60. --- Returns Dictionary of |api-metadata|.
  61. ---
  62. --- View it in a nice human-readable format: >vim
  63. --- lua vim.print(vim.fn.api_info())
  64. --- <
  65. ---
  66. --- @return table
  67. function vim.fn.api_info() end
  68. --- When {text} is a |List|: Append each item of the |List| as a
  69. --- text line below line {lnum} in the current buffer.
  70. --- Otherwise append {text} as one text line below line {lnum} in
  71. --- the current buffer.
  72. --- Any type of item is accepted and converted to a String.
  73. --- {lnum} can be zero to insert a line before the first one.
  74. --- {lnum} is used like with |getline()|.
  75. --- Returns 1 for failure ({lnum} out of range or out of memory),
  76. --- 0 for success. When {text} is an empty list zero is returned,
  77. --- no matter the value of {lnum}. Example: >vim
  78. --- let failed = append(line('$'), "# THE END")
  79. --- let failed = append(0, ["Chapter 1", "the beginning"])
  80. --- <
  81. ---
  82. --- @param lnum integer
  83. --- @param text string|string[]
  84. --- @return 0|1
  85. function vim.fn.append(lnum, text) end
  86. --- Like |append()| but append the text in buffer {expr}.
  87. ---
  88. --- This function works only for loaded buffers. First call
  89. --- |bufload()| if needed.
  90. ---
  91. --- For the use of {buf}, see |bufname()|.
  92. ---
  93. --- {lnum} is the line number to append below. Note that using
  94. --- |line()| would use the current buffer, not the one appending
  95. --- to. Use "$" to append at the end of the buffer. Other string
  96. --- values are not supported.
  97. ---
  98. --- On success 0 is returned, on failure 1 is returned.
  99. ---
  100. --- If {buf} is not a valid buffer or {lnum} is not valid, an
  101. --- error message is given. Example: >vim
  102. --- let failed = appendbufline(13, 0, "# THE START")
  103. --- <However, when {text} is an empty list then no error is given
  104. --- for an invalid {lnum}, since {lnum} isn't actually used.
  105. ---
  106. --- @param buf integer|string
  107. --- @param lnum integer
  108. --- @param text string
  109. --- @return 0|1
  110. function vim.fn.appendbufline(buf, lnum, text) end
  111. --- The result is the number of files in the argument list. See
  112. --- |arglist|.
  113. --- If {winid} is not supplied, the argument list of the current
  114. --- window is used.
  115. --- If {winid} is -1, the global argument list is used.
  116. --- Otherwise {winid} specifies the window of which the argument
  117. --- list is used: either the window number or the window ID.
  118. --- Returns -1 if the {winid} argument is invalid.
  119. ---
  120. --- @param winid? integer
  121. --- @return integer
  122. function vim.fn.argc(winid) end
  123. --- The result is the current index in the argument list. 0 is
  124. --- the first file. argc() - 1 is the last one. See |arglist|.
  125. ---
  126. --- @return integer
  127. function vim.fn.argidx() end
  128. --- Return the argument list ID. This is a number which
  129. --- identifies the argument list being used. Zero is used for the
  130. --- global argument list. See |arglist|.
  131. --- Returns -1 if the arguments are invalid.
  132. ---
  133. --- Without arguments use the current window.
  134. --- With {winnr} only use this window in the current tab page.
  135. --- With {winnr} and {tabnr} use the window in the specified tab
  136. --- page.
  137. --- {winnr} can be the window number or the |window-ID|.
  138. ---
  139. --- @param winnr? integer
  140. --- @param tabnr? integer
  141. --- @return integer
  142. function vim.fn.arglistid(winnr, tabnr) end
  143. --- The result is the {nr}th file in the argument list. See
  144. --- |arglist|. "argv(0)" is the first one. Example: >vim
  145. --- let i = 0
  146. --- while i < argc()
  147. --- let f = escape(fnameescape(argv(i)), '.')
  148. --- exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
  149. --- let i = i + 1
  150. --- endwhile
  151. --- <Without the {nr} argument, or when {nr} is -1, a |List| with
  152. --- the whole |arglist| is returned.
  153. ---
  154. --- The {winid} argument specifies the window ID, see |argc()|.
  155. --- For the Vim command line arguments see |v:argv|.
  156. ---
  157. --- Returns an empty string if {nr}th argument is not present in
  158. --- the argument list. Returns an empty List if the {winid}
  159. --- argument is invalid.
  160. ---
  161. --- @param nr? integer
  162. --- @param winid? integer
  163. --- @return string|string[]
  164. function vim.fn.argv(nr, winid) end
  165. --- Return the arc sine of {expr} measured in radians, as a |Float|
  166. --- in the range of [-pi/2, pi/2].
  167. --- {expr} must evaluate to a |Float| or a |Number| in the range
  168. --- [-1, 1].
  169. --- Returns NaN if {expr} is outside the range [-1, 1]. Returns
  170. --- 0.0 if {expr} is not a |Float| or a |Number|.
  171. --- Examples: >vim
  172. --- echo asin(0.8)
  173. --- < 0.927295 >vim
  174. --- echo asin(-0.5)
  175. --- < -0.523599
  176. ---
  177. --- @param expr any
  178. --- @return number
  179. function vim.fn.asin(expr) end
  180. --- Run {cmd} and add an error message to |v:errors| if it does
  181. --- NOT produce a beep or visual bell.
  182. --- Also see |assert_fails()|, |assert_nobeep()| and
  183. --- |assert-return|.
  184. ---
  185. --- @param cmd string
  186. --- @return 0|1
  187. function vim.fn.assert_beeps(cmd) end
  188. --- When {expected} and {actual} are not equal an error message is
  189. --- added to |v:errors| and 1 is returned. Otherwise zero is
  190. --- returned. |assert-return|
  191. --- The error is in the form "Expected {expected} but got
  192. --- {actual}". When {msg} is present it is prefixed to that,
  193. --- along with the location of the assert when run from a script.
  194. ---
  195. --- There is no automatic conversion, the String "4" is different
  196. --- from the Number 4. And the number 4 is different from the
  197. --- Float 4.0. The value of 'ignorecase' is not used here, case
  198. --- always matters.
  199. --- Example: >vim
  200. --- call assert_equal('foo', 'bar', 'baz')
  201. --- <Will add the following to |v:errors|:
  202. --- test.vim line 12: baz: Expected 'foo' but got 'bar' ~
  203. ---
  204. --- @param expected any
  205. --- @param actual any
  206. --- @param msg? any
  207. --- @return 0|1
  208. function vim.fn.assert_equal(expected, actual, msg) end
  209. --- When the files {fname_one} and {fname_two} do not contain
  210. --- exactly the same text an error message is added to |v:errors|.
  211. --- Also see |assert-return|.
  212. --- When {fname_one} or {fname_two} does not exist the error will
  213. --- mention that.
  214. ---
  215. --- @param fname_one string
  216. --- @param fname_two string
  217. --- @return 0|1
  218. function vim.fn.assert_equalfile(fname_one, fname_two) end
  219. --- When v:exception does not contain the string {error} an error
  220. --- message is added to |v:errors|. Also see |assert-return|.
  221. --- This can be used to assert that a command throws an exception.
  222. --- Using the error number, followed by a colon, avoids problems
  223. --- with translations: >vim
  224. --- try
  225. --- commandthatfails
  226. --- call assert_false(1, 'command should have failed')
  227. --- catch
  228. --- call assert_exception('E492:')
  229. --- endtry
  230. --- <
  231. ---
  232. --- @param error any
  233. --- @param msg? any
  234. --- @return 0|1
  235. function vim.fn.assert_exception(error, msg) end
  236. --- Run {cmd} and add an error message to |v:errors| if it does
  237. --- NOT produce an error or when {error} is not found in the
  238. --- error message. Also see |assert-return|.
  239. ---
  240. --- When {error} is a string it must be found literally in the
  241. --- first reported error. Most often this will be the error code,
  242. --- including the colon, e.g. "E123:". >vim
  243. --- call assert_fails('bad cmd', 'E987:')
  244. --- <
  245. --- When {error} is a |List| with one or two strings, these are
  246. --- used as patterns. The first pattern is matched against the
  247. --- first reported error: >vim
  248. --- call assert_fails('cmd', ['E987:.*expected bool'])
  249. --- <The second pattern, if present, is matched against the last
  250. --- reported error. To only match the last error use an empty
  251. --- string for the first error: >vim
  252. --- call assert_fails('cmd', ['', 'E987:'])
  253. --- <
  254. --- If {msg} is empty then it is not used. Do this to get the
  255. --- default message when passing the {lnum} argument.
  256. --- *E1115*
  257. --- When {lnum} is present and not negative, and the {error}
  258. --- argument is present and matches, then this is compared with
  259. --- the line number at which the error was reported. That can be
  260. --- the line number in a function or in a script.
  261. --- *E1116*
  262. --- When {context} is present it is used as a pattern and matched
  263. --- against the context (script name or function name) where
  264. --- {lnum} is located in.
  265. ---
  266. --- Note that beeping is not considered an error, and some failing
  267. --- commands only beep. Use |assert_beeps()| for those.
  268. ---
  269. --- @param cmd string
  270. --- @param error? any
  271. --- @param msg? any
  272. --- @param lnum? integer
  273. --- @param context? any
  274. --- @return 0|1
  275. function vim.fn.assert_fails(cmd, error, msg, lnum, context) end
  276. --- When {actual} is not false an error message is added to
  277. --- |v:errors|, like with |assert_equal()|.
  278. --- The error is in the form "Expected False but got {actual}".
  279. --- When {msg} is present it is prefixed to that, along with the
  280. --- location of the assert when run from a script.
  281. --- Also see |assert-return|.
  282. ---
  283. --- A value is false when it is zero. When {actual} is not a
  284. --- number the assert fails.
  285. ---
  286. --- @param actual any
  287. --- @param msg? any
  288. --- @return 0|1
  289. function vim.fn.assert_false(actual, msg) end
  290. --- This asserts number and |Float| values. When {actual} is lower
  291. --- than {lower} or higher than {upper} an error message is added
  292. --- to |v:errors|. Also see |assert-return|.
  293. --- The error is in the form "Expected range {lower} - {upper},
  294. --- but got {actual}". When {msg} is present it is prefixed to
  295. --- that.
  296. ---
  297. --- @param lower number
  298. --- @param upper number
  299. --- @param actual number
  300. --- @param msg? string
  301. --- @return 0|1
  302. function vim.fn.assert_inrange(lower, upper, actual, msg) end
  303. --- When {pattern} does not match {actual} an error message is
  304. --- added to |v:errors|. Also see |assert-return|.
  305. --- The error is in the form "Pattern {pattern} does not match
  306. --- {actual}". When {msg} is present it is prefixed to that,
  307. --- along with the location of the assert when run from a script.
  308. ---
  309. --- {pattern} is used as with |expr-=~|: The matching is always done
  310. --- like 'magic' was set and 'cpoptions' is empty, no matter what
  311. --- the actual value of 'magic' or 'cpoptions' is.
  312. ---
  313. --- {actual} is used as a string, automatic conversion applies.
  314. --- Use "^" and "$" to match with the start and end of the text.
  315. --- Use both to match the whole text.
  316. ---
  317. --- Example: >vim
  318. --- call assert_match('^f.*o$', 'foobar')
  319. --- <Will result in a string to be added to |v:errors|:
  320. --- test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
  321. ---
  322. --- @param pattern string
  323. --- @param actual string
  324. --- @param msg? string
  325. --- @return 0|1
  326. function vim.fn.assert_match(pattern, actual, msg) end
  327. --- Run {cmd} and add an error message to |v:errors| if it
  328. --- produces a beep or visual bell.
  329. --- Also see |assert_beeps()|.
  330. ---
  331. --- @param cmd string
  332. --- @return 0|1
  333. function vim.fn.assert_nobeep(cmd) end
  334. --- The opposite of `assert_equal()`: add an error message to
  335. --- |v:errors| when {expected} and {actual} are equal.
  336. --- Also see |assert-return|.
  337. ---
  338. --- @param expected any
  339. --- @param actual any
  340. --- @param msg? any
  341. --- @return 0|1
  342. function vim.fn.assert_notequal(expected, actual, msg) end
  343. --- The opposite of `assert_match()`: add an error message to
  344. --- |v:errors| when {pattern} matches {actual}.
  345. --- Also see |assert-return|.
  346. ---
  347. --- @param pattern string
  348. --- @param actual string
  349. --- @param msg? string
  350. --- @return 0|1
  351. function vim.fn.assert_notmatch(pattern, actual, msg) end
  352. --- Report a test failure directly, using String {msg}.
  353. --- Always returns one.
  354. ---
  355. --- @param msg string
  356. --- @return 0|1
  357. function vim.fn.assert_report(msg) end
  358. --- When {actual} is not true an error message is added to
  359. --- |v:errors|, like with |assert_equal()|.
  360. --- Also see |assert-return|.
  361. --- A value is |TRUE| when it is a non-zero number or |v:true|.
  362. --- When {actual} is not a number or |v:true| the assert fails.
  363. --- When {msg} is given it is prefixed to the default message,
  364. --- along with the location of the assert when run from a script.
  365. ---
  366. --- @param actual any
  367. --- @param msg? string
  368. --- @return 0|1
  369. function vim.fn.assert_true(actual, msg) end
  370. --- Return the principal value of the arc tangent of {expr}, in
  371. --- the range [-pi/2, +pi/2] radians, as a |Float|.
  372. --- {expr} must evaluate to a |Float| or a |Number|.
  373. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  374. --- Examples: >vim
  375. --- echo atan(100)
  376. --- < 1.560797 >vim
  377. --- echo atan(-4.01)
  378. --- < -1.326405
  379. ---
  380. --- @param expr number
  381. --- @return number
  382. function vim.fn.atan(expr) end
  383. --- Return the arc tangent of {expr1} / {expr2}, measured in
  384. --- radians, as a |Float| in the range [-pi, pi].
  385. --- {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  386. --- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  387. --- |Number|.
  388. --- Examples: >vim
  389. --- echo atan2(-1, 1)
  390. --- < -0.785398 >vim
  391. --- echo atan2(1, -1)
  392. --- < 2.356194
  393. ---
  394. --- @param expr1 number
  395. --- @param expr2 number
  396. --- @return number
  397. function vim.fn.atan2(expr1, expr2) end
  398. --- Return a List containing the number value of each byte in Blob
  399. --- {blob}. Examples: >vim
  400. --- blob2list(0z0102.0304) " returns [1, 2, 3, 4]
  401. --- blob2list(0z) " returns []
  402. --- <Returns an empty List on error. |list2blob()| does the
  403. --- opposite.
  404. ---
  405. --- @param blob any
  406. --- @return any[]
  407. function vim.fn.blob2list(blob) end
  408. --- Put up a file requester. This only works when "has("browse")"
  409. --- returns |TRUE| (only in some GUI versions).
  410. --- The input fields are:
  411. --- {save} when |TRUE|, select file to write
  412. --- {title} title for the requester
  413. --- {initdir} directory to start browsing in
  414. --- {default} default file name
  415. --- An empty string is returned when the "Cancel" button is hit,
  416. --- something went wrong, or browsing is not possible.
  417. ---
  418. --- @param save any
  419. --- @param title string
  420. --- @param initdir string
  421. --- @param default string
  422. --- @return 0|1
  423. function vim.fn.browse(save, title, initdir, default) end
  424. --- Put up a directory requester. This only works when
  425. --- "has("browse")" returns |TRUE| (only in some GUI versions).
  426. --- On systems where a directory browser is not supported a file
  427. --- browser is used. In that case: select a file in the directory
  428. --- to be used.
  429. --- The input fields are:
  430. --- {title} title for the requester
  431. --- {initdir} directory to start browsing in
  432. --- When the "Cancel" button is hit, something went wrong, or
  433. --- browsing is not possible, an empty string is returned.
  434. ---
  435. --- @param title string
  436. --- @param initdir string
  437. --- @return 0|1
  438. function vim.fn.browsedir(title, initdir) end
  439. --- Add a buffer to the buffer list with name {name} (must be a
  440. --- String).
  441. --- If a buffer for file {name} already exists, return that buffer
  442. --- number. Otherwise return the buffer number of the newly
  443. --- created buffer. When {name} is an empty string then a new
  444. --- buffer is always created.
  445. --- The buffer will not have 'buflisted' set and not be loaded
  446. --- yet. To add some text to the buffer use this: >vim
  447. --- let bufnr = bufadd('someName')
  448. --- call bufload(bufnr)
  449. --- call setbufline(bufnr, 1, ['some', 'text'])
  450. --- <Returns 0 on error.
  451. ---
  452. --- @param name string
  453. --- @return integer
  454. function vim.fn.bufadd(name) end
  455. --- The result is a Number, which is |TRUE| if a buffer called
  456. --- {buf} exists.
  457. --- If the {buf} argument is a number, buffer numbers are used.
  458. --- Number zero is the alternate buffer for the current window.
  459. ---
  460. --- If the {buf} argument is a string it must match a buffer name
  461. --- exactly. The name can be:
  462. --- - Relative to the current directory.
  463. --- - A full path.
  464. --- - The name of a buffer with 'buftype' set to "nofile".
  465. --- - A URL name.
  466. --- Unlisted buffers will be found.
  467. --- Note that help files are listed by their short name in the
  468. --- output of |:buffers|, but bufexists() requires using their
  469. --- long name to be able to find them.
  470. --- bufexists() may report a buffer exists, but to use the name
  471. --- with a |:buffer| command you may need to use |expand()|. Esp
  472. --- for MS-Windows 8.3 names in the form "c:\DOCUME~1"
  473. --- Use "bufexists(0)" to test for the existence of an alternate
  474. --- file name.
  475. ---
  476. --- @param buf any
  477. --- @return 0|1
  478. function vim.fn.bufexists(buf) end
  479. --- @deprecated
  480. --- Obsolete name for |bufexists()|.
  481. ---
  482. --- @param ... any
  483. --- @return 0|1
  484. function vim.fn.buffer_exists(...) end
  485. --- @deprecated
  486. --- Obsolete name for |bufname()|.
  487. ---
  488. --- @param ... any
  489. --- @return string
  490. function vim.fn.buffer_name(...) end
  491. --- @deprecated
  492. --- Obsolete name for |bufnr()|.
  493. ---
  494. --- @param ... any
  495. --- @return integer
  496. function vim.fn.buffer_number(...) end
  497. --- The result is a Number, which is |TRUE| if a buffer called
  498. --- {buf} exists and is listed (has the 'buflisted' option set).
  499. --- The {buf} argument is used like with |bufexists()|.
  500. ---
  501. --- @param buf any
  502. --- @return 0|1
  503. function vim.fn.buflisted(buf) end
  504. --- Ensure the buffer {buf} is loaded. When the buffer name
  505. --- refers to an existing file then the file is read. Otherwise
  506. --- the buffer will be empty. If the buffer was already loaded
  507. --- then there is no change. If the buffer is not related to a
  508. --- file then no file is read (e.g., when 'buftype' is "nofile").
  509. --- If there is an existing swap file for the file of the buffer,
  510. --- there will be no dialog, the buffer will be loaded anyway.
  511. --- The {buf} argument is used like with |bufexists()|.
  512. ---
  513. --- @param buf any
  514. function vim.fn.bufload(buf) end
  515. --- The result is a Number, which is |TRUE| if a buffer called
  516. --- {buf} exists and is loaded (shown in a window or hidden).
  517. --- The {buf} argument is used like with |bufexists()|.
  518. ---
  519. --- @param buf any
  520. --- @return 0|1
  521. function vim.fn.bufloaded(buf) end
  522. --- The result is the name of a buffer. Mostly as it is displayed
  523. --- by the `:ls` command, but not using special names such as
  524. --- "[No Name]".
  525. --- If {buf} is omitted the current buffer is used.
  526. --- If {buf} is a Number, that buffer number's name is given.
  527. --- Number zero is the alternate buffer for the current window.
  528. --- If {buf} is a String, it is used as a |file-pattern| to match
  529. --- with the buffer names. This is always done like 'magic' is
  530. --- set and 'cpoptions' is empty. When there is more than one
  531. --- match an empty string is returned.
  532. --- "" or "%" can be used for the current buffer, "#" for the
  533. --- alternate buffer.
  534. --- A full match is preferred, otherwise a match at the start, end
  535. --- or middle of the buffer name is accepted. If you only want a
  536. --- full match then put "^" at the start and "$" at the end of the
  537. --- pattern.
  538. --- Listed buffers are found first. If there is a single match
  539. --- with a listed buffer, that one is returned. Next unlisted
  540. --- buffers are searched for.
  541. --- If the {buf} is a String, but you want to use it as a buffer
  542. --- number, force it to be a Number by adding zero to it: >vim
  543. --- echo bufname("3" + 0)
  544. --- <If the buffer doesn't exist, or doesn't have a name, an empty
  545. --- string is returned. >vim
  546. --- echo bufname("#") " alternate buffer name
  547. --- echo bufname(3) " name of buffer 3
  548. --- echo bufname("%") " name of current buffer
  549. --- echo bufname("file2") " name of buffer where "file2" matches.
  550. --- <
  551. ---
  552. --- @param buf? integer|string
  553. --- @return string
  554. function vim.fn.bufname(buf) end
  555. --- The result is the number of a buffer, as it is displayed by
  556. --- the `:ls` command. For the use of {buf}, see |bufname()|
  557. --- above.
  558. --- If the buffer doesn't exist, -1 is returned. Or, if the
  559. --- {create} argument is present and TRUE, a new, unlisted,
  560. --- buffer is created and its number is returned.
  561. --- bufnr("$") is the last buffer: >vim
  562. --- let last_buffer = bufnr("$")
  563. --- <The result is a Number, which is the highest buffer number
  564. --- of existing buffers. Note that not all buffers with a smaller
  565. --- number necessarily exist, because ":bwipeout" may have removed
  566. --- them. Use bufexists() to test for the existence of a buffer.
  567. ---
  568. --- @param buf? integer|string
  569. --- @param create? any
  570. --- @return integer
  571. function vim.fn.bufnr(buf, create) end
  572. --- The result is a Number, which is the |window-ID| of the first
  573. --- window associated with buffer {buf}. For the use of {buf},
  574. --- see |bufname()| above. If buffer {buf} doesn't exist or
  575. --- there is no such window, -1 is returned. Example: >vim
  576. ---
  577. --- echo "A window containing buffer 1 is " .. (bufwinid(1))
  578. --- <
  579. --- Only deals with the current tab page. See |win_findbuf()| for
  580. --- finding more.
  581. ---
  582. --- @param buf any
  583. --- @return integer
  584. function vim.fn.bufwinid(buf) end
  585. --- Like |bufwinid()| but return the window number instead of the
  586. --- |window-ID|.
  587. --- If buffer {buf} doesn't exist or there is no such window, -1
  588. --- is returned. Example: >vim
  589. ---
  590. --- echo "A window containing buffer 1 is " .. (bufwinnr(1))
  591. ---
  592. --- <The number can be used with |CTRL-W_w| and ":wincmd w"
  593. --- |:wincmd|.
  594. ---
  595. --- @param buf any
  596. --- @return integer
  597. function vim.fn.bufwinnr(buf) end
  598. --- Return the line number that contains the character at byte
  599. --- count {byte} in the current buffer. This includes the
  600. --- end-of-line character, depending on the 'fileformat' option
  601. --- for the current buffer. The first character has byte count
  602. --- one.
  603. --- Also see |line2byte()|, |go| and |:goto|.
  604. ---
  605. --- Returns -1 if the {byte} value is invalid.
  606. ---
  607. --- @param byte any
  608. --- @return integer
  609. function vim.fn.byte2line(byte) end
  610. --- Return byte index of the {nr}th character in the String
  611. --- {expr}. Use zero for the first character, it then returns
  612. --- zero.
  613. --- If there are no multibyte characters the returned value is
  614. --- equal to {nr}.
  615. --- Composing characters are not counted separately, their byte
  616. --- length is added to the preceding base character. See
  617. --- |byteidxcomp()| below for counting composing characters
  618. --- separately.
  619. --- When {utf16} is present and TRUE, {nr} is used as the UTF-16
  620. --- index in the String {expr} instead of as the character index.
  621. --- The UTF-16 index is the index in the string when it is encoded
  622. --- with 16-bit words. If the specified UTF-16 index is in the
  623. --- middle of a character (e.g. in a 4-byte character), then the
  624. --- byte index of the first byte in the character is returned.
  625. --- Refer to |string-offset-encoding| for more information.
  626. --- Example : >vim
  627. --- echo matchstr(str, ".", byteidx(str, 3))
  628. --- <will display the fourth character. Another way to do the
  629. --- same: >vim
  630. --- let s = strpart(str, byteidx(str, 3))
  631. --- echo strpart(s, 0, byteidx(s, 1))
  632. --- <Also see |strgetchar()| and |strcharpart()|.
  633. ---
  634. --- If there are less than {nr} characters -1 is returned.
  635. --- If there are exactly {nr} characters the length of the string
  636. --- in bytes is returned.
  637. --- See |charidx()| and |utf16idx()| for getting the character and
  638. --- UTF-16 index respectively from the byte index.
  639. --- Examples: >vim
  640. --- echo byteidx('a😊😊', 2) " returns 5
  641. --- echo byteidx('a😊😊', 2, 1) " returns 1
  642. --- echo byteidx('a😊😊', 3, 1) " returns 5
  643. --- <
  644. ---
  645. --- @param expr any
  646. --- @param nr integer
  647. --- @param utf16? any
  648. --- @return integer
  649. function vim.fn.byteidx(expr, nr, utf16) end
  650. --- Like byteidx(), except that a composing character is counted
  651. --- as a separate character. Example: >vim
  652. --- let s = 'e' .. nr2char(0x301)
  653. --- echo byteidx(s, 1)
  654. --- echo byteidxcomp(s, 1)
  655. --- echo byteidxcomp(s, 2)
  656. --- <The first and third echo result in 3 ('e' plus composing
  657. --- character is 3 bytes), the second echo results in 1 ('e' is
  658. --- one byte).
  659. ---
  660. --- @param expr any
  661. --- @param nr integer
  662. --- @param utf16? any
  663. --- @return integer
  664. function vim.fn.byteidxcomp(expr, nr, utf16) end
  665. --- Call function {func} with the items in |List| {arglist} as
  666. --- arguments.
  667. --- {func} can either be a |Funcref| or the name of a function.
  668. --- a:firstline and a:lastline are set to the cursor line.
  669. --- Returns the return value of the called function.
  670. --- {dict} is for functions with the "dict" attribute. It will be
  671. --- used to set the local variable "self". |Dictionary-function|
  672. ---
  673. --- @param func any
  674. --- @param arglist any
  675. --- @param dict? any
  676. --- @return any
  677. function vim.fn.call(func, arglist, dict) end
  678. --- Return the smallest integral value greater than or equal to
  679. --- {expr} as a |Float| (round up).
  680. --- {expr} must evaluate to a |Float| or a |Number|.
  681. --- Examples: >vim
  682. --- echo ceil(1.456)
  683. --- < 2.0 >vim
  684. --- echo ceil(-5.456)
  685. --- < -5.0 >vim
  686. --- echo ceil(4.0)
  687. --- < 4.0
  688. ---
  689. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  690. ---
  691. --- @param expr number
  692. --- @return number
  693. function vim.fn.ceil(expr) end
  694. --- Close a channel or a specific stream associated with it.
  695. --- For a job, {stream} can be one of "stdin", "stdout",
  696. --- "stderr" or "rpc" (closes stdin/stdout for a job started
  697. --- with `"rpc":v:true`) If {stream} is omitted, all streams
  698. --- are closed. If the channel is a pty, this will then close the
  699. --- pty master, sending SIGHUP to the job process.
  700. --- For a socket, there is only one stream, and {stream} should be
  701. --- omitted.
  702. ---
  703. --- @param id integer
  704. --- @param stream? string
  705. --- @return 0|1
  706. function vim.fn.chanclose(id, stream) end
  707. --- Return the number of the most recent change. This is the same
  708. --- number as what is displayed with |:undolist| and can be used
  709. --- with the |:undo| command.
  710. --- When a change was made it is the number of that change. After
  711. --- redo it is the number of the redone change. After undo it is
  712. --- one less than the number of the undone change.
  713. --- Returns 0 if the undo list is empty.
  714. ---
  715. --- @return integer
  716. function vim.fn.changenr() end
  717. --- Send data to channel {id}. For a job, it writes it to the
  718. --- stdin of the process. For the stdio channel |channel-stdio|,
  719. --- it writes to Nvim's stdout. Returns the number of bytes
  720. --- written if the write succeeded, 0 otherwise.
  721. --- See |channel-bytes| for more information.
  722. ---
  723. --- {data} may be a string, string convertible, |Blob|, or a list.
  724. --- If {data} is a list, the items will be joined by newlines; any
  725. --- newlines in an item will be sent as NUL. To send a final
  726. --- newline, include a final empty string. Example: >vim
  727. --- call chansend(id, ["abc", "123\n456", ""])
  728. --- <will send "abc<NL>123<NUL>456<NL>".
  729. ---
  730. --- chansend() writes raw data, not RPC messages. If the channel
  731. --- was created with `"rpc":v:true` then the channel expects RPC
  732. --- messages, use |rpcnotify()| and |rpcrequest()| instead.
  733. ---
  734. --- @param id number
  735. --- @param data string|string[]
  736. --- @return 0|1
  737. function vim.fn.chansend(id, data) end
  738. --- Return Number value of the first char in {string}.
  739. --- Examples: >vim
  740. --- echo char2nr(" ") " returns 32
  741. --- echo char2nr("ABC") " returns 65
  742. --- echo char2nr("á") " returns 225
  743. --- echo char2nr("á"[0]) " returns 195
  744. --- echo char2nr("\<M-x>") " returns 128
  745. --- <Non-ASCII characters are always treated as UTF-8 characters.
  746. --- {utf8} is ignored, it exists only for backwards-compatibility.
  747. --- A combining character is a separate character.
  748. --- |nr2char()| does the opposite.
  749. ---
  750. --- Returns 0 if {string} is not a |String|.
  751. ---
  752. --- @param string string
  753. --- @param utf8? any
  754. --- @return 0|1
  755. function vim.fn.char2nr(string, utf8) end
  756. --- Return the character class of the first character in {string}.
  757. --- The character class is one of:
  758. --- 0 blank
  759. --- 1 punctuation
  760. --- 2 word character (depends on 'iskeyword')
  761. --- 3 emoji
  762. --- other specific Unicode class
  763. --- The class is used in patterns and word motions.
  764. --- Returns 0 if {string} is not a |String|.
  765. ---
  766. --- @param string string
  767. --- @return 0|1|2|3|'other'
  768. function vim.fn.charclass(string) end
  769. --- Same as |col()| but returns the character index of the column
  770. --- position given with {expr} instead of the byte position.
  771. ---
  772. --- Example:
  773. --- With the cursor on '세' in line 5 with text "여보세요": >vim
  774. --- echo charcol('.') " returns 3
  775. --- echo col('.') " returns 7
  776. --- <
  777. ---
  778. --- @param expr string|any[]
  779. --- @param winid? integer
  780. --- @return integer
  781. function vim.fn.charcol(expr, winid) end
  782. --- Return the character index of the byte at {idx} in {string}.
  783. --- The index of the first character is zero.
  784. --- If there are no multibyte characters the returned value is
  785. --- equal to {idx}.
  786. ---
  787. --- When {countcc} is omitted or |FALSE|, then composing characters
  788. --- are not counted separately, their byte length is added to the
  789. --- preceding base character.
  790. --- When {countcc} is |TRUE|, then composing characters are
  791. --- counted as separate characters.
  792. ---
  793. --- When {utf16} is present and TRUE, {idx} is used as the UTF-16
  794. --- index in the String {expr} instead of as the byte index.
  795. ---
  796. --- Returns -1 if the arguments are invalid or if there are less
  797. --- than {idx} bytes. If there are exactly {idx} bytes the length
  798. --- of the string in characters is returned.
  799. ---
  800. --- An error is given and -1 is returned if the first argument is
  801. --- not a string, the second argument is not a number or when the
  802. --- third argument is present and is not zero or one.
  803. ---
  804. --- See |byteidx()| and |byteidxcomp()| for getting the byte index
  805. --- from the character index and |utf16idx()| for getting the
  806. --- UTF-16 index from the character index.
  807. --- Refer to |string-offset-encoding| for more information.
  808. --- Examples: >vim
  809. --- echo charidx('áb́ć', 3) " returns 1
  810. --- echo charidx('áb́ć', 6, 1) " returns 4
  811. --- echo charidx('áb́ć', 16) " returns -1
  812. --- echo charidx('a😊😊', 4, 0, 1) " returns 2
  813. --- <
  814. ---
  815. --- @param string string
  816. --- @param idx integer
  817. --- @param countcc? boolean
  818. --- @param utf16? boolean
  819. --- @return integer
  820. function vim.fn.charidx(string, idx, countcc, utf16) end
  821. --- Change the current working directory to {dir}. The scope of
  822. --- the directory change depends on the directory of the current
  823. --- window:
  824. --- - If the current window has a window-local directory
  825. --- (|:lcd|), then changes the window local directory.
  826. --- - Otherwise, if the current tabpage has a local
  827. --- directory (|:tcd|) then changes the tabpage local
  828. --- directory.
  829. --- - Otherwise, changes the global directory.
  830. --- {dir} must be a String.
  831. --- If successful, returns the previous working directory. Pass
  832. --- this to another chdir() to restore the directory.
  833. --- On failure, returns an empty string.
  834. ---
  835. --- Example: >vim
  836. --- let save_dir = chdir(newdir)
  837. --- if save_dir != ""
  838. --- " ... do some work
  839. --- call chdir(save_dir)
  840. --- endif
  841. --- <
  842. ---
  843. --- @param dir string
  844. --- @return string
  845. function vim.fn.chdir(dir) end
  846. --- Get the amount of indent for line {lnum} according the
  847. --- |C-indenting| rules, as with 'cindent'.
  848. --- The indent is counted in spaces, the value of 'tabstop' is
  849. --- relevant. {lnum} is used just like in |getline()|.
  850. --- When {lnum} is invalid -1 is returned.
  851. ---
  852. --- To get or set indent of lines in a string, see |vim.text.indent()|.
  853. ---
  854. --- @param lnum integer
  855. --- @return integer
  856. function vim.fn.cindent(lnum) end
  857. --- Clears all matches previously defined for the current window
  858. --- by |matchadd()| and the |:match| commands.
  859. --- If {win} is specified, use the window with this number or
  860. --- window ID instead of the current window.
  861. ---
  862. --- @param win? integer
  863. function vim.fn.clearmatches(win) end
  864. --- The result is a Number, which is the byte index of the column
  865. --- position given with {expr}.
  866. --- For accepted positions see |getpos()|.
  867. --- When {expr} is "$", it means the end of the cursor line, so
  868. --- the result is the number of bytes in the cursor line plus one.
  869. --- Additionally {expr} can be [lnum, col]: a |List| with the line
  870. --- and column number. Most useful when the column is "$", to get
  871. --- the last column of a specific line. When "lnum" or "col" is
  872. --- out of range then col() returns zero.
  873. ---
  874. --- With the optional {winid} argument the values are obtained for
  875. --- that window instead of the current window.
  876. ---
  877. --- To get the line number use |line()|. To get both use
  878. --- |getpos()|.
  879. ---
  880. --- For the screen column position use |virtcol()|. For the
  881. --- character position use |charcol()|.
  882. ---
  883. --- Note that only marks in the current file can be used.
  884. ---
  885. --- Examples: >vim
  886. --- echo col(".") " column of cursor
  887. --- echo col("$") " length of cursor line plus one
  888. --- echo col("'t") " column of mark t
  889. --- echo col("'" .. markname) " column of mark markname
  890. --- <
  891. --- The first column is 1. Returns 0 if {expr} is invalid or when
  892. --- the window with ID {winid} is not found.
  893. --- For an uppercase mark the column may actually be in another
  894. --- buffer.
  895. --- For the cursor position, when 'virtualedit' is active, the
  896. --- column is one higher if the cursor is after the end of the
  897. --- line. Also, when using a <Cmd> mapping the cursor isn't
  898. --- moved, this can be used to obtain the column in Insert mode: >vim
  899. --- imap <F2> <Cmd>echo col(".").."\n"<CR>
  900. --- <
  901. ---
  902. --- @param expr string|any[]
  903. --- @param winid? integer
  904. --- @return integer
  905. function vim.fn.col(expr, winid) end
  906. --- Set the matches for Insert mode completion.
  907. --- Can only be used in Insert mode. You need to use a mapping
  908. --- with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O
  909. --- or with an expression mapping.
  910. --- {startcol} is the byte offset in the line where the completed
  911. --- text start. The text up to the cursor is the original text
  912. --- that will be replaced by the matches. Use col('.') for an
  913. --- empty string. "col('.') - 1" will replace one character by a
  914. --- match.
  915. --- {matches} must be a |List|. Each |List| item is one match.
  916. --- See |complete-items| for the kind of items that are possible.
  917. --- "longest" in 'completeopt' is ignored.
  918. --- Note that the after calling this function you need to avoid
  919. --- inserting anything that would cause completion to stop.
  920. --- The match can be selected with CTRL-N and CTRL-P as usual with
  921. --- Insert mode completion. The popup menu will appear if
  922. --- specified, see |ins-completion-menu|.
  923. --- Example: >vim
  924. --- inoremap <F5> <C-R>=ListMonths()<CR>
  925. ---
  926. --- func ListMonths()
  927. --- call complete(col('.'), ['January', 'February', 'March',
  928. --- \ 'April', 'May', 'June', 'July', 'August', 'September',
  929. --- \ 'October', 'November', 'December'])
  930. --- return ''
  931. --- endfunc
  932. --- <This isn't very useful, but it shows how it works. Note that
  933. --- an empty string is returned to avoid a zero being inserted.
  934. ---
  935. --- @param startcol integer
  936. --- @param matches any[]
  937. function vim.fn.complete(startcol, matches) end
  938. --- Add {expr} to the list of matches. Only to be used by the
  939. --- function specified with the 'completefunc' option.
  940. --- Returns 0 for failure (empty string or out of memory),
  941. --- 1 when the match was added, 2 when the match was already in
  942. --- the list.
  943. --- See |complete-functions| for an explanation of {expr}. It is
  944. --- the same as one item in the list that 'omnifunc' would return.
  945. ---
  946. --- @param expr any
  947. --- @return 0|1|2
  948. function vim.fn.complete_add(expr) end
  949. --- Check for a key typed while looking for completion matches.
  950. --- This is to be used when looking for matches takes some time.
  951. --- Returns |TRUE| when searching for matches is to be aborted,
  952. --- zero otherwise.
  953. --- Only to be used by the function specified with the
  954. --- 'completefunc' option.
  955. ---
  956. --- @return 0|1
  957. function vim.fn.complete_check() end
  958. --- Returns a |Dictionary| with information about Insert mode
  959. --- completion. See |ins-completion|.
  960. --- The items are:
  961. --- mode Current completion mode name string.
  962. --- See |complete_info_mode| for the values.
  963. --- pum_visible |TRUE| if popup menu is visible.
  964. --- See |pumvisible()|.
  965. --- items List of all completion candidates. Each item
  966. --- is a dictionary containing the entries "word",
  967. --- "abbr", "menu", "kind", "info" and "user_data".
  968. --- See |complete-items|.
  969. --- matches Same as "items", but only returns items that
  970. --- are matching current query. If both "matches"
  971. --- and "items" are in "what", the returned list
  972. --- will still be named "items", but each item
  973. --- will have an additional "match" field.
  974. --- selected Selected item index. First index is zero.
  975. --- Index is -1 if no item is selected (showing
  976. --- typed text only, or the last completion after
  977. --- no item is selected when using the <Up> or
  978. --- <Down> keys)
  979. --- completed Return a dictionary containing the entries of
  980. --- the currently selected index item.
  981. --- preview_winid Info floating preview window id.
  982. --- preview_bufnr Info floating preview buffer id.
  983. ---
  984. --- *complete_info_mode*
  985. --- mode values are:
  986. --- "" Not in completion mode
  987. --- "keyword" Keyword completion |i_CTRL-X_CTRL-N|
  988. --- "ctrl_x" Just pressed CTRL-X |i_CTRL-X|
  989. --- "scroll" Scrolling with |i_CTRL-X_CTRL-E| or
  990. --- |i_CTRL-X_CTRL-Y|
  991. --- "whole_line" Whole lines |i_CTRL-X_CTRL-L|
  992. --- "files" File names |i_CTRL-X_CTRL-F|
  993. --- "tags" Tags |i_CTRL-X_CTRL-]|
  994. --- "path_defines" Definition completion |i_CTRL-X_CTRL-D|
  995. --- "path_patterns" Include completion |i_CTRL-X_CTRL-I|
  996. --- "dictionary" Dictionary |i_CTRL-X_CTRL-K|
  997. --- "thesaurus" Thesaurus |i_CTRL-X_CTRL-T|
  998. --- "cmdline" Vim Command line |i_CTRL-X_CTRL-V|
  999. --- "function" User defined completion |i_CTRL-X_CTRL-U|
  1000. --- "omni" Omni completion |i_CTRL-X_CTRL-O|
  1001. --- "spell" Spelling suggestions |i_CTRL-X_s|
  1002. --- "eval" |complete()| completion
  1003. --- "unknown" Other internal modes
  1004. ---
  1005. --- If the optional {what} list argument is supplied, then only
  1006. --- the items listed in {what} are returned. Unsupported items in
  1007. --- {what} are silently ignored.
  1008. ---
  1009. --- To get the position and size of the popup menu, see
  1010. --- |pum_getpos()|. It's also available in |v:event| during the
  1011. --- |CompleteChanged| event.
  1012. ---
  1013. --- Returns an empty |Dictionary| on error.
  1014. ---
  1015. --- Examples: >vim
  1016. --- " Get all items
  1017. --- call complete_info()
  1018. --- " Get only 'mode'
  1019. --- call complete_info(['mode'])
  1020. --- " Get only 'mode' and 'pum_visible'
  1021. --- call complete_info(['mode', 'pum_visible'])
  1022. --- <
  1023. ---
  1024. --- @param what? any[]
  1025. --- @return table
  1026. function vim.fn.complete_info(what) end
  1027. --- confirm() offers the user a dialog, from which a choice can be
  1028. --- made. It returns the number of the choice. For the first
  1029. --- choice this is 1.
  1030. ---
  1031. --- {msg} is displayed in a dialog with {choices} as the
  1032. --- alternatives. When {choices} is missing or empty, "&OK" is
  1033. --- used (and translated).
  1034. --- {msg} is a String, use '\n' to include a newline. Only on
  1035. --- some systems the string is wrapped when it doesn't fit.
  1036. ---
  1037. --- {choices} is a String, with the individual choices separated
  1038. --- by '\n', e.g. >vim
  1039. --- confirm("Save changes?", "&Yes\n&No\n&Cancel")
  1040. --- <The letter after the '&' is the shortcut key for that choice.
  1041. --- Thus you can type 'c' to select "Cancel". The shortcut does
  1042. --- not need to be the first letter: >vim
  1043. --- confirm("file has been modified", "&Save\nSave &All")
  1044. --- <For the console, the first letter of each choice is used as
  1045. --- the default shortcut key. Case is ignored.
  1046. ---
  1047. --- The optional {type} String argument gives the type of dialog.
  1048. --- It can be one of these values: "Error", "Question", "Info",
  1049. --- "Warning" or "Generic". Only the first character is relevant.
  1050. --- When {type} is omitted, "Generic" is used.
  1051. ---
  1052. --- The optional {type} argument gives the type of dialog. This
  1053. --- is only used for the icon of the Win32 GUI. It can be one of
  1054. --- these values: "Error", "Question", "Info", "Warning" or
  1055. --- "Generic". Only the first character is relevant.
  1056. --- When {type} is omitted, "Generic" is used.
  1057. ---
  1058. --- If the user aborts the dialog by pressing <Esc>, CTRL-C,
  1059. --- or another valid interrupt key, confirm() returns 0.
  1060. ---
  1061. --- An example: >vim
  1062. --- let choice = confirm("What do you want?",
  1063. --- \ "&Apples\n&Oranges\n&Bananas", 2)
  1064. --- if choice == 0
  1065. --- echo "make up your mind!"
  1066. --- elseif choice == 3
  1067. --- echo "tasteful"
  1068. --- else
  1069. --- echo "I prefer bananas myself."
  1070. --- endif
  1071. --- <In a GUI dialog, buttons are used. The layout of the buttons
  1072. --- depends on the 'v' flag in 'guioptions'. If it is included,
  1073. --- the buttons are always put vertically. Otherwise, confirm()
  1074. --- tries to put the buttons in one horizontal line. If they
  1075. --- don't fit, a vertical layout is used anyway. For some systems
  1076. --- the horizontal layout is always used.
  1077. ---
  1078. --- @param msg string
  1079. --- @param choices? string
  1080. --- @param default? integer
  1081. --- @param type? string
  1082. --- @return integer
  1083. function vim.fn.confirm(msg, choices, default, type) end
  1084. --- Make a copy of {expr}. For Numbers and Strings this isn't
  1085. --- different from using {expr} directly.
  1086. --- When {expr} is a |List| a shallow copy is created. This means
  1087. --- that the original |List| can be changed without changing the
  1088. --- copy, and vice versa. But the items are identical, thus
  1089. --- changing an item changes the contents of both |Lists|.
  1090. --- A |Dictionary| is copied in a similar way as a |List|.
  1091. --- Also see |deepcopy()|.
  1092. ---
  1093. --- @generic T
  1094. --- @param expr T
  1095. --- @return T
  1096. function vim.fn.copy(expr) end
  1097. --- Return the cosine of {expr}, measured in radians, as a |Float|.
  1098. --- {expr} must evaluate to a |Float| or a |Number|.
  1099. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1100. --- Examples: >vim
  1101. --- echo cos(100)
  1102. --- < 0.862319 >vim
  1103. --- echo cos(-4.01)
  1104. --- < -0.646043
  1105. ---
  1106. --- @param expr number
  1107. --- @return number
  1108. function vim.fn.cos(expr) end
  1109. --- Return the hyperbolic cosine of {expr} as a |Float| in the range
  1110. --- [1, inf].
  1111. --- {expr} must evaluate to a |Float| or a |Number|.
  1112. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1113. --- Examples: >vim
  1114. --- echo cosh(0.5)
  1115. --- < 1.127626 >vim
  1116. --- echo cosh(-0.5)
  1117. --- < -1.127626
  1118. ---
  1119. --- @param expr number
  1120. --- @return number
  1121. function vim.fn.cosh(expr) end
  1122. --- Return the number of times an item with value {expr} appears
  1123. --- in |String|, |List| or |Dictionary| {comp}.
  1124. ---
  1125. --- If {start} is given then start with the item with this index.
  1126. --- {start} can only be used with a |List|.
  1127. ---
  1128. --- When {ic} is given and it's |TRUE| then case is ignored.
  1129. ---
  1130. --- When {comp} is a string then the number of not overlapping
  1131. --- occurrences of {expr} is returned. Zero is returned when
  1132. --- {expr} is an empty string.
  1133. ---
  1134. --- @param comp string|table|any[]
  1135. --- @param expr any
  1136. --- @param ic? boolean
  1137. --- @param start? integer
  1138. --- @return integer
  1139. function vim.fn.count(comp, expr, ic, start) end
  1140. --- Returns a |Dictionary| representing the |context| at {index}
  1141. --- from the top of the |context-stack| (see |context-dict|).
  1142. --- If {index} is not given, it is assumed to be 0 (i.e.: top).
  1143. ---
  1144. --- @param index? integer
  1145. --- @return table
  1146. function vim.fn.ctxget(index) end
  1147. --- Pops and restores the |context| at the top of the
  1148. --- |context-stack|.
  1149. ---
  1150. --- @return any
  1151. function vim.fn.ctxpop() end
  1152. --- Pushes the current editor state (|context|) on the
  1153. --- |context-stack|.
  1154. --- If {types} is given and is a |List| of |String|s, it specifies
  1155. --- which |context-types| to include in the pushed context.
  1156. --- Otherwise, all context types are included.
  1157. ---
  1158. --- @param types? string[]
  1159. --- @return any
  1160. function vim.fn.ctxpush(types) end
  1161. --- Sets the |context| at {index} from the top of the
  1162. --- |context-stack| to that represented by {context}.
  1163. --- {context} is a Dictionary with context data (|context-dict|).
  1164. --- If {index} is not given, it is assumed to be 0 (i.e.: top).
  1165. ---
  1166. --- @param context table
  1167. --- @param index? integer
  1168. --- @return integer
  1169. function vim.fn.ctxset(context, index) end
  1170. --- Returns the size of the |context-stack|.
  1171. ---
  1172. --- @return any
  1173. function vim.fn.ctxsize() end
  1174. --- @param lnum integer
  1175. --- @param col? integer
  1176. --- @param off? integer
  1177. --- @return any
  1178. function vim.fn.cursor(lnum, col, off) end
  1179. --- Positions the cursor at the column (byte count) {col} in the
  1180. --- line {lnum}. The first column is one.
  1181. ---
  1182. --- When there is one argument {list} this is used as a |List|
  1183. --- with two, three or four item:
  1184. --- [{lnum}, {col}]
  1185. --- [{lnum}, {col}, {off}]
  1186. --- [{lnum}, {col}, {off}, {curswant}]
  1187. --- This is like the return value of |getpos()| or |getcurpos()|,
  1188. --- but without the first item.
  1189. ---
  1190. --- To position the cursor using {col} as the character count, use
  1191. --- |setcursorcharpos()|.
  1192. ---
  1193. --- Does not change the jumplist.
  1194. --- {lnum} is used like with |getline()|, except that if {lnum} is
  1195. --- zero, the cursor will stay in the current line.
  1196. --- If {lnum} is greater than the number of lines in the buffer,
  1197. --- the cursor will be positioned at the last line in the buffer.
  1198. --- If {col} is greater than the number of bytes in the line,
  1199. --- the cursor will be positioned at the last character in the
  1200. --- line.
  1201. --- If {col} is zero, the cursor will stay in the current column.
  1202. --- If {curswant} is given it is used to set the preferred column
  1203. --- for vertical movement. Otherwise {col} is used.
  1204. ---
  1205. --- When 'virtualedit' is used {off} specifies the offset in
  1206. --- screen columns from the start of the character. E.g., a
  1207. --- position within a <Tab> or after the last character.
  1208. --- Returns 0 when the position could be set, -1 otherwise.
  1209. ---
  1210. --- @param list integer[]
  1211. --- @return any
  1212. function vim.fn.cursor(list) end
  1213. --- Specifically used to interrupt a program being debugged. It
  1214. --- will cause process {pid} to get a SIGTRAP. Behavior for other
  1215. --- processes is undefined. See |terminal-debug|.
  1216. --- (Sends a SIGINT to a process {pid} other than MS-Windows)
  1217. ---
  1218. --- Returns |TRUE| if successfully interrupted the program.
  1219. --- Otherwise returns |FALSE|.
  1220. ---
  1221. --- @param pid integer
  1222. --- @return any
  1223. function vim.fn.debugbreak(pid) end
  1224. --- Make a copy of {expr}. For Numbers and Strings this isn't
  1225. --- different from using {expr} directly.
  1226. --- When {expr} is a |List| a full copy is created. This means
  1227. --- that the original |List| can be changed without changing the
  1228. --- copy, and vice versa. When an item is a |List|, a copy for it
  1229. --- is made, recursively. Thus changing an item in the copy does
  1230. --- not change the contents of the original |List|.
  1231. ---
  1232. --- When {noref} is omitted or zero a contained |List| or
  1233. --- |Dictionary| is only copied once. All references point to
  1234. --- this single copy. With {noref} set to 1 every occurrence of a
  1235. --- |List| or |Dictionary| results in a new copy. This also means
  1236. --- that a cyclic reference causes deepcopy() to fail.
  1237. --- *E724*
  1238. --- Nesting is possible up to 100 levels. When there is an item
  1239. --- that refers back to a higher level making a deep copy with
  1240. --- {noref} set to 1 will fail.
  1241. --- Also see |copy()|.
  1242. ---
  1243. --- @generic T
  1244. --- @param expr T
  1245. --- @param noref? boolean
  1246. --- @return T
  1247. function vim.fn.deepcopy(expr, noref) end
  1248. --- Without {flags} or with {flags} empty: Deletes the file by the
  1249. --- name {fname}.
  1250. ---
  1251. --- This also works when {fname} is a symbolic link. The symbolic
  1252. --- link itself is deleted, not what it points to.
  1253. ---
  1254. --- When {flags} is "d": Deletes the directory by the name
  1255. --- {fname}. This fails when directory {fname} is not empty.
  1256. ---
  1257. --- When {flags} is "rf": Deletes the directory by the name
  1258. --- {fname} and everything in it, recursively. BE CAREFUL!
  1259. --- Note: on MS-Windows it is not possible to delete a directory
  1260. --- that is being used.
  1261. ---
  1262. --- The result is a Number, which is 0/false if the delete
  1263. --- operation was successful and -1/true when the deletion failed
  1264. --- or partly failed.
  1265. ---
  1266. --- @param fname string
  1267. --- @param flags? string
  1268. --- @return integer
  1269. function vim.fn.delete(fname, flags) end
  1270. --- Delete lines {first} to {last} (inclusive) from buffer {buf}.
  1271. --- If {last} is omitted then delete line {first} only.
  1272. --- On success 0 is returned, on failure 1 is returned.
  1273. ---
  1274. --- This function works only for loaded buffers. First call
  1275. --- |bufload()| if needed.
  1276. ---
  1277. --- For the use of {buf}, see |bufname()| above.
  1278. ---
  1279. --- {first} and {last} are used like with |getline()|. Note that
  1280. --- when using |line()| this refers to the current buffer. Use "$"
  1281. --- to refer to the last line in buffer {buf}.
  1282. ---
  1283. --- @param buf integer|string
  1284. --- @param first integer|string
  1285. --- @param last? integer|string
  1286. --- @return any
  1287. function vim.fn.deletebufline(buf, first, last) end
  1288. --- Adds a watcher to a dictionary. A dictionary watcher is
  1289. --- identified by three components:
  1290. ---
  1291. --- - A dictionary({dict});
  1292. --- - A key pattern({pattern}).
  1293. --- - A function({callback}).
  1294. ---
  1295. --- After this is called, every change on {dict} and on keys
  1296. --- matching {pattern} will result in {callback} being invoked.
  1297. ---
  1298. --- For example, to watch all global variables: >vim
  1299. --- silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
  1300. --- function! OnDictChanged(d,k,z)
  1301. --- echomsg string(a:k) string(a:z)
  1302. --- endfunction
  1303. --- call dictwatcheradd(g:, '*', 'OnDictChanged')
  1304. --- <
  1305. --- For now {pattern} only accepts very simple patterns that can
  1306. --- contain a "*" at the end of the string, in which case it will
  1307. --- match every key that begins with the substring before the "*".
  1308. --- That means if "*" is not the last character of {pattern}, only
  1309. --- keys that are exactly equal as {pattern} will be matched.
  1310. ---
  1311. --- The {callback} receives three arguments:
  1312. ---
  1313. --- - The dictionary being watched.
  1314. --- - The key which changed.
  1315. --- - A dictionary containing the new and old values for the key.
  1316. ---
  1317. --- The type of change can be determined by examining the keys
  1318. --- present on the third argument:
  1319. ---
  1320. --- - If contains both `old` and `new`, the key was updated.
  1321. --- - If it contains only `new`, the key was added.
  1322. --- - If it contains only `old`, the key was deleted.
  1323. ---
  1324. --- This function can be used by plugins to implement options with
  1325. --- validation and parsing logic.
  1326. ---
  1327. --- @param dict table
  1328. --- @param pattern string
  1329. --- @param callback function
  1330. --- @return any
  1331. function vim.fn.dictwatcheradd(dict, pattern, callback) end
  1332. --- Removes a watcher added with |dictwatcheradd()|. All three
  1333. --- arguments must match the ones passed to |dictwatcheradd()| in
  1334. --- order for the watcher to be successfully deleted.
  1335. ---
  1336. --- @param dict any
  1337. --- @param pattern string
  1338. --- @param callback function
  1339. --- @return any
  1340. function vim.fn.dictwatcherdel(dict, pattern, callback) end
  1341. --- Returns |TRUE| when autocommands are being executed and the
  1342. --- FileType event has been triggered at least once. Can be used
  1343. --- to avoid triggering the FileType event again in the scripts
  1344. --- that detect the file type. |FileType|
  1345. --- Returns |FALSE| when `:setf FALLBACK` was used.
  1346. --- When editing another file, the counter is reset, thus this
  1347. --- really checks if the FileType event has been triggered for the
  1348. --- current buffer. This allows an autocommand that starts
  1349. --- editing another buffer to set 'filetype' and load a syntax
  1350. --- file.
  1351. ---
  1352. --- @return integer
  1353. function vim.fn.did_filetype() end
  1354. --- Returns the number of filler lines above line {lnum}.
  1355. --- These are the lines that were inserted at this point in
  1356. --- another diff'ed window. These filler lines are shown in the
  1357. --- display but don't exist in the buffer.
  1358. --- {lnum} is used like with |getline()|. Thus "." is the current
  1359. --- line, "'m" mark m, etc.
  1360. --- Returns 0 if the current window is not in diff mode.
  1361. ---
  1362. --- @param lnum integer
  1363. --- @return integer
  1364. function vim.fn.diff_filler(lnum) end
  1365. --- Returns the highlight ID for diff mode at line {lnum} column
  1366. --- {col} (byte index). When the current line does not have a
  1367. --- diff change zero is returned.
  1368. --- {lnum} is used like with |getline()|. Thus "." is the current
  1369. --- line, "'m" mark m, etc.
  1370. --- {col} is 1 for the leftmost column, {lnum} is 1 for the first
  1371. --- line.
  1372. --- The highlight ID can be used with |synIDattr()| to obtain
  1373. --- syntax information about the highlighting.
  1374. ---
  1375. --- @param lnum integer
  1376. --- @param col integer
  1377. --- @return any
  1378. function vim.fn.diff_hlID(lnum, col) end
  1379. --- Return the digraph of {chars}. This should be a string with
  1380. --- exactly two characters. If {chars} are not just two
  1381. --- characters, or the digraph of {chars} does not exist, an error
  1382. --- is given and an empty string is returned.
  1383. ---
  1384. --- Also see |digraph_getlist()|.
  1385. ---
  1386. --- Examples: >vim
  1387. --- " Get a built-in digraph
  1388. --- echo digraph_get('00') " Returns '∞'
  1389. ---
  1390. --- " Get a user-defined digraph
  1391. --- call digraph_set('aa', 'あ')
  1392. --- echo digraph_get('aa') " Returns 'あ'
  1393. --- <
  1394. ---
  1395. --- @param chars string
  1396. --- @return string
  1397. function vim.fn.digraph_get(chars) end
  1398. --- Return a list of digraphs. If the {listall} argument is given
  1399. --- and it is TRUE, return all digraphs, including the default
  1400. --- digraphs. Otherwise, return only user-defined digraphs.
  1401. ---
  1402. --- Also see |digraph_get()|.
  1403. ---
  1404. --- Examples: >vim
  1405. --- " Get user-defined digraphs
  1406. --- echo digraph_getlist()
  1407. ---
  1408. --- " Get all the digraphs, including default digraphs
  1409. --- echo digraph_getlist(1)
  1410. --- <
  1411. ---
  1412. --- @param listall? boolean
  1413. --- @return string[][]
  1414. function vim.fn.digraph_getlist(listall) end
  1415. --- Add digraph {chars} to the list. {chars} must be a string
  1416. --- with two characters. {digraph} is a string with one UTF-8
  1417. --- encoded character. *E1215*
  1418. --- Be careful, composing characters are NOT ignored. This
  1419. --- function is similar to |:digraphs| command, but useful to add
  1420. --- digraphs start with a white space.
  1421. ---
  1422. --- The function result is v:true if |digraph| is registered. If
  1423. --- this fails an error message is given and v:false is returned.
  1424. ---
  1425. --- If you want to define multiple digraphs at once, you can use
  1426. --- |digraph_setlist()|.
  1427. ---
  1428. --- Example: >vim
  1429. --- call digraph_set(' ', 'あ')
  1430. --- <
  1431. ---
  1432. --- @param chars string
  1433. --- @param digraph string
  1434. --- @return any
  1435. function vim.fn.digraph_set(chars, digraph) end
  1436. --- Similar to |digraph_set()| but this function can add multiple
  1437. --- digraphs at once. {digraphlist} is a list composed of lists,
  1438. --- where each list contains two strings with {chars} and
  1439. --- {digraph} as in |digraph_set()|. *E1216*
  1440. --- Example: >vim
  1441. --- call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
  1442. --- <
  1443. --- It is similar to the following: >vim
  1444. --- for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
  1445. --- call digraph_set(chars, digraph)
  1446. --- endfor
  1447. --- <Except that the function returns after the first error,
  1448. --- following digraphs will not be added.
  1449. ---
  1450. --- @param digraphlist table<integer,string[]>
  1451. --- @return any
  1452. function vim.fn.digraph_setlist(digraphlist) end
  1453. --- Return the Number 1 if {expr} is empty, zero otherwise.
  1454. --- - A |List| or |Dictionary| is empty when it does not have any
  1455. --- items.
  1456. --- - A |String| is empty when its length is zero.
  1457. --- - A |Number| and |Float| are empty when their value is zero.
  1458. --- - |v:false| and |v:null| are empty, |v:true| is not.
  1459. --- - A |Blob| is empty when its length is zero.
  1460. ---
  1461. --- @param expr any
  1462. --- @return integer
  1463. function vim.fn.empty(expr) end
  1464. --- Return all of environment variables as dictionary. You can
  1465. --- check if an environment variable exists like this: >vim
  1466. --- echo has_key(environ(), 'HOME')
  1467. --- <Note that the variable name may be CamelCase; to ignore case
  1468. --- use this: >vim
  1469. --- echo index(keys(environ()), 'HOME', 0, 1) != -1
  1470. --- <
  1471. ---
  1472. --- @return any
  1473. function vim.fn.environ() end
  1474. --- Escape the characters in {chars} that occur in {string} with a
  1475. --- backslash. Example: >vim
  1476. --- echo escape('c:\program files\vim', ' \')
  1477. --- <results in: >
  1478. --- c:\\program\ files\\vim
  1479. --- <Also see |shellescape()| and |fnameescape()|.
  1480. ---
  1481. --- @param string string
  1482. --- @param chars string
  1483. --- @return string
  1484. function vim.fn.escape(string, chars) end
  1485. --- Evaluate {string} and return the result. Especially useful to
  1486. --- turn the result of |string()| back into the original value.
  1487. --- This works for Numbers, Floats, Strings, Blobs and composites
  1488. --- of them. Also works for |Funcref|s that refer to existing
  1489. --- functions.
  1490. ---
  1491. --- @param string string
  1492. --- @return any
  1493. function vim.fn.eval(string) end
  1494. --- Returns 1 when inside an event handler. That is that Vim got
  1495. --- interrupted while waiting for the user to type a character,
  1496. --- e.g., when dropping a file on Vim. This means interactive
  1497. --- commands cannot be used. Otherwise zero is returned.
  1498. ---
  1499. --- @return any
  1500. function vim.fn.eventhandler() end
  1501. --- This function checks if an executable with the name {expr}
  1502. --- exists. {expr} must be the name of the program without any
  1503. --- arguments.
  1504. ---
  1505. --- executable() uses the value of $PATH and/or the normal
  1506. --- searchpath for programs.
  1507. --- *PATHEXT*
  1508. --- On MS-Windows the ".exe", ".bat", etc. can optionally be
  1509. --- included. Then the extensions in $PATHEXT are tried. Thus if
  1510. --- "foo.exe" does not exist, "foo.exe.bat" can be found. If
  1511. --- $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot
  1512. --- by itself can be used in $PATHEXT to try using the name
  1513. --- without an extension. When 'shell' looks like a Unix shell,
  1514. --- then the name is also tried without adding an extension.
  1515. --- On MS-Windows it only checks if the file exists and is not a
  1516. --- directory, not if it's really executable.
  1517. --- On MS-Windows an executable in the same directory as the Vim
  1518. --- executable is always found (it's added to $PATH at |startup|).
  1519. --- *NoDefaultCurrentDirectoryInExePath*
  1520. --- On MS-Windows an executable in Vim's current working directory
  1521. --- is also normally found, but this can be disabled by setting
  1522. --- the $NoDefaultCurrentDirectoryInExePath environment variable.
  1523. ---
  1524. --- The result is a Number:
  1525. --- 1 exists
  1526. --- 0 does not exist
  1527. --- |exepath()| can be used to get the full path of an executable.
  1528. ---
  1529. --- @param expr string
  1530. --- @return 0|1
  1531. function vim.fn.executable(expr) end
  1532. --- Execute {command} and capture its output.
  1533. --- If {command} is a |String|, returns {command} output.
  1534. --- If {command} is a |List|, returns concatenated outputs.
  1535. --- Line continuations in {command} are not recognized.
  1536. --- Examples: >vim
  1537. --- echo execute('echon "foo"')
  1538. --- < foo >vim
  1539. --- echo execute(['echon "foo"', 'echon "bar"'])
  1540. --- < foobar
  1541. ---
  1542. --- The optional {silent} argument can have these values:
  1543. --- "" no `:silent` used
  1544. --- "silent" `:silent` used
  1545. --- "silent!" `:silent!` used
  1546. --- The default is "silent". Note that with "silent!", unlike
  1547. --- `:redir`, error messages are dropped.
  1548. ---
  1549. --- To get a list of lines use `split()` on the result: >vim
  1550. --- execute('args')->split("\n")
  1551. ---
  1552. --- <This function is not available in the |sandbox|.
  1553. --- Note: If nested, an outer execute() will not observe output of
  1554. --- the inner calls.
  1555. --- Note: Text attributes (highlights) are not captured.
  1556. --- To execute a command in another window than the current one
  1557. --- use `win_execute()`.
  1558. ---
  1559. --- @param command string|string[]
  1560. --- @param silent? ''|'silent'|'silent!'
  1561. --- @return string
  1562. function vim.fn.execute(command, silent) end
  1563. --- Returns the full path of {expr} if it is an executable and
  1564. --- given as a (partial or full) path or is found in $PATH.
  1565. --- Returns empty string otherwise.
  1566. --- If {expr} starts with "./" the |current-directory| is used.
  1567. ---
  1568. --- @param expr string
  1569. --- @return string
  1570. function vim.fn.exepath(expr) end
  1571. --- The result is a Number, which is |TRUE| if {expr} is
  1572. --- defined, zero otherwise.
  1573. ---
  1574. --- For checking for a supported feature use |has()|.
  1575. --- For checking if a file exists use |filereadable()|.
  1576. ---
  1577. --- The {expr} argument is a string, which contains one of these:
  1578. --- varname internal variable (see
  1579. --- dict.key |internal-variables|). Also works
  1580. --- list[i] for |curly-braces-names|, |Dictionary|
  1581. --- entries, |List| items, etc.
  1582. --- Beware that evaluating an index may
  1583. --- cause an error message for an invalid
  1584. --- expression. E.g.: >vim
  1585. --- let l = [1, 2, 3]
  1586. --- echo exists("l[5]")
  1587. --- < 0 >vim
  1588. --- echo exists("l[xx]")
  1589. --- < E121: Undefined variable: xx
  1590. --- 0
  1591. --- &option-name Vim option (only checks if it exists,
  1592. --- not if it really works)
  1593. --- +option-name Vim option that works.
  1594. --- $ENVNAME environment variable (could also be
  1595. --- done by comparing with an empty
  1596. --- string)
  1597. --- `*funcname` built-in function (see |functions|)
  1598. --- or user defined function (see
  1599. --- |user-function|). Also works for a
  1600. --- variable that is a Funcref.
  1601. --- :cmdname Ex command: built-in command, user
  1602. --- command or command modifier |:command|.
  1603. --- Returns:
  1604. --- 1 for match with start of a command
  1605. --- 2 full match with a command
  1606. --- 3 matches several user commands
  1607. --- To check for a supported command
  1608. --- always check the return value to be 2.
  1609. --- :2match The |:2match| command.
  1610. --- :3match The |:3match| command (but you
  1611. --- probably should not use it, it is
  1612. --- reserved for internal usage)
  1613. --- #event autocommand defined for this event
  1614. --- #event#pattern autocommand defined for this event and
  1615. --- pattern (the pattern is taken
  1616. --- literally and compared to the
  1617. --- autocommand patterns character by
  1618. --- character)
  1619. --- #group autocommand group exists
  1620. --- #group#event autocommand defined for this group and
  1621. --- event.
  1622. --- #group#event#pattern
  1623. --- autocommand defined for this group,
  1624. --- event and pattern.
  1625. --- ##event autocommand for this event is
  1626. --- supported.
  1627. ---
  1628. --- Examples: >vim
  1629. --- echo exists("&mouse")
  1630. --- echo exists("$HOSTNAME")
  1631. --- echo exists("*strftime")
  1632. --- echo exists("*s:MyFunc")
  1633. --- echo exists("*MyFunc")
  1634. --- echo exists("*v:lua.Func")
  1635. --- echo exists("bufcount")
  1636. --- echo exists(":Make")
  1637. --- echo exists("#CursorHold")
  1638. --- echo exists("#BufReadPre#*.gz")
  1639. --- echo exists("#filetypeindent")
  1640. --- echo exists("#filetypeindent#FileType")
  1641. --- echo exists("#filetypeindent#FileType#*")
  1642. --- echo exists("##ColorScheme")
  1643. --- <There must be no space between the symbol (&/$/*/#) and the
  1644. --- name.
  1645. --- There must be no extra characters after the name, although in
  1646. --- a few cases this is ignored. That may become stricter in the
  1647. --- future, thus don't count on it!
  1648. --- Working example: >vim
  1649. --- echo exists(":make")
  1650. --- <NOT working example: >vim
  1651. --- echo exists(":make install")
  1652. ---
  1653. --- <Note that the argument must be a string, not the name of the
  1654. --- variable itself. For example: >vim
  1655. --- echo exists(bufcount)
  1656. --- <This doesn't check for existence of the "bufcount" variable,
  1657. --- but gets the value of "bufcount", and checks if that exists.
  1658. ---
  1659. --- @param expr string
  1660. --- @return 0|1
  1661. function vim.fn.exists(expr) end
  1662. --- Return the exponential of {expr} as a |Float| in the range
  1663. --- [0, inf].
  1664. --- {expr} must evaluate to a |Float| or a |Number|.
  1665. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1666. --- Examples: >vim
  1667. --- echo exp(2)
  1668. --- < 7.389056 >vim
  1669. --- echo exp(-1)
  1670. --- < 0.367879
  1671. ---
  1672. --- @param expr number
  1673. --- @return any
  1674. function vim.fn.exp(expr) end
  1675. --- Expand wildcards and the following special keywords in
  1676. --- {string}. 'wildignorecase' applies.
  1677. ---
  1678. --- If {list} is given and it is |TRUE|, a List will be returned.
  1679. --- Otherwise the result is a String and when there are several
  1680. --- matches, they are separated by <NL> characters.
  1681. ---
  1682. --- If the expansion fails, the result is an empty string. A name
  1683. --- for a non-existing file is not included, unless {string} does
  1684. --- not start with '%', '#' or '<', see below.
  1685. ---
  1686. --- When {string} starts with '%', '#' or '<', the expansion is
  1687. --- done like for the |cmdline-special| variables with their
  1688. --- associated modifiers. Here is a short overview:
  1689. ---
  1690. --- % current file name
  1691. --- # alternate file name
  1692. --- #n alternate file name n
  1693. --- <cfile> file name under the cursor
  1694. --- <afile> autocmd file name
  1695. --- <abuf> autocmd buffer number (as a String!)
  1696. --- <amatch> autocmd matched name
  1697. --- <cexpr> C expression under the cursor
  1698. --- <sfile> sourced script file or function name
  1699. --- <slnum> sourced script line number or function
  1700. --- line number
  1701. --- <sflnum> script file line number, also when in
  1702. --- a function
  1703. --- <SID> "<SNR>123_" where "123" is the
  1704. --- current script ID |<SID>|
  1705. --- <script> sourced script file, or script file
  1706. --- where the current function was defined
  1707. --- <stack> call stack
  1708. --- <cword> word under the cursor
  1709. --- <cWORD> WORD under the cursor
  1710. --- <client> the {clientid} of the last received
  1711. --- message
  1712. --- Modifiers:
  1713. --- :p expand to full path
  1714. --- :h head (last path component removed)
  1715. --- :t tail (last path component only)
  1716. --- :r root (one extension removed)
  1717. --- :e extension only
  1718. ---
  1719. --- Example: >vim
  1720. --- let &tags = expand("%:p:h") .. "/tags"
  1721. --- <Note that when expanding a string that starts with '%', '#' or
  1722. --- '<', any following text is ignored. This does NOT work: >vim
  1723. --- let doesntwork = expand("%:h.bak")
  1724. --- <Use this: >vim
  1725. --- let doeswork = expand("%:h") .. ".bak"
  1726. --- <Also note that expanding "<cfile>" and others only returns the
  1727. --- referenced file name without further expansion. If "<cfile>"
  1728. --- is "~/.cshrc", you need to do another expand() to have the
  1729. --- "~/" expanded into the path of the home directory: >vim
  1730. --- echo expand(expand("<cfile>"))
  1731. --- <
  1732. --- There cannot be white space between the variables and the
  1733. --- following modifier. The |fnamemodify()| function can be used
  1734. --- to modify normal file names.
  1735. ---
  1736. --- When using '%' or '#', and the current or alternate file name
  1737. --- is not defined, an empty string is used. Using "%:p" in a
  1738. --- buffer with no name, results in the current directory, with a
  1739. --- '/' added.
  1740. --- When 'verbose' is set then expanding '%', '#' and <> items
  1741. --- will result in an error message if the argument cannot be
  1742. --- expanded.
  1743. ---
  1744. --- When {string} does not start with '%', '#' or '<', it is
  1745. --- expanded like a file name is expanded on the command line.
  1746. --- 'suffixes' and 'wildignore' are used, unless the optional
  1747. --- {nosuf} argument is given and it is |TRUE|.
  1748. --- Names for non-existing files are included. The "**" item can
  1749. --- be used to search in a directory tree. For example, to find
  1750. --- all "README" files in the current directory and below: >vim
  1751. --- echo expand("**/README")
  1752. --- <
  1753. --- expand() can also be used to expand variables and environment
  1754. --- variables that are only known in a shell. But this can be
  1755. --- slow, because a shell may be used to do the expansion. See
  1756. --- |expr-env-expand|.
  1757. --- The expanded variable is still handled like a list of file
  1758. --- names. When an environment variable cannot be expanded, it is
  1759. --- left unchanged. Thus ":echo expand('$FOOBAR')" results in
  1760. --- "$FOOBAR".
  1761. ---
  1762. --- See |glob()| for finding existing files. See |system()| for
  1763. --- getting the raw output of an external command.
  1764. ---
  1765. --- @param string string
  1766. --- @param nosuf? boolean
  1767. --- @param list? nil|false
  1768. --- @return string
  1769. function vim.fn.expand(string, nosuf, list) end
  1770. --- @param string string
  1771. --- @param nosuf boolean
  1772. --- @param list true|number|string|table
  1773. --- @return string|string[]
  1774. function vim.fn.expand(string, nosuf, list) end
  1775. --- Expand special items in String {string} like what is done for
  1776. --- an Ex command such as `:edit`. This expands special keywords,
  1777. --- like with |expand()|, and environment variables, anywhere in
  1778. --- {string}. "~user" and "~/path" are only expanded at the
  1779. --- start.
  1780. ---
  1781. --- The following items are supported in the {options} Dict
  1782. --- argument:
  1783. --- errmsg If set to TRUE, error messages are displayed
  1784. --- if an error is encountered during expansion.
  1785. --- By default, error messages are not displayed.
  1786. ---
  1787. --- Returns the expanded string. If an error is encountered
  1788. --- during expansion, the unmodified {string} is returned.
  1789. ---
  1790. --- Example: >vim
  1791. --- echo expandcmd('make %<.o')
  1792. --- < >
  1793. --- make /path/runtime/doc/builtin.o
  1794. --- < >vim
  1795. --- echo expandcmd('make %<.o', {'errmsg': v:true})
  1796. --- <
  1797. ---
  1798. --- @param string string
  1799. --- @param options? table
  1800. --- @return any
  1801. function vim.fn.expandcmd(string, options) end
  1802. --- {expr1} and {expr2} must be both |Lists| or both
  1803. --- |Dictionaries|.
  1804. ---
  1805. --- If they are |Lists|: Append {expr2} to {expr1}.
  1806. --- If {expr3} is given insert the items of {expr2} before the
  1807. --- item with index {expr3} in {expr1}. When {expr3} is zero
  1808. --- insert before the first item. When {expr3} is equal to
  1809. --- len({expr1}) then {expr2} is appended.
  1810. --- Examples: >vim
  1811. --- echo sort(extend(mylist, [7, 5]))
  1812. --- call extend(mylist, [2, 3], 1)
  1813. --- <When {expr1} is the same List as {expr2} then the number of
  1814. --- items copied is equal to the original length of the List.
  1815. --- E.g., when {expr3} is 1 you get N new copies of the first item
  1816. --- (where N is the original length of the List).
  1817. --- Use |add()| to concatenate one item to a list. To concatenate
  1818. --- two lists into a new list use the + operator: >vim
  1819. --- let newlist = [1, 2, 3] + [4, 5]
  1820. --- <
  1821. --- If they are |Dictionaries|:
  1822. --- Add all entries from {expr2} to {expr1}.
  1823. --- If a key exists in both {expr1} and {expr2} then {expr3} is
  1824. --- used to decide what to do:
  1825. --- {expr3} = "keep": keep the value of {expr1}
  1826. --- {expr3} = "force": use the value of {expr2}
  1827. --- {expr3} = "error": give an error message *E737*
  1828. --- When {expr3} is omitted then "force" is assumed.
  1829. ---
  1830. --- {expr1} is changed when {expr2} is not empty. If necessary
  1831. --- make a copy of {expr1} first or use |extendnew()| to return a
  1832. --- new List/Dictionary.
  1833. --- {expr2} remains unchanged.
  1834. --- When {expr1} is locked and {expr2} is not empty the operation
  1835. --- fails.
  1836. --- Returns {expr1}. Returns 0 on error.
  1837. ---
  1838. --- @param expr1 table
  1839. --- @param expr2 table
  1840. --- @param expr3? table
  1841. --- @return any
  1842. function vim.fn.extend(expr1, expr2, expr3) end
  1843. --- Like |extend()| but instead of adding items to {expr1} a new
  1844. --- List or Dictionary is created and returned. {expr1} remains
  1845. --- unchanged.
  1846. ---
  1847. --- @param expr1 table
  1848. --- @param expr2 table
  1849. --- @param expr3? table
  1850. --- @return any
  1851. function vim.fn.extendnew(expr1, expr2, expr3) end
  1852. --- Characters in {string} are queued for processing as if they
  1853. --- come from a mapping or were typed by the user.
  1854. ---
  1855. --- By default the string is added to the end of the typeahead
  1856. --- buffer, thus if a mapping is still being executed the
  1857. --- characters come after them. Use the 'i' flag to insert before
  1858. --- other characters, they will be executed next, before any
  1859. --- characters from a mapping.
  1860. ---
  1861. --- The function does not wait for processing of keys contained in
  1862. --- {string}.
  1863. ---
  1864. --- To include special keys into {string}, use double-quotes
  1865. --- and "\..." notation |expr-quote|. For example,
  1866. --- feedkeys("\<CR>") simulates pressing of the <Enter> key. But
  1867. --- feedkeys('\<CR>') pushes 5 characters.
  1868. --- The |<Ignore>| keycode may be used to exit the
  1869. --- wait-for-character without doing anything.
  1870. ---
  1871. --- {mode} is a String, which can contain these character flags:
  1872. --- 'm' Remap keys. This is default. If {mode} is absent,
  1873. --- keys are remapped.
  1874. --- 'n' Do not remap keys.
  1875. --- 't' Handle keys as if typed; otherwise they are handled as
  1876. --- if coming from a mapping. This matters for undo,
  1877. --- opening folds, etc.
  1878. --- 'L' Lowlevel input. Other flags are not used.
  1879. --- 'i' Insert the string instead of appending (see above).
  1880. --- 'x' Execute commands until typeahead is empty. This is
  1881. --- similar to using ":normal!". You can call feedkeys()
  1882. --- several times without 'x' and then one time with 'x'
  1883. --- (possibly with an empty {string}) to execute all the
  1884. --- typeahead. Note that when Vim ends in Insert mode it
  1885. --- will behave as if <Esc> is typed, to avoid getting
  1886. --- stuck, waiting for a character to be typed before the
  1887. --- script continues.
  1888. --- Note that if you manage to call feedkeys() while
  1889. --- executing commands, thus calling it recursively, then
  1890. --- all typeahead will be consumed by the last call.
  1891. --- '!' When used with 'x' will not end Insert mode. Can be
  1892. --- used in a test when a timer is set to exit Insert mode
  1893. --- a little later. Useful for testing CursorHoldI.
  1894. ---
  1895. --- Return value is always 0.
  1896. ---
  1897. --- @param string string
  1898. --- @param mode? string
  1899. --- @return any
  1900. function vim.fn.feedkeys(string, mode) end
  1901. --- @deprecated
  1902. --- Obsolete name for |filereadable()|.
  1903. ---
  1904. --- @param file string
  1905. --- @return any
  1906. function vim.fn.file_readable(file) end
  1907. --- Copy the file pointed to by the name {from} to {to}. The
  1908. --- result is a Number, which is |TRUE| if the file was copied
  1909. --- successfully, and |FALSE| when it failed.
  1910. --- If a file with name {to} already exists, it will fail.
  1911. --- Note that it does not handle directories (yet).
  1912. ---
  1913. --- This function is not available in the |sandbox|.
  1914. ---
  1915. --- @param from string
  1916. --- @param to string
  1917. --- @return 0|1
  1918. function vim.fn.filecopy(from, to) end
  1919. --- The result is a Number, which is |TRUE| when a file with the
  1920. --- name {file} exists, and can be read. If {file} doesn't exist,
  1921. --- or is a directory, the result is |FALSE|. {file} is any
  1922. --- expression, which is used as a String.
  1923. --- If you don't care about the file being readable you can use
  1924. --- |glob()|.
  1925. --- {file} is used as-is, you may want to expand wildcards first: >vim
  1926. --- echo filereadable('~/.vimrc')
  1927. --- < >
  1928. --- 0
  1929. --- < >vim
  1930. --- echo filereadable(expand('~/.vimrc'))
  1931. --- < >
  1932. --- 1
  1933. --- <
  1934. ---
  1935. --- @param file string
  1936. --- @return 0|1
  1937. function vim.fn.filereadable(file) end
  1938. --- The result is a Number, which is 1 when a file with the
  1939. --- name {file} exists, and can be written. If {file} doesn't
  1940. --- exist, or is not writable, the result is 0. If {file} is a
  1941. --- directory, and we can write to it, the result is 2.
  1942. ---
  1943. --- @param file string
  1944. --- @return 0|1
  1945. function vim.fn.filewritable(file) end
  1946. --- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  1947. --- For each item in {expr1} evaluate {expr2} and when the result
  1948. --- is zero or false remove the item from the |List| or
  1949. --- |Dictionary|. Similarly for each byte in a |Blob| and each
  1950. --- character in a |String|.
  1951. ---
  1952. --- {expr2} must be a |string| or |Funcref|.
  1953. ---
  1954. --- If {expr2} is a |string|, inside {expr2} |v:val| has the value
  1955. --- of the current item. For a |Dictionary| |v:key| has the key
  1956. --- of the current item and for a |List| |v:key| has the index of
  1957. --- the current item. For a |Blob| |v:key| has the index of the
  1958. --- current byte. For a |String| |v:key| has the index of the
  1959. --- current character.
  1960. --- Examples: >vim
  1961. --- call filter(mylist, 'v:val !~ "OLD"')
  1962. --- <Removes the items where "OLD" appears. >vim
  1963. --- call filter(mydict, 'v:key >= 8')
  1964. --- <Removes the items with a key below 8. >vim
  1965. --- call filter(var, 0)
  1966. --- <Removes all the items, thus clears the |List| or |Dictionary|.
  1967. ---
  1968. --- Note that {expr2} is the result of expression and is then
  1969. --- used as an expression again. Often it is good to use a
  1970. --- |literal-string| to avoid having to double backslashes.
  1971. ---
  1972. --- If {expr2} is a |Funcref| it must take two arguments:
  1973. --- 1. the key or the index of the current item.
  1974. --- 2. the value of the current item.
  1975. --- The function must return |TRUE| if the item should be kept.
  1976. --- Example that keeps the odd items of a list: >vim
  1977. --- func Odd(idx, val)
  1978. --- return a:idx % 2 == 1
  1979. --- endfunc
  1980. --- call filter(mylist, function('Odd'))
  1981. --- <It is shorter when using a |lambda|: >vim
  1982. --- call filter(myList, {idx, val -> idx * val <= 42})
  1983. --- <If you do not use "val" you can leave it out: >vim
  1984. --- call filter(myList, {idx -> idx % 2 == 1})
  1985. --- <
  1986. --- For a |List| and a |Dictionary| the operation is done
  1987. --- in-place. If you want it to remain unmodified make a copy
  1988. --- first: >vim
  1989. --- let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  1990. ---
  1991. --- <Returns {expr1}, the |List| or |Dictionary| that was filtered,
  1992. --- or a new |Blob| or |String|.
  1993. --- When an error is encountered while evaluating {expr2} no
  1994. --- further items in {expr1} are processed.
  1995. --- When {expr2} is a Funcref errors inside a function are ignored,
  1996. --- unless it was defined with the "abort" flag.
  1997. ---
  1998. --- @param expr1 string|table
  1999. --- @param expr2 string|function
  2000. --- @return any
  2001. function vim.fn.filter(expr1, expr2) end
  2002. --- Find directory {name} in {path}. Supports both downwards and
  2003. --- upwards recursive directory searches. See |file-searching|
  2004. --- for the syntax of {path}.
  2005. ---
  2006. --- Returns the path of the first found match. When the found
  2007. --- directory is below the current directory a relative path is
  2008. --- returned. Otherwise a full path is returned.
  2009. --- If {path} is omitted or empty then 'path' is used.
  2010. ---
  2011. --- If the optional {count} is given, find {count}'s occurrence of
  2012. --- {name} in {path} instead of the first one.
  2013. --- When {count} is negative return all the matches in a |List|.
  2014. ---
  2015. --- Returns an empty string if the directory is not found.
  2016. ---
  2017. --- This is quite similar to the ex-command `:find`.
  2018. ---
  2019. --- @param name string
  2020. --- @param path? string
  2021. --- @param count? integer
  2022. --- @return any
  2023. function vim.fn.finddir(name, path, count) end
  2024. --- Just like |finddir()|, but find a file instead of a directory.
  2025. --- Uses 'suffixesadd'.
  2026. --- Example: >vim
  2027. --- echo findfile("tags.vim", ".;")
  2028. --- <Searches from the directory of the current file upwards until
  2029. --- it finds the file "tags.vim".
  2030. ---
  2031. --- @param name string
  2032. --- @param path? string
  2033. --- @param count? any
  2034. --- @return any
  2035. function vim.fn.findfile(name, path, count) end
  2036. --- Flatten {list} up to {maxdepth} levels. Without {maxdepth}
  2037. --- the result is a |List| without nesting, as if {maxdepth} is
  2038. --- a very large number.
  2039. --- The {list} is changed in place, use |flattennew()| if you do
  2040. --- not want that.
  2041. --- *E900*
  2042. --- {maxdepth} means how deep in nested lists changes are made.
  2043. --- {list} is not modified when {maxdepth} is 0.
  2044. --- {maxdepth} must be positive number.
  2045. ---
  2046. --- If there is an error the number zero is returned.
  2047. ---
  2048. --- Example: >vim
  2049. --- echo flatten([1, [2, [3, 4]], 5])
  2050. --- < [1, 2, 3, 4, 5] >vim
  2051. --- echo flatten([1, [2, [3, 4]], 5], 1)
  2052. --- < [1, 2, [3, 4], 5]
  2053. ---
  2054. --- @param list any[]
  2055. --- @param maxdepth? integer
  2056. --- @return any[]|0
  2057. function vim.fn.flatten(list, maxdepth) end
  2058. --- Like |flatten()| but first make a copy of {list}.
  2059. ---
  2060. --- @param list any[]
  2061. --- @param maxdepth? integer
  2062. --- @return any[]|0
  2063. function vim.fn.flattennew(list, maxdepth) end
  2064. --- Convert {expr} to a Number by omitting the part after the
  2065. --- decimal point.
  2066. --- {expr} must evaluate to a |Float| or a |Number|.
  2067. --- Returns 0 if {expr} is not a |Float| or a |Number|.
  2068. --- When the value of {expr} is out of range for a |Number| the
  2069. --- result is truncated to 0x7fffffff or -0x7fffffff (or when
  2070. --- 64-bit Number support is enabled, 0x7fffffffffffffff or
  2071. --- -0x7fffffffffffffff). NaN results in -0x80000000 (or when
  2072. --- 64-bit Number support is enabled, -0x8000000000000000).
  2073. --- Examples: >vim
  2074. --- echo float2nr(3.95)
  2075. --- < 3 >vim
  2076. --- echo float2nr(-23.45)
  2077. --- < -23 >vim
  2078. --- echo float2nr(1.0e100)
  2079. --- < 2147483647 (or 9223372036854775807) >vim
  2080. --- echo float2nr(-1.0e150)
  2081. --- < -2147483647 (or -9223372036854775807) >vim
  2082. --- echo float2nr(1.0e-100)
  2083. --- < 0
  2084. ---
  2085. --- @param expr number
  2086. --- @return any
  2087. function vim.fn.float2nr(expr) end
  2088. --- Return the largest integral value less than or equal to
  2089. --- {expr} as a |Float| (round down).
  2090. --- {expr} must evaluate to a |Float| or a |Number|.
  2091. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  2092. --- Examples: >vim
  2093. --- echo floor(1.856)
  2094. --- < 1.0 >vim
  2095. --- echo floor(-5.456)
  2096. --- < -6.0 >vim
  2097. --- echo floor(4.0)
  2098. --- < 4.0
  2099. ---
  2100. --- @param expr number
  2101. --- @return any
  2102. function vim.fn.floor(expr) end
  2103. --- Return the remainder of {expr1} / {expr2}, even if the
  2104. --- division is not representable. Returns {expr1} - i * {expr2}
  2105. --- for some integer i such that if {expr2} is non-zero, the
  2106. --- result has the same sign as {expr1} and magnitude less than
  2107. --- the magnitude of {expr2}. If {expr2} is zero, the value
  2108. --- returned is zero. The value returned is a |Float|.
  2109. --- {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  2110. --- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  2111. --- |Number|.
  2112. --- Examples: >vim
  2113. --- echo fmod(12.33, 1.22)
  2114. --- < 0.13 >vim
  2115. --- echo fmod(-12.33, 1.22)
  2116. --- < -0.13
  2117. ---
  2118. --- @param expr1 number
  2119. --- @param expr2 number
  2120. --- @return any
  2121. function vim.fn.fmod(expr1, expr2) end
  2122. --- Escape {string} for use as file name command argument. All
  2123. --- characters that have a special meaning, such as `'%'` and `'|'`
  2124. --- are escaped with a backslash.
  2125. --- For most systems the characters escaped are
  2126. --- " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
  2127. --- appears in a filename, it depends on the value of 'isfname'.
  2128. --- A leading '+' and '>' is also escaped (special after |:edit|
  2129. --- and |:write|). And a "-" by itself (special after |:cd|).
  2130. --- Returns an empty string on error.
  2131. --- Example: >vim
  2132. --- let fname = '+some str%nge|name'
  2133. --- exe "edit " .. fnameescape(fname)
  2134. --- <results in executing: >vim
  2135. --- edit \+some\ str\%nge\|name
  2136. --- <
  2137. ---
  2138. --- @param string string
  2139. --- @return string
  2140. function vim.fn.fnameescape(string) end
  2141. --- Modify file name {fname} according to {mods}. {mods} is a
  2142. --- string of characters like it is used for file names on the
  2143. --- command line. See |filename-modifiers|.
  2144. --- Example: >vim
  2145. --- echo fnamemodify("main.c", ":p:h")
  2146. --- <results in: >
  2147. --- /home/user/vim/vim/src
  2148. --- <If {mods} is empty or an unsupported modifier is used then
  2149. --- {fname} is returned.
  2150. --- When {fname} is empty then with {mods} ":h" returns ".", so
  2151. --- that `:cd` can be used with it. This is different from
  2152. --- expand('%:h') without a buffer name, which returns an empty
  2153. --- string.
  2154. --- Note: Environment variables don't work in {fname}, use
  2155. --- |expand()| first then.
  2156. ---
  2157. --- @param fname string
  2158. --- @param mods string
  2159. --- @return string
  2160. function vim.fn.fnamemodify(fname, mods) end
  2161. --- The result is a Number. If the line {lnum} is in a closed
  2162. --- fold, the result is the number of the first line in that fold.
  2163. --- If the line {lnum} is not in a closed fold, -1 is returned.
  2164. --- {lnum} is used like with |getline()|. Thus "." is the current
  2165. --- line, "'m" mark m, etc.
  2166. ---
  2167. --- @param lnum integer
  2168. --- @return integer
  2169. function vim.fn.foldclosed(lnum) end
  2170. --- The result is a Number. If the line {lnum} is in a closed
  2171. --- fold, the result is the number of the last line in that fold.
  2172. --- If the line {lnum} is not in a closed fold, -1 is returned.
  2173. --- {lnum} is used like with |getline()|. Thus "." is the current
  2174. --- line, "'m" mark m, etc.
  2175. ---
  2176. --- @param lnum integer
  2177. --- @return integer
  2178. function vim.fn.foldclosedend(lnum) end
  2179. --- The result is a Number, which is the foldlevel of line {lnum}
  2180. --- in the current buffer. For nested folds the deepest level is
  2181. --- returned. If there is no fold at line {lnum}, zero is
  2182. --- returned. It doesn't matter if the folds are open or closed.
  2183. --- When used while updating folds (from 'foldexpr') -1 is
  2184. --- returned for lines where folds are still to be updated and the
  2185. --- foldlevel is unknown. As a special case the level of the
  2186. --- previous line is usually available.
  2187. --- {lnum} is used like with |getline()|. Thus "." is the current
  2188. --- line, "'m" mark m, etc.
  2189. ---
  2190. --- @param lnum integer
  2191. --- @return integer
  2192. function vim.fn.foldlevel(lnum) end
  2193. --- Returns a String, to be displayed for a closed fold. This is
  2194. --- the default function used for the 'foldtext' option and should
  2195. --- only be called from evaluating 'foldtext'. It uses the
  2196. --- |v:foldstart|, |v:foldend| and |v:folddashes| variables.
  2197. --- The returned string looks like this: >
  2198. --- +-- 45 lines: abcdef
  2199. --- <The number of leading dashes depends on the foldlevel. The
  2200. --- "45" is the number of lines in the fold. "abcdef" is the text
  2201. --- in the first non-blank line of the fold. Leading white space,
  2202. --- "//" or "/*" and the text from the 'foldmarker' and
  2203. --- 'commentstring' options is removed.
  2204. --- When used to draw the actual foldtext, the rest of the line
  2205. --- will be filled with the fold char from the 'fillchars'
  2206. --- setting.
  2207. --- Returns an empty string when there is no fold.
  2208. ---
  2209. --- @return string
  2210. function vim.fn.foldtext() end
  2211. --- Returns the text that is displayed for the closed fold at line
  2212. --- {lnum}. Evaluates 'foldtext' in the appropriate context.
  2213. --- When there is no closed fold at {lnum} an empty string is
  2214. --- returned.
  2215. --- {lnum} is used like with |getline()|. Thus "." is the current
  2216. --- line, "'m" mark m, etc.
  2217. --- Useful when exporting folded text, e.g., to HTML.
  2218. ---
  2219. --- @param lnum integer
  2220. --- @return string
  2221. function vim.fn.foldtextresult(lnum) end
  2222. --- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  2223. --- For each item in {expr1} execute {expr2}. {expr1} is not
  2224. --- modified; its values may be, as with |:lockvar| 1. |E741|
  2225. --- See |map()| and |filter()| to modify {expr1}.
  2226. ---
  2227. --- {expr2} must be a |string| or |Funcref|.
  2228. ---
  2229. --- If {expr2} is a |string|, inside {expr2} |v:val| has the value
  2230. --- of the current item. For a |Dictionary| |v:key| has the key
  2231. --- of the current item and for a |List| |v:key| has the index of
  2232. --- the current item. For a |Blob| |v:key| has the index of the
  2233. --- current byte. For a |String| |v:key| has the index of the
  2234. --- current character.
  2235. --- Examples: >vim
  2236. --- call foreach(mylist, 'let used[v:val] = v:true')
  2237. --- <This records the items that are in the {expr1} list.
  2238. ---
  2239. --- Note that {expr2} is the result of expression and is then used
  2240. --- as a command. Often it is good to use a |literal-string| to
  2241. --- avoid having to double backslashes.
  2242. ---
  2243. --- If {expr2} is a |Funcref| it must take two arguments:
  2244. --- 1. the key or the index of the current item.
  2245. --- 2. the value of the current item.
  2246. --- With a lambda you don't get an error if it only accepts one
  2247. --- argument.
  2248. --- If the function returns a value, it is ignored.
  2249. ---
  2250. --- Returns {expr1} in all cases.
  2251. --- When an error is encountered while executing {expr2} no
  2252. --- further items in {expr1} are processed.
  2253. --- When {expr2} is a Funcref errors inside a function are ignored,
  2254. --- unless it was defined with the "abort" flag.
  2255. ---
  2256. --- @param expr1 string|table
  2257. --- @param expr2 string|function
  2258. --- @return string|table
  2259. function vim.fn.foreach(expr1, expr2) end
  2260. --- Get the full command name from a short abbreviated command
  2261. --- name; see |20.2| for details on command abbreviations.
  2262. ---
  2263. --- The string argument {name} may start with a `:` and can
  2264. --- include a [range], these are skipped and not returned.
  2265. --- Returns an empty string if a command doesn't exist or if it's
  2266. --- ambiguous (for user-defined commands).
  2267. ---
  2268. --- For example `fullcommand('s')`, `fullcommand('sub')`,
  2269. --- `fullcommand(':%substitute')` all return "substitute".
  2270. ---
  2271. --- @param name string
  2272. --- @return string
  2273. function vim.fn.fullcommand(name) end
  2274. --- Just like |function()|, but the returned Funcref will lookup
  2275. --- the function by reference, not by name. This matters when the
  2276. --- function {name} is redefined later.
  2277. ---
  2278. --- Unlike |function()|, {name} must be an existing user function.
  2279. --- It only works for an autoloaded function if it has already
  2280. --- been loaded (to avoid mistakenly loading the autoload script
  2281. --- when only intending to use the function name, use |function()|
  2282. --- instead). {name} cannot be a builtin function.
  2283. --- Returns 0 on error.
  2284. ---
  2285. --- @param name string
  2286. --- @param arglist? any
  2287. --- @param dict? any
  2288. --- @return any
  2289. function vim.fn.funcref(name, arglist, dict) end
  2290. --- Return a |Funcref| variable that refers to function {name}.
  2291. --- {name} can be the name of a user defined function or an
  2292. --- internal function.
  2293. ---
  2294. --- {name} can also be a Funcref or a partial. When it is a
  2295. --- partial the dict stored in it will be used and the {dict}
  2296. --- argument is not allowed. E.g.: >vim
  2297. --- let FuncWithArg = function(dict.Func, [arg])
  2298. --- let Broken = function(dict.Func, [arg], dict)
  2299. --- <
  2300. --- When using the Funcref the function will be found by {name},
  2301. --- also when it was redefined later. Use |funcref()| to keep the
  2302. --- same function.
  2303. ---
  2304. --- When {arglist} or {dict} is present this creates a partial.
  2305. --- That means the argument list and/or the dictionary is stored in
  2306. --- the Funcref and will be used when the Funcref is called.
  2307. ---
  2308. --- The arguments are passed to the function in front of other
  2309. --- arguments, but after any argument from |method|. Example: >vim
  2310. --- func Callback(arg1, arg2, name)
  2311. --- "...
  2312. --- endfunc
  2313. --- let Partial = function('Callback', ['one', 'two'])
  2314. --- "...
  2315. --- call Partial('name')
  2316. --- <Invokes the function as with: >vim
  2317. --- call Callback('one', 'two', 'name')
  2318. ---
  2319. --- <With a |method|: >vim
  2320. --- func Callback(one, two, three)
  2321. --- "...
  2322. --- endfunc
  2323. --- let Partial = function('Callback', ['two'])
  2324. --- "...
  2325. --- eval 'one'->Partial('three')
  2326. --- <Invokes the function as with: >vim
  2327. --- call Callback('one', 'two', 'three')
  2328. ---
  2329. --- <The function() call can be nested to add more arguments to the
  2330. --- Funcref. The extra arguments are appended to the list of
  2331. --- arguments. Example: >vim
  2332. --- func Callback(arg1, arg2, name)
  2333. --- "...
  2334. --- endfunc
  2335. --- let Func = function('Callback', ['one'])
  2336. --- let Func2 = function(Func, ['two'])
  2337. --- "...
  2338. --- call Func2('name')
  2339. --- <Invokes the function as with: >vim
  2340. --- call Callback('one', 'two', 'name')
  2341. ---
  2342. --- <The Dictionary is only useful when calling a "dict" function.
  2343. --- In that case the {dict} is passed in as "self". Example: >vim
  2344. --- function Callback() dict
  2345. --- echo "called for " .. self.name
  2346. --- endfunction
  2347. --- "...
  2348. --- let context = {"name": "example"}
  2349. --- let Func = function('Callback', context)
  2350. --- "...
  2351. --- call Func() " will echo: called for example
  2352. --- <The use of function() is not needed when there are no extra
  2353. --- arguments, these two are equivalent, if Callback() is defined
  2354. --- as context.Callback(): >vim
  2355. --- let Func = function('Callback', context)
  2356. --- let Func = context.Callback
  2357. ---
  2358. --- <The argument list and the Dictionary can be combined: >vim
  2359. --- function Callback(arg1, count) dict
  2360. --- "...
  2361. --- endfunction
  2362. --- let context = {"name": "example"}
  2363. --- let Func = function('Callback', ['one'], context)
  2364. --- "...
  2365. --- call Func(500)
  2366. --- <Invokes the function as with: >vim
  2367. --- call context.Callback('one', 500)
  2368. --- <
  2369. --- Returns 0 on error.
  2370. ---
  2371. --- @param name string
  2372. --- @param arglist? any
  2373. --- @param dict? any
  2374. --- @return any
  2375. vim.fn['function'] = function(name, arglist, dict) end
  2376. --- Cleanup unused |Lists| and |Dictionaries| that have circular
  2377. --- references.
  2378. ---
  2379. --- There is hardly ever a need to invoke this function, as it is
  2380. --- automatically done when Vim runs out of memory or is waiting
  2381. --- for the user to press a key after 'updatetime'. Items without
  2382. --- circular references are always freed when they become unused.
  2383. --- This is useful if you have deleted a very big |List| and/or
  2384. --- |Dictionary| with circular references in a script that runs
  2385. --- for a long time.
  2386. ---
  2387. --- When the optional {atexit} argument is one, garbage
  2388. --- collection will also be done when exiting Vim, if it wasn't
  2389. --- done before. This is useful when checking for memory leaks.
  2390. ---
  2391. --- The garbage collection is not done immediately but only when
  2392. --- it's safe to perform. This is when waiting for the user to
  2393. --- type a character.
  2394. ---
  2395. --- @param atexit? boolean
  2396. --- @return any
  2397. function vim.fn.garbagecollect(atexit) end
  2398. --- Get item {idx} from |List| {list}. When this item is not
  2399. --- available return {default}. Return zero when {default} is
  2400. --- omitted.
  2401. ---
  2402. --- @param list any[]
  2403. --- @param idx integer
  2404. --- @param default? any
  2405. --- @return any
  2406. function vim.fn.get(list, idx, default) end
  2407. --- Get byte {idx} from |Blob| {blob}. When this byte is not
  2408. --- available return {default}. Return -1 when {default} is
  2409. --- omitted.
  2410. ---
  2411. --- @param blob string
  2412. --- @param idx integer
  2413. --- @param default? any
  2414. --- @return any
  2415. function vim.fn.get(blob, idx, default) end
  2416. --- Get item with key {key} from |Dictionary| {dict}. When this
  2417. --- item is not available return {default}. Return zero when
  2418. --- {default} is omitted. Useful example: >vim
  2419. --- let val = get(g:, 'var_name', 'default')
  2420. --- <This gets the value of g:var_name if it exists, and uses
  2421. --- "default" when it does not exist.
  2422. ---
  2423. --- @param dict table<string,any>
  2424. --- @param key string
  2425. --- @param default? any
  2426. --- @return any
  2427. function vim.fn.get(dict, key, default) end
  2428. --- Get item {what} from |Funcref| {func}. Possible values for
  2429. --- {what} are:
  2430. --- "name" The function name
  2431. --- "func" The function
  2432. --- "dict" The dictionary
  2433. --- "args" The list with arguments
  2434. --- "arity" A dictionary with information about the number of
  2435. --- arguments accepted by the function (minus the
  2436. --- {arglist}) with the following fields:
  2437. --- required the number of positional arguments
  2438. --- optional the number of optional arguments,
  2439. --- in addition to the required ones
  2440. --- varargs |TRUE| if the function accepts a
  2441. --- variable number of arguments |...|
  2442. ---
  2443. --- Note: There is no error, if the {arglist} of
  2444. --- the Funcref contains more arguments than the
  2445. --- Funcref expects, it's not validated.
  2446. ---
  2447. --- Returns zero on error.
  2448. ---
  2449. --- @param func function
  2450. --- @param what string
  2451. --- @return any
  2452. function vim.fn.get(func, what) end
  2453. --- @param buf? integer|string
  2454. --- @return vim.fn.getbufinfo.ret.item[]
  2455. function vim.fn.getbufinfo(buf) end
  2456. --- Get information about buffers as a List of Dictionaries.
  2457. ---
  2458. --- Without an argument information about all the buffers is
  2459. --- returned.
  2460. ---
  2461. --- When the argument is a |Dictionary| only the buffers matching
  2462. --- the specified criteria are returned. The following keys can
  2463. --- be specified in {dict}:
  2464. --- buflisted include only listed buffers.
  2465. --- bufloaded include only loaded buffers.
  2466. --- bufmodified include only modified buffers.
  2467. ---
  2468. --- Otherwise, {buf} specifies a particular buffer to return
  2469. --- information for. For the use of {buf}, see |bufname()|
  2470. --- above. If the buffer is found the returned List has one item.
  2471. --- Otherwise the result is an empty list.
  2472. ---
  2473. --- Each returned List item is a dictionary with the following
  2474. --- entries:
  2475. --- bufnr Buffer number.
  2476. --- changed TRUE if the buffer is modified.
  2477. --- changedtick Number of changes made to the buffer.
  2478. --- command TRUE if the buffer belongs to the
  2479. --- command-line window |cmdwin|.
  2480. --- hidden TRUE if the buffer is hidden.
  2481. --- lastused Timestamp in seconds, like
  2482. --- |localtime()|, when the buffer was
  2483. --- last used.
  2484. --- listed TRUE if the buffer is listed.
  2485. --- lnum Line number used for the buffer when
  2486. --- opened in the current window.
  2487. --- Only valid if the buffer has been
  2488. --- displayed in the window in the past.
  2489. --- If you want the line number of the
  2490. --- last known cursor position in a given
  2491. --- window, use |line()|: >vim
  2492. --- echo line('.', {winid})
  2493. --- <
  2494. --- linecount Number of lines in the buffer (only
  2495. --- valid when loaded)
  2496. --- loaded TRUE if the buffer is loaded.
  2497. --- name Full path to the file in the buffer.
  2498. --- signs List of signs placed in the buffer.
  2499. --- Each list item is a dictionary with
  2500. --- the following fields:
  2501. --- id sign identifier
  2502. --- lnum line number
  2503. --- name sign name
  2504. --- variables A reference to the dictionary with
  2505. --- buffer-local variables.
  2506. --- windows List of |window-ID|s that display this
  2507. --- buffer
  2508. ---
  2509. --- Examples: >vim
  2510. --- for buf in getbufinfo()
  2511. --- echo buf.name
  2512. --- endfor
  2513. --- for buf in getbufinfo({'buflisted':1})
  2514. --- if buf.changed
  2515. --- " ....
  2516. --- endif
  2517. --- endfor
  2518. --- <
  2519. --- To get buffer-local options use: >vim
  2520. --- getbufvar({bufnr}, '&option_name')
  2521. --- <
  2522. ---
  2523. --- @param dict? vim.fn.getbufinfo.dict
  2524. --- @return vim.fn.getbufinfo.ret.item[]
  2525. function vim.fn.getbufinfo(dict) end
  2526. --- Return a |List| with the lines starting from {lnum} to {end}
  2527. --- (inclusive) in the buffer {buf}. If {end} is omitted, a
  2528. --- |List| with only the line {lnum} is returned. See
  2529. --- `getbufoneline()` for only getting the line.
  2530. ---
  2531. --- For the use of {buf}, see |bufname()| above.
  2532. ---
  2533. --- For {lnum} and {end} "$" can be used for the last line of the
  2534. --- buffer. Otherwise a number must be used.
  2535. ---
  2536. --- When {lnum} is smaller than 1 or bigger than the number of
  2537. --- lines in the buffer, an empty |List| is returned.
  2538. ---
  2539. --- When {end} is greater than the number of lines in the buffer,
  2540. --- it is treated as {end} is set to the number of lines in the
  2541. --- buffer. When {end} is before {lnum} an empty |List| is
  2542. --- returned.
  2543. ---
  2544. --- This function works only for loaded buffers. For unloaded and
  2545. --- non-existing buffers, an empty |List| is returned.
  2546. ---
  2547. --- Example: >vim
  2548. --- let lines = getbufline(bufnr("myfile"), 1, "$")
  2549. --- <
  2550. ---
  2551. --- @param buf integer|string
  2552. --- @param lnum integer
  2553. --- @param end_? integer
  2554. --- @return string[]
  2555. function vim.fn.getbufline(buf, lnum, end_) end
  2556. --- Just like `getbufline()` but only get one line and return it
  2557. --- as a string.
  2558. ---
  2559. --- @param buf integer|string
  2560. --- @param lnum integer
  2561. --- @return string
  2562. function vim.fn.getbufoneline(buf, lnum) end
  2563. --- The result is the value of option or local buffer variable
  2564. --- {varname} in buffer {buf}. Note that the name without "b:"
  2565. --- must be used.
  2566. --- The {varname} argument is a string.
  2567. --- When {varname} is empty returns a |Dictionary| with all the
  2568. --- buffer-local variables.
  2569. --- When {varname} is equal to "&" returns a |Dictionary| with all
  2570. --- the buffer-local options.
  2571. --- Otherwise, when {varname} starts with "&" returns the value of
  2572. --- a buffer-local option.
  2573. --- This also works for a global or buffer-local option, but it
  2574. --- doesn't work for a global variable, window-local variable or
  2575. --- window-local option.
  2576. --- For the use of {buf}, see |bufname()| above.
  2577. --- When the buffer or variable doesn't exist {def} or an empty
  2578. --- string is returned, there is no error message.
  2579. --- Examples: >vim
  2580. --- let bufmodified = getbufvar(1, "&mod")
  2581. --- echo "todo myvar = " .. getbufvar("todo", "myvar")
  2582. ---
  2583. --- @param buf integer|string
  2584. --- @param varname string
  2585. --- @param def? any
  2586. --- @return any
  2587. function vim.fn.getbufvar(buf, varname, def) end
  2588. --- Returns a |List| of cell widths of character ranges overridden
  2589. --- by |setcellwidths()|. The format is equal to the argument of
  2590. --- |setcellwidths()|. If no character ranges have their cell
  2591. --- widths overridden, an empty List is returned.
  2592. ---
  2593. --- @return any
  2594. function vim.fn.getcellwidths() end
  2595. --- Returns the |changelist| for the buffer {buf}. For the use
  2596. --- of {buf}, see |bufname()| above. If buffer {buf} doesn't
  2597. --- exist, an empty list is returned.
  2598. ---
  2599. --- The returned list contains two entries: a list with the change
  2600. --- locations and the current position in the list. Each
  2601. --- entry in the change list is a dictionary with the following
  2602. --- entries:
  2603. --- col column number
  2604. --- coladd column offset for 'virtualedit'
  2605. --- lnum line number
  2606. --- If buffer {buf} is the current buffer, then the current
  2607. --- position refers to the position in the list. For other
  2608. --- buffers, it is set to the length of the list.
  2609. ---
  2610. --- @param buf? integer|string
  2611. --- @return table[]
  2612. function vim.fn.getchangelist(buf) end
  2613. --- Get a single character from the user or input stream.
  2614. --- If {expr} is omitted or is -1, wait until a character is
  2615. --- available.
  2616. --- If {expr} is 0, only get a character when one is available.
  2617. --- Return zero otherwise.
  2618. --- If {expr} is 1, only check if a character is available, it is
  2619. --- not consumed. Return zero if no character available.
  2620. --- If you prefer always getting a string use |getcharstr()|, or
  2621. --- specify |FALSE| as "number" in {opts}.
  2622. ---
  2623. --- Without {expr} and when {expr} is 0 a whole character or
  2624. --- special key is returned. If it is a single character, the
  2625. --- result is a Number. Use |nr2char()| to convert it to a String.
  2626. --- Otherwise a String is returned with the encoded character.
  2627. --- For a special key it's a String with a sequence of bytes
  2628. --- starting with 0x80 (decimal: 128). This is the same value as
  2629. --- the String "\<Key>", e.g., "\<Left>". The returned value is
  2630. --- also a String when a modifier (shift, control, alt) was used
  2631. --- that is not included in the character. |keytrans()| can also
  2632. --- be used to convert a returned String into a readable form.
  2633. ---
  2634. --- When {expr} is 0 and Esc is typed, there will be a short delay
  2635. --- while Vim waits to see if this is the start of an escape
  2636. --- sequence.
  2637. ---
  2638. --- When {expr} is 1 only the first byte is returned. For a
  2639. --- one-byte character it is the character itself as a number.
  2640. --- Use nr2char() to convert it to a String.
  2641. ---
  2642. --- Use getcharmod() to obtain any additional modifiers.
  2643. ---
  2644. --- The optional argument {opts} is a Dict and supports the
  2645. --- following items:
  2646. ---
  2647. --- cursor A String specifying cursor behavior
  2648. --- when waiting for a character.
  2649. --- "hide": hide the cursor.
  2650. --- "keep": keep current cursor unchanged.
  2651. --- "msg": move cursor to message area.
  2652. --- (default: automagically decide
  2653. --- between "keep" and "msg")
  2654. ---
  2655. --- number If |TRUE|, return a Number when getting
  2656. --- a single character.
  2657. --- If |FALSE|, the return value is always
  2658. --- converted to a String, and an empty
  2659. --- String (instead of 0) is returned when
  2660. --- no character is available.
  2661. --- (default: |TRUE|)
  2662. ---
  2663. --- simplify If |TRUE|, include modifiers in the
  2664. --- character if possible. E.g., return
  2665. --- the same value for CTRL-I and <Tab>.
  2666. --- If |FALSE|, don't include modifiers in
  2667. --- the character.
  2668. --- (default: |TRUE|)
  2669. ---
  2670. --- When the user clicks a mouse button, the mouse event will be
  2671. --- returned. The position can then be found in |v:mouse_col|,
  2672. --- |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
  2673. --- |getmousepos()| can also be used. Mouse move events will be
  2674. --- ignored.
  2675. --- This example positions the mouse as it would normally happen: >vim
  2676. --- let c = getchar()
  2677. --- if c == "\<LeftMouse>" && v:mouse_win > 0
  2678. --- exe v:mouse_win .. "wincmd w"
  2679. --- exe v:mouse_lnum
  2680. --- exe "normal " .. v:mouse_col .. "|"
  2681. --- endif
  2682. --- <
  2683. --- There is no prompt, you will somehow have to make clear to the
  2684. --- user that a character has to be typed. The screen is not
  2685. --- redrawn, e.g. when resizing the window.
  2686. ---
  2687. --- There is no mapping for the character.
  2688. --- Key codes are replaced, thus when the user presses the <Del>
  2689. --- key you get the code for the <Del> key, not the raw character
  2690. --- sequence. Examples: >vim
  2691. --- getchar() == "\<Del>"
  2692. --- getchar() == "\<S-Left>"
  2693. --- <This example redefines "f" to ignore case: >vim
  2694. --- nmap f :call FindChar()<CR>
  2695. --- function FindChar()
  2696. --- let c = nr2char(getchar())
  2697. --- while col('.') < col('$') - 1
  2698. --- normal l
  2699. --- if getline('.')[col('.') - 1] ==? c
  2700. --- break
  2701. --- endif
  2702. --- endwhile
  2703. --- endfunction
  2704. --- <
  2705. ---
  2706. --- @param expr? -1|0|1
  2707. --- @param opts? table
  2708. --- @return integer|string
  2709. function vim.fn.getchar(expr, opts) end
  2710. --- The result is a Number which is the state of the modifiers for
  2711. --- the last obtained character with getchar() or in another way.
  2712. --- These values are added together:
  2713. --- 2 shift
  2714. --- 4 control
  2715. --- 8 alt (meta)
  2716. --- 16 meta (when it's different from ALT)
  2717. --- 32 mouse double click
  2718. --- 64 mouse triple click
  2719. --- 96 mouse quadruple click (== 32 + 64)
  2720. --- 128 command (Mac) or super
  2721. --- Only the modifiers that have not been included in the
  2722. --- character itself are obtained. Thus Shift-a results in "A"
  2723. --- without a modifier. Returns 0 if no modifiers are used.
  2724. ---
  2725. --- @return integer
  2726. function vim.fn.getcharmod() end
  2727. --- Get the position for String {expr}. Same as |getpos()| but the
  2728. --- column number in the returned List is a character index
  2729. --- instead of a byte index.
  2730. --- If |getpos()| returns a very large column number, equal to
  2731. --- |v:maxcol|, then getcharpos() will return the character index
  2732. --- of the last character.
  2733. ---
  2734. --- Example:
  2735. --- With the cursor on '세' in line 5 with text "여보세요": >vim
  2736. --- getcharpos('.') returns [0, 5, 3, 0]
  2737. --- getpos('.') returns [0, 5, 7, 0]
  2738. --- <
  2739. ---
  2740. --- @param expr string
  2741. --- @return integer[]
  2742. function vim.fn.getcharpos(expr) end
  2743. --- Return the current character search information as a {dict}
  2744. --- with the following entries:
  2745. ---
  2746. --- char character previously used for a character
  2747. --- search (|t|, |f|, |T|, or |F|); empty string
  2748. --- if no character search has been performed
  2749. --- forward direction of character search; 1 for forward,
  2750. --- 0 for backward
  2751. --- until type of character search; 1 for a |t| or |T|
  2752. --- character search, 0 for an |f| or |F|
  2753. --- character search
  2754. ---
  2755. --- This can be useful to always have |;| and |,| search
  2756. --- forward/backward regardless of the direction of the previous
  2757. --- character search: >vim
  2758. --- nnoremap <expr> ; getcharsearch().forward ? ';' : ','
  2759. --- nnoremap <expr> , getcharsearch().forward ? ',' : ';'
  2760. --- <Also see |setcharsearch()|.
  2761. ---
  2762. --- @return table
  2763. function vim.fn.getcharsearch() end
  2764. --- The same as |getchar()|, except that this always returns a
  2765. --- String, and "number" isn't allowed in {opts}.
  2766. ---
  2767. --- @param expr? -1|0|1
  2768. --- @param opts? table
  2769. --- @return string
  2770. function vim.fn.getcharstr(expr, opts) end
  2771. --- Return completion pattern of the current command-line.
  2772. --- Only works when the command line is being edited, thus
  2773. --- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2774. --- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2775. --- |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
  2776. --- Returns an empty string when completion is not defined.
  2777. ---
  2778. --- @return string
  2779. function vim.fn.getcmdcomplpat() end
  2780. --- Return the type of the current command-line completion.
  2781. --- Only works when the command line is being edited, thus
  2782. --- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2783. --- See |:command-completion| for the return string.
  2784. --- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2785. --- |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
  2786. --- Returns an empty string when completion is not defined.
  2787. ---
  2788. --- @return string
  2789. function vim.fn.getcmdcompltype() end
  2790. --- Return the current command-line input. Only works when the
  2791. --- command line is being edited, thus requires use of
  2792. --- |c_CTRL-\_e| or |c_CTRL-R_=|.
  2793. --- Example: >vim
  2794. --- cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
  2795. --- <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
  2796. --- |getcmdprompt()| and |setcmdline()|.
  2797. --- Returns an empty string when entering a password or using
  2798. --- |inputsecret()|.
  2799. ---
  2800. --- @return string
  2801. function vim.fn.getcmdline() end
  2802. --- Return the position of the cursor in the command line as a
  2803. --- byte count. The first column is 1.
  2804. --- Only works when editing the command line, thus requires use of
  2805. --- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2806. --- Returns 0 otherwise.
  2807. --- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2808. --- |getcmdprompt()| and |setcmdline()|.
  2809. ---
  2810. --- @return integer
  2811. function vim.fn.getcmdpos() end
  2812. --- Return the current command-line prompt when using functions
  2813. --- like |input()| or |confirm()|.
  2814. --- Only works when the command line is being edited, thus
  2815. --- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2816. --- Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
  2817. --- |setcmdpos()| and |setcmdline()|.
  2818. ---
  2819. --- @return string
  2820. function vim.fn.getcmdprompt() end
  2821. --- Return the screen position of the cursor in the command line
  2822. --- as a byte count. The first column is 1.
  2823. --- Instead of |getcmdpos()|, it adds the prompt position.
  2824. --- Only works when editing the command line, thus requires use of
  2825. --- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2826. --- Returns 0 otherwise.
  2827. --- Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
  2828. --- |setcmdline()|.
  2829. ---
  2830. --- @return integer
  2831. function vim.fn.getcmdscreenpos() end
  2832. --- Return the current command-line type. Possible return values
  2833. --- are:
  2834. --- : normal Ex command
  2835. --- > debug mode command |debug-mode|
  2836. --- / forward search command
  2837. --- ? backward search command
  2838. --- \@ |input()| command
  2839. --- `-` |:insert| or |:append| command
  2840. --- = |i_CTRL-R_=|
  2841. --- Only works when editing the command line, thus requires use of
  2842. --- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2843. --- Returns an empty string otherwise.
  2844. --- Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  2845. ---
  2846. --- @return ':'|'>'|'/'|'?'|'@'|'-'|'='
  2847. function vim.fn.getcmdtype() end
  2848. --- Return the current |command-line-window| type. Possible return
  2849. --- values are the same as |getcmdtype()|. Returns an empty string
  2850. --- when not in the command-line window.
  2851. ---
  2852. --- @return ':'|'>'|'/'|'?'|'@'|'-'|'='
  2853. function vim.fn.getcmdwintype() end
  2854. --- Return a list of command-line completion matches. The String
  2855. --- {type} argument specifies what for. The following completion
  2856. --- types are supported:
  2857. ---
  2858. --- arglist file names in argument list
  2859. --- augroup autocmd groups
  2860. --- buffer buffer names
  2861. --- breakpoint |:breakadd| and |:breakdel| suboptions
  2862. --- cmdline |cmdline-completion| result
  2863. --- color color schemes
  2864. --- command Ex command
  2865. --- compiler compilers
  2866. --- custom,{func} custom completion, defined via {func}
  2867. --- customlist,{func} custom completion, defined via {func}
  2868. --- diff_buffer |:diffget| and |:diffput| completion
  2869. --- dir directory names
  2870. --- dir_in_path directory names in |'cdpath'|
  2871. --- environment environment variable names
  2872. --- event autocommand events
  2873. --- expression Vim expression
  2874. --- file file and directory names
  2875. --- file_in_path file and directory names in |'path'|
  2876. --- filetype filetype names |'filetype'|
  2877. --- function function name
  2878. --- help help subjects
  2879. --- highlight highlight groups
  2880. --- history |:history| suboptions
  2881. --- keymap keyboard mappings
  2882. --- locale locale names (as output of locale -a)
  2883. --- mapclear buffer argument
  2884. --- mapping mapping name
  2885. --- menu menus
  2886. --- messages |:messages| suboptions
  2887. --- option options
  2888. --- packadd optional package |pack-add| names
  2889. --- runtime |:runtime| completion
  2890. --- scriptnames sourced script names |:scriptnames|
  2891. --- shellcmd Shell command
  2892. --- shellcmdline Shell command line with filename arguments
  2893. --- sign |:sign| suboptions
  2894. --- syntax syntax file names |'syntax'|
  2895. --- syntime |:syntime| suboptions
  2896. --- tag tags
  2897. --- tag_listfiles tags, file names
  2898. --- user user names
  2899. --- var user variables
  2900. ---
  2901. --- If {pat} is an empty string, then all the matches are
  2902. --- returned. Otherwise only items matching {pat} are returned.
  2903. --- See |wildcards| for the use of special characters in {pat}.
  2904. ---
  2905. --- If the optional {filtered} flag is set to 1, then 'wildignore'
  2906. --- is applied to filter the results. Otherwise all the matches
  2907. --- are returned. The 'wildignorecase' option always applies.
  2908. ---
  2909. --- If the 'wildoptions' option contains "fuzzy", then fuzzy
  2910. --- matching is used to get the completion matches. Otherwise
  2911. --- regular expression matching is used. Thus this function
  2912. --- follows the user preference, what happens on the command line.
  2913. --- If you do not want this you can make 'wildoptions' empty
  2914. --- before calling getcompletion() and restore it afterwards.
  2915. ---
  2916. --- If {type} is "cmdline", then the |cmdline-completion| result is
  2917. --- returned. For example, to complete the possible values after
  2918. --- a ":call" command: >vim
  2919. --- echo getcompletion('call ', 'cmdline')
  2920. --- <
  2921. --- If there are no matches, an empty list is returned. An
  2922. --- invalid value for {type} produces an error.
  2923. ---
  2924. --- @param pat string
  2925. --- @param type string
  2926. --- @param filtered? boolean
  2927. --- @return string[]
  2928. function vim.fn.getcompletion(pat, type, filtered) end
  2929. --- Get the position of the cursor. This is like getpos('.'), but
  2930. --- includes an extra "curswant" item in the list:
  2931. --- [0, lnum, col, off, curswant] ~
  2932. --- The "curswant" number is the preferred column when moving the
  2933. --- cursor vertically. After |$| command it will be a very large
  2934. --- number equal to |v:maxcol|. Also see |getcursorcharpos()| and
  2935. --- |getpos()|.
  2936. --- The first "bufnum" item is always zero. The byte position of
  2937. --- the cursor is returned in "col". To get the character
  2938. --- position, use |getcursorcharpos()|.
  2939. ---
  2940. --- The optional {winid} argument can specify the window. It can
  2941. --- be the window number or the |window-ID|. The last known
  2942. --- cursor position is returned, this may be invalid for the
  2943. --- current value of the buffer if it is not the current window.
  2944. --- If {winid} is invalid a list with zeroes is returned.
  2945. ---
  2946. --- This can be used to save and restore the cursor position: >vim
  2947. --- let save_cursor = getcurpos()
  2948. --- MoveTheCursorAround
  2949. --- call setpos('.', save_cursor)
  2950. --- <Note that this only works within the window. See
  2951. --- |winrestview()| for restoring more state.
  2952. ---
  2953. --- @param winid? integer
  2954. --- @return any
  2955. function vim.fn.getcurpos(winid) end
  2956. --- Same as |getcurpos()| but the column number in the returned
  2957. --- List is a character index instead of a byte index.
  2958. ---
  2959. --- Example:
  2960. --- With the cursor on '보' in line 3 with text "여보세요": >vim
  2961. --- getcursorcharpos() " returns [0, 3, 2, 0, 3]
  2962. --- getcurpos() " returns [0, 3, 4, 0, 3]
  2963. --- <
  2964. ---
  2965. --- @param winid? integer
  2966. --- @return any
  2967. function vim.fn.getcursorcharpos(winid) end
  2968. --- With no arguments, returns the name of the effective
  2969. --- |current-directory|. With {winnr} or {tabnr} the working
  2970. --- directory of that scope is returned, and 'autochdir' is
  2971. --- ignored.
  2972. --- Tabs and windows are identified by their respective numbers,
  2973. --- 0 means current tab or window. Missing tab number implies 0.
  2974. --- Thus the following are equivalent: >vim
  2975. --- getcwd(0)
  2976. --- getcwd(0, 0)
  2977. --- <If {winnr} is -1 it is ignored, only the tab is resolved.
  2978. --- {winnr} can be the window number or the |window-ID|.
  2979. --- If both {winnr} and {tabnr} are -1 the global working
  2980. --- directory is returned.
  2981. --- Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  2982. ---
  2983. --- @param winnr? integer
  2984. --- @param tabnr? integer
  2985. --- @return string
  2986. function vim.fn.getcwd(winnr, tabnr) end
  2987. --- Return the value of environment variable {name}. The {name}
  2988. --- argument is a string, without a leading '$'. Example: >vim
  2989. --- myHome = getenv('HOME')
  2990. ---
  2991. --- <When the variable does not exist |v:null| is returned. That
  2992. --- is different from a variable set to an empty string.
  2993. --- See also |expr-env|.
  2994. ---
  2995. --- @param name string
  2996. --- @return string
  2997. function vim.fn.getenv(name) end
  2998. --- Without an argument returns the name of the normal font being
  2999. --- used. Like what is used for the Normal highlight group
  3000. --- |hl-Normal|.
  3001. --- With an argument a check is done whether String {name} is a
  3002. --- valid font name. If not then an empty string is returned.
  3003. --- Otherwise the actual font name is returned, or {name} if the
  3004. --- GUI does not support obtaining the real name.
  3005. --- Only works when the GUI is running, thus not in your vimrc or
  3006. --- gvimrc file. Use the |GUIEnter| autocommand to use this
  3007. --- function just after the GUI has started.
  3008. ---
  3009. --- @param name? string
  3010. --- @return string
  3011. function vim.fn.getfontname(name) end
  3012. --- The result is a String, which is the read, write, and execute
  3013. --- permissions of the given file {fname}.
  3014. --- If {fname} does not exist or its directory cannot be read, an
  3015. --- empty string is returned.
  3016. --- The result is of the form "rwxrwxrwx", where each group of
  3017. --- "rwx" flags represent, in turn, the permissions of the owner
  3018. --- of the file, the group the file belongs to, and other users.
  3019. --- If a user does not have a given permission the flag for this
  3020. --- is replaced with the string "-". Examples: >vim
  3021. --- echo getfperm("/etc/passwd")
  3022. --- echo getfperm(expand("~/.config/nvim/init.vim"))
  3023. --- <This will hopefully (from a security point of view) display
  3024. --- the string "rw-r--r--" or even "rw-------".
  3025. ---
  3026. --- For setting permissions use |setfperm()|.
  3027. ---
  3028. --- @param fname string
  3029. --- @return string
  3030. function vim.fn.getfperm(fname) end
  3031. --- The result is a Number, which is the size in bytes of the
  3032. --- given file {fname}.
  3033. --- If {fname} is a directory, 0 is returned.
  3034. --- If the file {fname} can't be found, -1 is returned.
  3035. --- If the size of {fname} is too big to fit in a Number then -2
  3036. --- is returned.
  3037. ---
  3038. --- @param fname string
  3039. --- @return integer
  3040. function vim.fn.getfsize(fname) end
  3041. --- The result is a Number, which is the last modification time of
  3042. --- the given file {fname}. The value is measured as seconds
  3043. --- since 1st Jan 1970, and may be passed to strftime(). See also
  3044. --- |localtime()| and |strftime()|.
  3045. --- If the file {fname} can't be found -1 is returned.
  3046. ---
  3047. --- @param fname string
  3048. --- @return integer
  3049. function vim.fn.getftime(fname) end
  3050. --- The result is a String, which is a description of the kind of
  3051. --- file of the given file {fname}.
  3052. --- If {fname} does not exist an empty string is returned.
  3053. --- Here is a table over different kinds of files and their
  3054. --- results:
  3055. --- Normal file "file"
  3056. --- Directory "dir"
  3057. --- Symbolic link "link"
  3058. --- Block device "bdev"
  3059. --- Character device "cdev"
  3060. --- Socket "socket"
  3061. --- FIFO "fifo"
  3062. --- All other "other"
  3063. --- Example: >vim
  3064. --- getftype("/home")
  3065. --- <Note that a type such as "link" will only be returned on
  3066. --- systems that support it. On some systems only "dir" and
  3067. --- "file" are returned.
  3068. ---
  3069. --- @param fname string
  3070. --- @return 'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'
  3071. function vim.fn.getftype(fname) end
  3072. --- Returns the |jumplist| for the specified window.
  3073. ---
  3074. --- Without arguments use the current window.
  3075. --- With {winnr} only use this window in the current tab page.
  3076. --- {winnr} can also be a |window-ID|.
  3077. --- With {winnr} and {tabnr} use the window in the specified tab
  3078. --- page. If {winnr} or {tabnr} is invalid, an empty list is
  3079. --- returned.
  3080. ---
  3081. --- The returned list contains two entries: a list with the jump
  3082. --- locations and the last used jump position number in the list.
  3083. --- Each entry in the jump location list is a dictionary with
  3084. --- the following entries:
  3085. --- bufnr buffer number
  3086. --- col column number
  3087. --- coladd column offset for 'virtualedit'
  3088. --- filename filename if available
  3089. --- lnum line number
  3090. ---
  3091. --- @param winnr? integer
  3092. --- @param tabnr? integer
  3093. --- @return vim.fn.getjumplist.ret
  3094. function vim.fn.getjumplist(winnr, tabnr) end
  3095. --- Without {end} the result is a String, which is line {lnum}
  3096. --- from the current buffer. Example: >vim
  3097. --- getline(1)
  3098. --- <When {lnum} is a String that doesn't start with a
  3099. --- digit, |line()| is called to translate the String into a Number.
  3100. --- To get the line under the cursor: >vim
  3101. --- getline(".")
  3102. --- <When {lnum} is a number smaller than 1 or bigger than the
  3103. --- number of lines in the buffer, an empty string is returned.
  3104. ---
  3105. --- When {end} is given the result is a |List| where each item is
  3106. --- a line from the current buffer in the range {lnum} to {end},
  3107. --- including line {end}.
  3108. --- {end} is used in the same way as {lnum}.
  3109. --- Non-existing lines are silently omitted.
  3110. --- When {end} is before {lnum} an empty |List| is returned.
  3111. --- Example: >vim
  3112. --- let start = line('.')
  3113. --- let end = search("^$") - 1
  3114. --- let lines = getline(start, end)
  3115. ---
  3116. --- <To get lines from another buffer see |getbufline()| and
  3117. --- |getbufoneline()|
  3118. ---
  3119. --- @param lnum integer|string
  3120. --- @param end_? nil|false
  3121. --- @return string
  3122. function vim.fn.getline(lnum, end_) end
  3123. --- @param lnum integer
  3124. --- @param end_ true|number|string|table
  3125. --- @return string|string[]
  3126. function vim.fn.getline(lnum, end_) end
  3127. --- Returns a |List| with all the entries in the location list for
  3128. --- window {nr}. {nr} can be the window number or the |window-ID|.
  3129. --- When {nr} is zero the current window is used.
  3130. ---
  3131. --- For a location list window, the displayed location list is
  3132. --- returned. For an invalid window number {nr}, an empty list is
  3133. --- returned. Otherwise, same as |getqflist()|.
  3134. ---
  3135. --- If the optional {what} dictionary argument is supplied, then
  3136. --- returns the items listed in {what} as a dictionary. Refer to
  3137. --- |getqflist()| for the supported items in {what}.
  3138. ---
  3139. --- In addition to the items supported by |getqflist()| in {what},
  3140. --- the following item is supported by |getloclist()|:
  3141. ---
  3142. --- filewinid id of the window used to display files
  3143. --- from the location list. This field is
  3144. --- applicable only when called from a
  3145. --- location list window. See
  3146. --- |location-list-file-window| for more
  3147. --- details.
  3148. ---
  3149. --- Returns a |Dictionary| with default values if there is no
  3150. --- location list for the window {nr}.
  3151. --- Returns an empty Dictionary if window {nr} does not exist.
  3152. ---
  3153. --- Examples (See also |getqflist-examples|): >vim
  3154. --- echo getloclist(3, {'all': 0})
  3155. --- echo getloclist(5, {'filewinid': 0})
  3156. --- <
  3157. ---
  3158. --- @param nr integer
  3159. --- @param what? table
  3160. --- @return any
  3161. function vim.fn.getloclist(nr, what) end
  3162. --- Without the {buf} argument returns a |List| with information
  3163. --- about all the global marks. |mark|
  3164. ---
  3165. --- If the optional {buf} argument is specified, returns the
  3166. --- local marks defined in buffer {buf}. For the use of {buf},
  3167. --- see |bufname()|. If {buf} is invalid, an empty list is
  3168. --- returned.
  3169. ---
  3170. --- Each item in the returned List is a |Dict| with the following:
  3171. --- mark name of the mark prefixed by "'"
  3172. --- pos a |List| with the position of the mark:
  3173. --- [bufnum, lnum, col, off]
  3174. --- Refer to |getpos()| for more information.
  3175. --- file file name
  3176. ---
  3177. --- Refer to |getpos()| for getting information about a specific
  3178. --- mark.
  3179. ---
  3180. --- @param buf? integer?
  3181. --- @return vim.fn.getmarklist.ret.item[]
  3182. function vim.fn.getmarklist(buf) end
  3183. --- Returns a |List| with all matches previously defined for the
  3184. --- current window by |matchadd()| and the |:match| commands.
  3185. --- |getmatches()| is useful in combination with |setmatches()|,
  3186. --- as |setmatches()| can restore a list of matches saved by
  3187. --- |getmatches()|.
  3188. --- If {win} is specified, use the window with this number or
  3189. --- window ID instead of the current window. If {win} is invalid,
  3190. --- an empty list is returned.
  3191. --- Example: >vim
  3192. --- echo getmatches()
  3193. --- < >
  3194. --- [{"group": "MyGroup1", "pattern": "TODO",
  3195. --- "priority": 10, "id": 1}, {"group": "MyGroup2",
  3196. --- "pattern": "FIXME", "priority": 10, "id": 2}]
  3197. --- < >vim
  3198. --- let m = getmatches()
  3199. --- call clearmatches()
  3200. --- echo getmatches()
  3201. --- < >
  3202. --- []
  3203. --- < >vim
  3204. --- call setmatches(m)
  3205. --- echo getmatches()
  3206. --- < >
  3207. --- [{"group": "MyGroup1", "pattern": "TODO",
  3208. --- "priority": 10, "id": 1}, {"group": "MyGroup2",
  3209. --- "pattern": "FIXME", "priority": 10, "id": 2}]
  3210. --- < >vim
  3211. --- unlet m
  3212. --- <
  3213. ---
  3214. --- @param win? integer
  3215. --- @return any
  3216. function vim.fn.getmatches(win) end
  3217. --- Returns a |Dictionary| with the last known position of the
  3218. --- mouse. This can be used in a mapping for a mouse click. The
  3219. --- items are:
  3220. --- screenrow screen row
  3221. --- screencol screen column
  3222. --- winid Window ID of the click
  3223. --- winrow row inside "winid"
  3224. --- wincol column inside "winid"
  3225. --- line text line inside "winid"
  3226. --- column text column inside "winid"
  3227. --- coladd offset (in screen columns) from the
  3228. --- start of the clicked char
  3229. --- All numbers are 1-based.
  3230. ---
  3231. --- If not over a window, e.g. when in the command line, then only
  3232. --- "screenrow" and "screencol" are valid, the others are zero.
  3233. ---
  3234. --- When on the status line below a window or the vertical
  3235. --- separator right of a window, the "line" and "column" values
  3236. --- are zero.
  3237. ---
  3238. --- When the position is after the text then "column" is the
  3239. --- length of the text in bytes plus one.
  3240. ---
  3241. --- If the mouse is over a focusable floating window then that
  3242. --- window is used.
  3243. ---
  3244. --- When using |getchar()| the Vim variables |v:mouse_lnum|,
  3245. --- |v:mouse_col| and |v:mouse_winid| also provide these values.
  3246. ---
  3247. --- @return vim.fn.getmousepos.ret
  3248. function vim.fn.getmousepos() end
  3249. --- Return a Number which is the process ID of the Vim process.
  3250. --- This is a unique number, until Vim exits.
  3251. ---
  3252. --- @return integer
  3253. function vim.fn.getpid() end
  3254. --- Get the position for String {expr}.
  3255. --- The accepted values for {expr} are:
  3256. --- . The cursor position.
  3257. --- $ The last line in the current buffer.
  3258. --- 'x Position of mark x (if the mark is not set, 0 is
  3259. --- returned for all values).
  3260. --- w0 First line visible in current window (one if the
  3261. --- display isn't updated, e.g. in silent Ex mode).
  3262. --- w$ Last line visible in current window (this is one
  3263. --- less than "w0" if no lines are visible).
  3264. --- v When not in Visual mode, returns the cursor
  3265. --- position. In Visual mode, returns the other end
  3266. --- of the Visual area. A good way to think about
  3267. --- this is that in Visual mode "v" and "." complement
  3268. --- each other. While "." refers to the cursor
  3269. --- position, "v" refers to where |v_o| would move the
  3270. --- cursor. As a result, you can use "v" and "."
  3271. --- together to work on all of a selection in
  3272. --- characterwise Visual mode. If the cursor is at
  3273. --- the end of a characterwise Visual area, "v" refers
  3274. --- to the start of the same Visual area. And if the
  3275. --- cursor is at the start of a characterwise Visual
  3276. --- area, "v" refers to the end of the same Visual
  3277. --- area. "v" differs from |'<| and |'>| in that it's
  3278. --- updated right away.
  3279. --- Note that a mark in another file can be used. The line number
  3280. --- then applies to another buffer.
  3281. ---
  3282. --- The result is a |List| with four numbers:
  3283. --- [bufnum, lnum, col, off]
  3284. --- "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  3285. --- is the buffer number of the mark.
  3286. --- "lnum" and "col" are the position in the buffer. The first
  3287. --- column is 1.
  3288. --- The "off" number is zero, unless 'virtualedit' is used. Then
  3289. --- it is the offset in screen columns from the start of the
  3290. --- character. E.g., a position within a <Tab> or after the last
  3291. --- character.
  3292. ---
  3293. --- For getting the cursor position see |getcurpos()|.
  3294. --- The column number in the returned List is the byte position
  3295. --- within the line. To get the character position in the line,
  3296. --- use |getcharpos()|.
  3297. ---
  3298. --- Note that for '< and '> Visual mode matters: when it is "V"
  3299. --- (visual line mode) the column of '< is zero and the column of
  3300. --- '> is a large number equal to |v:maxcol|.
  3301. --- A very large column number equal to |v:maxcol| can be returned,
  3302. --- in which case it means "after the end of the line".
  3303. --- If {expr} is invalid, returns a list with all zeros.
  3304. ---
  3305. --- This can be used to save and restore the position of a mark: >vim
  3306. --- let save_a_mark = getpos("'a")
  3307. --- " ...
  3308. --- call setpos("'a", save_a_mark)
  3309. --- <
  3310. --- Also see |getcharpos()|, |getcurpos()| and |setpos()|.
  3311. ---
  3312. --- @param expr string
  3313. --- @return integer[]
  3314. function vim.fn.getpos(expr) end
  3315. --- Returns a |List| with all the current quickfix errors. Each
  3316. --- list item is a dictionary with these entries:
  3317. --- bufnr number of buffer that has the file name, use
  3318. --- bufname() to get the name
  3319. --- module module name
  3320. --- lnum line number in the buffer (first line is 1)
  3321. --- end_lnum
  3322. --- end of line number if the item is multiline
  3323. --- col column number (first column is 1)
  3324. --- end_col end of column number if the item has range
  3325. --- vcol |TRUE|: "col" is visual column
  3326. --- |FALSE|: "col" is byte index
  3327. --- nr error number
  3328. --- pattern search pattern used to locate the error
  3329. --- text description of the error
  3330. --- type type of the error, 'E', '1', etc.
  3331. --- valid |TRUE|: recognized error message
  3332. --- user_data
  3333. --- custom data associated with the item, can be
  3334. --- any type.
  3335. ---
  3336. --- When there is no error list or it's empty, an empty list is
  3337. --- returned. Quickfix list entries with a non-existing buffer
  3338. --- number are returned with "bufnr" set to zero (Note: some
  3339. --- functions accept buffer number zero for the alternate buffer,
  3340. --- you may need to explicitly check for zero).
  3341. ---
  3342. --- Useful application: Find pattern matches in multiple files and
  3343. --- do something with them: >vim
  3344. --- vimgrep /theword/jg *.c
  3345. --- for d in getqflist()
  3346. --- echo bufname(d.bufnr) ':' d.lnum '=' d.text
  3347. --- endfor
  3348. --- <
  3349. --- If the optional {what} dictionary argument is supplied, then
  3350. --- returns only the items listed in {what} as a dictionary. The
  3351. --- following string items are supported in {what}:
  3352. --- changedtick get the total number of changes made
  3353. --- to the list |quickfix-changedtick|
  3354. --- context get the |quickfix-context|
  3355. --- efm errorformat to use when parsing "lines". If
  3356. --- not present, then the 'errorformat' option
  3357. --- value is used.
  3358. --- id get information for the quickfix list with
  3359. --- |quickfix-ID|; zero means the id for the
  3360. --- current list or the list specified by "nr"
  3361. --- idx get information for the quickfix entry at this
  3362. --- index in the list specified by "id" or "nr".
  3363. --- If set to zero, then uses the current entry.
  3364. --- See |quickfix-index|
  3365. --- items quickfix list entries
  3366. --- lines parse a list of lines using 'efm' and return
  3367. --- the resulting entries. Only a |List| type is
  3368. --- accepted. The current quickfix list is not
  3369. --- modified. See |quickfix-parse|.
  3370. --- nr get information for this quickfix list; zero
  3371. --- means the current quickfix list and "$" means
  3372. --- the last quickfix list
  3373. --- qfbufnr number of the buffer displayed in the quickfix
  3374. --- window. Returns 0 if the quickfix buffer is
  3375. --- not present. See |quickfix-buffer|.
  3376. --- size number of entries in the quickfix list
  3377. --- title get the list title |quickfix-title|
  3378. --- winid get the quickfix |window-ID|
  3379. --- all all of the above quickfix properties
  3380. --- Non-string items in {what} are ignored. To get the value of a
  3381. --- particular item, set it to zero.
  3382. --- If "nr" is not present then the current quickfix list is used.
  3383. --- If both "nr" and a non-zero "id" are specified, then the list
  3384. --- specified by "id" is used.
  3385. --- To get the number of lists in the quickfix stack, set "nr" to
  3386. --- "$" in {what}. The "nr" value in the returned dictionary
  3387. --- contains the quickfix stack size.
  3388. --- When "lines" is specified, all the other items except "efm"
  3389. --- are ignored. The returned dictionary contains the entry
  3390. --- "items" with the list of entries.
  3391. ---
  3392. --- The returned dictionary contains the following entries:
  3393. --- changedtick total number of changes made to the
  3394. --- list |quickfix-changedtick|
  3395. --- context quickfix list context. See |quickfix-context|
  3396. --- If not present, set to "".
  3397. --- id quickfix list ID |quickfix-ID|. If not
  3398. --- present, set to 0.
  3399. --- idx index of the quickfix entry in the list. If not
  3400. --- present, set to 0.
  3401. --- items quickfix list entries. If not present, set to
  3402. --- an empty list.
  3403. --- nr quickfix list number. If not present, set to 0
  3404. --- qfbufnr number of the buffer displayed in the quickfix
  3405. --- window. If not present, set to 0.
  3406. --- size number of entries in the quickfix list. If not
  3407. --- present, set to 0.
  3408. --- title quickfix list title text. If not present, set
  3409. --- to "".
  3410. --- winid quickfix |window-ID|. If not present, set to 0
  3411. ---
  3412. --- Examples (See also |getqflist-examples|): >vim
  3413. --- echo getqflist({'all': 1})
  3414. --- echo getqflist({'nr': 2, 'title': 1})
  3415. --- echo getqflist({'lines' : ["F1:10:L10"]})
  3416. --- <
  3417. ---
  3418. --- @param what? table
  3419. --- @return any
  3420. function vim.fn.getqflist(what) end
  3421. --- The result is a String, which is the contents of register
  3422. --- {regname}. Example: >vim
  3423. --- let cliptext = getreg('*')
  3424. --- <When register {regname} was not set the result is an empty
  3425. --- string.
  3426. --- The {regname} argument must be a string.
  3427. ---
  3428. --- getreg('=') returns the last evaluated value of the expression
  3429. --- register. (For use in maps.)
  3430. --- getreg('=', 1) returns the expression itself, so that it can
  3431. --- be restored with |setreg()|. For other registers the extra
  3432. --- argument is ignored, thus you can always give it.
  3433. ---
  3434. --- If {list} is present and |TRUE|, the result type is changed
  3435. --- to |List|. Each list item is one text line. Use it if you care
  3436. --- about zero bytes possibly present inside register: without
  3437. --- third argument both NLs and zero bytes are represented as NLs
  3438. --- (see |NL-used-for-Nul|).
  3439. --- When the register was not set an empty list is returned.
  3440. ---
  3441. --- If {regname} is not specified, |v:register| is used.
  3442. ---
  3443. --- @param regname? string
  3444. --- @param list? nil|false
  3445. --- @return string
  3446. function vim.fn.getreg(regname, list) end
  3447. --- @param regname string
  3448. --- @param list true|number|string|table
  3449. --- @return string|string[]
  3450. function vim.fn.getreg(regname, list) end
  3451. --- Returns detailed information about register {regname} as a
  3452. --- Dictionary with the following entries:
  3453. --- regcontents List of lines contained in register
  3454. --- {regname}, like
  3455. --- getreg({regname}, 1, 1).
  3456. --- regtype the type of register {regname}, as in
  3457. --- |getregtype()|.
  3458. --- isunnamed Boolean flag, v:true if this register
  3459. --- is currently pointed to by the unnamed
  3460. --- register.
  3461. --- points_to for the unnamed register, gives the
  3462. --- single letter name of the register
  3463. --- currently pointed to (see |quotequote|).
  3464. --- For example, after deleting a line
  3465. --- with `dd`, this field will be "1",
  3466. --- which is the register that got the
  3467. --- deleted text.
  3468. ---
  3469. --- The {regname} argument is a string. If {regname} is invalid
  3470. --- or not set, an empty Dictionary will be returned.
  3471. --- If {regname} is not specified, |v:register| is used.
  3472. --- The returned Dictionary can be passed to |setreg()|.
  3473. ---
  3474. --- @param regname? string
  3475. --- @return table
  3476. function vim.fn.getreginfo(regname) end
  3477. --- Returns the list of strings from {pos1} to {pos2} from a
  3478. --- buffer.
  3479. ---
  3480. --- {pos1} and {pos2} must both be |List|s with four numbers.
  3481. --- See |getpos()| for the format of the list. It's possible
  3482. --- to specify positions from a different buffer, but please
  3483. --- note the limitations at |getregion-notes|.
  3484. ---
  3485. --- The optional argument {opts} is a Dict and supports the
  3486. --- following items:
  3487. ---
  3488. --- type Specify the region's selection type.
  3489. --- See |getregtype()| for possible values,
  3490. --- except that the width can be omitted
  3491. --- and an empty string cannot be used.
  3492. --- (default: "v")
  3493. ---
  3494. --- exclusive If |TRUE|, use exclusive selection
  3495. --- for the end position.
  3496. --- (default: follow 'selection')
  3497. ---
  3498. --- You can get the last selection type by |visualmode()|.
  3499. --- If Visual mode is active, use |mode()| to get the Visual mode
  3500. --- (e.g., in a |:vmap|).
  3501. --- This function is useful to get text starting and ending in
  3502. --- different columns, such as a |charwise-visual| selection.
  3503. ---
  3504. --- *getregion-notes*
  3505. --- Note that:
  3506. --- - Order of {pos1} and {pos2} doesn't matter, it will always
  3507. --- return content from the upper left position to the lower
  3508. --- right position.
  3509. --- - If 'virtualedit' is enabled and the region is past the end
  3510. --- of the lines, resulting lines are padded with spaces.
  3511. --- - If the region is blockwise and it starts or ends in the
  3512. --- middle of a multi-cell character, it is not included but
  3513. --- its selected part is substituted with spaces.
  3514. --- - If {pos1} and {pos2} are not in the same buffer, an empty
  3515. --- list is returned.
  3516. --- - {pos1} and {pos2} must belong to a |bufloaded()| buffer.
  3517. --- - It is evaluated in current window context, which makes a
  3518. --- difference if the buffer is displayed in a window with
  3519. --- different 'virtualedit' or 'list' values.
  3520. ---
  3521. --- Examples: >vim
  3522. --- xnoremap <CR>
  3523. --- \ <Cmd>echom getregion(
  3524. --- \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
  3525. --- <
  3526. ---
  3527. --- @param pos1 table
  3528. --- @param pos2 table
  3529. --- @param opts? table
  3530. --- @return string[]
  3531. function vim.fn.getregion(pos1, pos2, opts) end
  3532. --- Same as |getregion()|, but returns a list of positions
  3533. --- describing the buffer text segments bound by {pos1} and
  3534. --- {pos2}.
  3535. --- The segments are a pair of positions for every line: >
  3536. --- [[{start_pos}, {end_pos}], ...]
  3537. --- <
  3538. --- The position is a |List| with four numbers:
  3539. --- [bufnum, lnum, col, off]
  3540. --- "bufnum" is the buffer number.
  3541. --- "lnum" and "col" are the position in the buffer. The first
  3542. --- column is 1.
  3543. --- If the "off" number of a starting position is non-zero, it is
  3544. --- the offset in screen columns from the start of the character.
  3545. --- E.g., a position within a <Tab> or after the last character.
  3546. --- If the "off" number of an ending position is non-zero, it is
  3547. --- the offset of the character's first cell not included in the
  3548. --- selection, otherwise all its cells are included.
  3549. ---
  3550. --- Apart from the options supported by |getregion()|, {opts} also
  3551. --- supports the following:
  3552. ---
  3553. --- eol If |TRUE|, indicate positions beyond
  3554. --- the end of a line with "col" values
  3555. --- one more than the length of the line.
  3556. --- If |FALSE|, positions are limited
  3557. --- within their lines, and if a line is
  3558. --- empty or the selection is entirely
  3559. --- beyond the end of a line, a "col"
  3560. --- value of 0 is used for both positions.
  3561. --- (default: |FALSE|)
  3562. ---
  3563. --- @param pos1 table
  3564. --- @param pos2 table
  3565. --- @param opts? table
  3566. --- @return integer[][][]
  3567. function vim.fn.getregionpos(pos1, pos2, opts) end
  3568. --- The result is a String, which is type of register {regname}.
  3569. --- The value will be one of:
  3570. --- "v" for |charwise| text
  3571. --- "V" for |linewise| text
  3572. --- "<CTRL-V>{width}" for |blockwise-visual| text
  3573. --- "" for an empty or unknown register
  3574. --- <CTRL-V> is one character with value 0x16.
  3575. --- The {regname} argument is a string. If {regname} is not
  3576. --- specified, |v:register| is used.
  3577. ---
  3578. --- @param regname? string
  3579. --- @return string
  3580. function vim.fn.getregtype(regname) end
  3581. --- Returns a |List| with information about all the sourced Vim
  3582. --- scripts in the order they were sourced, like what
  3583. --- `:scriptnames` shows.
  3584. ---
  3585. --- The optional Dict argument {opts} supports the following
  3586. --- optional items:
  3587. --- name Script name match pattern. If specified,
  3588. --- and "sid" is not specified, information about
  3589. --- scripts with a name that match the pattern
  3590. --- "name" are returned.
  3591. --- sid Script ID |<SID>|. If specified, only
  3592. --- information about the script with ID "sid" is
  3593. --- returned and "name" is ignored.
  3594. ---
  3595. --- Each item in the returned List is a |Dict| with the following
  3596. --- items:
  3597. --- autoload Always set to FALSE.
  3598. --- functions List of script-local function names defined in
  3599. --- the script. Present only when a particular
  3600. --- script is specified using the "sid" item in
  3601. --- {opts}.
  3602. --- name Vim script file name.
  3603. --- sid Script ID |<SID>|.
  3604. --- variables A dictionary with the script-local variables.
  3605. --- Present only when a particular script is
  3606. --- specified using the "sid" item in {opts}.
  3607. --- Note that this is a copy, the value of
  3608. --- script-local variables cannot be changed using
  3609. --- this dictionary.
  3610. --- version Vim script version, always 1
  3611. ---
  3612. --- Examples: >vim
  3613. --- echo getscriptinfo({'name': 'myscript'})
  3614. --- echo getscriptinfo({'sid': 15})[0].variables
  3615. --- <
  3616. ---
  3617. --- @param opts? table
  3618. --- @return vim.fn.getscriptinfo.ret[]
  3619. function vim.fn.getscriptinfo(opts) end
  3620. --- Returns the current stack trace of Vim scripts.
  3621. --- Stack trace is a |List|, of which each item is a |Dictionary|
  3622. --- with the following items:
  3623. --- funcref The funcref if the stack is at a function,
  3624. --- otherwise this item is omitted.
  3625. --- event The string of the event description if the
  3626. --- stack is at an autocmd event, otherwise this
  3627. --- item is omitted.
  3628. --- lnum The line number in the script on the stack.
  3629. --- filepath The file path of the script on the stack.
  3630. ---
  3631. --- @return table[]
  3632. function vim.fn.getstacktrace() end
  3633. --- If {tabnr} is not specified, then information about all the
  3634. --- tab pages is returned as a |List|. Each List item is a
  3635. --- |Dictionary|. Otherwise, {tabnr} specifies the tab page
  3636. --- number and information about that one is returned. If the tab
  3637. --- page does not exist an empty List is returned.
  3638. ---
  3639. --- Each List item is a |Dictionary| with the following entries:
  3640. --- tabnr tab page number.
  3641. --- variables a reference to the dictionary with
  3642. --- tabpage-local variables
  3643. --- windows List of |window-ID|s in the tab page.
  3644. ---
  3645. --- @param tabnr? integer
  3646. --- @return any
  3647. function vim.fn.gettabinfo(tabnr) end
  3648. --- Get the value of a tab-local variable {varname} in tab page
  3649. --- {tabnr}. |t:var|
  3650. --- Tabs are numbered starting with one.
  3651. --- The {varname} argument is a string. When {varname} is empty a
  3652. --- dictionary with all tab-local variables is returned.
  3653. --- Note that the name without "t:" must be used.
  3654. --- When the tab or variable doesn't exist {def} or an empty
  3655. --- string is returned, there is no error message.
  3656. ---
  3657. --- @param tabnr integer
  3658. --- @param varname string
  3659. --- @param def? any
  3660. --- @return any
  3661. function vim.fn.gettabvar(tabnr, varname, def) end
  3662. --- Get the value of window-local variable {varname} in window
  3663. --- {winnr} in tab page {tabnr}.
  3664. --- The {varname} argument is a string. When {varname} is empty a
  3665. --- dictionary with all window-local variables is returned.
  3666. --- When {varname} is equal to "&" get the values of all
  3667. --- window-local options in a |Dictionary|.
  3668. --- Otherwise, when {varname} starts with "&" get the value of a
  3669. --- window-local option.
  3670. --- Note that {varname} must be the name without "w:".
  3671. --- Tabs are numbered starting with one. For the current tabpage
  3672. --- use |getwinvar()|.
  3673. --- {winnr} can be the window number or the |window-ID|.
  3674. --- When {winnr} is zero the current window is used.
  3675. --- This also works for a global option, buffer-local option and
  3676. --- window-local option, but it doesn't work for a global variable
  3677. --- or buffer-local variable.
  3678. --- When the tab, window or variable doesn't exist {def} or an
  3679. --- empty string is returned, there is no error message.
  3680. --- Examples: >vim
  3681. --- let list_is_on = gettabwinvar(1, 2, '&list')
  3682. --- echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
  3683. --- <
  3684. --- To obtain all window-local variables use: >vim
  3685. --- gettabwinvar({tabnr}, {winnr}, '&')
  3686. --- <
  3687. ---
  3688. --- @param tabnr integer
  3689. --- @param winnr integer
  3690. --- @param varname string
  3691. --- @param def? any
  3692. --- @return any
  3693. function vim.fn.gettabwinvar(tabnr, winnr, varname, def) end
  3694. --- The result is a Dict, which is the tag stack of window {winnr}.
  3695. --- {winnr} can be the window number or the |window-ID|.
  3696. --- When {winnr} is not specified, the current window is used.
  3697. --- When window {winnr} doesn't exist, an empty Dict is returned.
  3698. ---
  3699. --- The returned dictionary contains the following entries:
  3700. --- curidx Current index in the stack. When at
  3701. --- top of the stack, set to (length + 1).
  3702. --- Index of bottom of the stack is 1.
  3703. --- items List of items in the stack. Each item
  3704. --- is a dictionary containing the
  3705. --- entries described below.
  3706. --- length Number of entries in the stack.
  3707. ---
  3708. --- Each item in the stack is a dictionary with the following
  3709. --- entries:
  3710. --- bufnr buffer number of the current jump
  3711. --- from cursor position before the tag jump.
  3712. --- See |getpos()| for the format of the
  3713. --- returned list.
  3714. --- matchnr current matching tag number. Used when
  3715. --- multiple matching tags are found for a
  3716. --- name.
  3717. --- tagname name of the tag
  3718. ---
  3719. --- See |tagstack| for more information about the tag stack.
  3720. ---
  3721. --- @param winnr? integer
  3722. --- @return any
  3723. function vim.fn.gettagstack(winnr) end
  3724. --- Translate String {text} if possible.
  3725. --- This is mainly for use in the distributed Vim scripts. When
  3726. --- generating message translations the {text} is extracted by
  3727. --- xgettext, the translator can add the translated message in the
  3728. --- .po file and Vim will lookup the translation when gettext() is
  3729. --- called.
  3730. --- For {text} double quoted strings are preferred, because
  3731. --- xgettext does not understand escaping in single quoted
  3732. --- strings.
  3733. ---
  3734. --- @param text string
  3735. --- @return string
  3736. function vim.fn.gettext(text) end
  3737. --- Returns information about windows as a |List| with Dictionaries.
  3738. ---
  3739. --- If {winid} is given Information about the window with that ID
  3740. --- is returned, as a |List| with one item. If the window does not
  3741. --- exist the result is an empty list.
  3742. ---
  3743. --- Without {winid} information about all the windows in all the
  3744. --- tab pages is returned.
  3745. ---
  3746. --- Each List item is a |Dictionary| with the following entries:
  3747. --- botline last complete displayed buffer line
  3748. --- bufnr number of buffer in the window
  3749. --- height window height (excluding winbar)
  3750. --- leftcol first column displayed; only used when
  3751. --- 'wrap' is off
  3752. --- loclist 1 if showing a location list
  3753. --- quickfix 1 if quickfix or location list window
  3754. --- terminal 1 if a terminal window
  3755. --- tabnr tab page number
  3756. --- topline first displayed buffer line
  3757. --- variables a reference to the dictionary with
  3758. --- window-local variables
  3759. --- width window width
  3760. --- winbar 1 if the window has a toolbar, 0
  3761. --- otherwise
  3762. --- wincol leftmost screen column of the window;
  3763. --- "col" from |win_screenpos()|
  3764. --- textoff number of columns occupied by any
  3765. --- 'foldcolumn', 'signcolumn' and line
  3766. --- number in front of the text
  3767. --- winid |window-ID|
  3768. --- winnr window number
  3769. --- winrow topmost screen line of the window;
  3770. --- "row" from |win_screenpos()|
  3771. ---
  3772. --- @param winid? integer
  3773. --- @return vim.fn.getwininfo.ret.item[]
  3774. function vim.fn.getwininfo(winid) end
  3775. --- The result is a |List| with two numbers, the result of
  3776. --- |getwinposx()| and |getwinposy()| combined:
  3777. --- [x-pos, y-pos]
  3778. --- {timeout} can be used to specify how long to wait in msec for
  3779. --- a response from the terminal. When omitted 100 msec is used.
  3780. ---
  3781. --- Use a longer time for a remote terminal.
  3782. --- When using a value less than 10 and no response is received
  3783. --- within that time, a previously reported position is returned,
  3784. --- if available. This can be used to poll for the position and
  3785. --- do some work in the meantime: >vim
  3786. --- while 1
  3787. --- let res = getwinpos(1)
  3788. --- if res[0] >= 0
  3789. --- break
  3790. --- endif
  3791. --- " Do some work here
  3792. --- endwhile
  3793. --- <
  3794. ---
  3795. --- @param timeout? integer
  3796. --- @return any
  3797. function vim.fn.getwinpos(timeout) end
  3798. --- The result is a Number, which is the X coordinate in pixels of
  3799. --- the left hand side of the GUI Vim window. The result will be
  3800. --- -1 if the information is not available.
  3801. --- The value can be used with `:winpos`.
  3802. ---
  3803. --- @return integer
  3804. function vim.fn.getwinposx() end
  3805. --- The result is a Number, which is the Y coordinate in pixels of
  3806. --- the top of the GUI Vim window. The result will be -1 if the
  3807. --- information is not available.
  3808. --- The value can be used with `:winpos`.
  3809. ---
  3810. --- @return integer
  3811. function vim.fn.getwinposy() end
  3812. --- Like |gettabwinvar()| for the current tabpage.
  3813. --- Examples: >vim
  3814. --- let list_is_on = getwinvar(2, '&list')
  3815. --- echo "myvar = " .. getwinvar(1, 'myvar')
  3816. ---
  3817. --- @param winnr integer
  3818. --- @param varname string
  3819. --- @param def? any
  3820. --- @return any
  3821. function vim.fn.getwinvar(winnr, varname, def) end
  3822. --- Expand the file wildcards in {expr}. See |wildcards| for the
  3823. --- use of special characters.
  3824. ---
  3825. --- Unless the optional {nosuf} argument is given and is |TRUE|,
  3826. --- the 'suffixes' and 'wildignore' options apply: Names matching
  3827. --- one of the patterns in 'wildignore' will be skipped and
  3828. --- 'suffixes' affect the ordering of matches.
  3829. --- 'wildignorecase' always applies.
  3830. ---
  3831. --- When {list} is present and it is |TRUE| the result is a |List|
  3832. --- with all matching files. The advantage of using a List is,
  3833. --- you also get filenames containing newlines correctly.
  3834. --- Otherwise the result is a String and when there are several
  3835. --- matches, they are separated by <NL> characters.
  3836. ---
  3837. --- If the expansion fails, the result is an empty String or List.
  3838. ---
  3839. --- You can also use |readdir()| if you need to do complicated
  3840. --- things, such as limiting the number of matches.
  3841. ---
  3842. --- A name for a non-existing file is not included. A symbolic
  3843. --- link is only included if it points to an existing file.
  3844. --- However, when the {alllinks} argument is present and it is
  3845. --- |TRUE| then all symbolic links are included.
  3846. ---
  3847. --- For most systems backticks can be used to get files names from
  3848. --- any external command. Example: >vim
  3849. --- let tagfiles = glob("`find . -name tags -print`")
  3850. --- let &tags = substitute(tagfiles, "\n", ",", "g")
  3851. --- <The result of the program inside the backticks should be one
  3852. --- item per line. Spaces inside an item are allowed.
  3853. ---
  3854. --- See |expand()| for expanding special Vim variables. See
  3855. --- |system()| for getting the raw output of an external command.
  3856. ---
  3857. --- @param expr string
  3858. --- @param nosuf? boolean
  3859. --- @param list? boolean
  3860. --- @param alllinks? boolean
  3861. --- @return any
  3862. function vim.fn.glob(expr, nosuf, list, alllinks) end
  3863. --- Convert a file pattern, as used by glob(), into a search
  3864. --- pattern. The result can be used to match with a string that
  3865. --- is a file name. E.g. >vim
  3866. --- if filename =~ glob2regpat('Make*.mak')
  3867. --- " ...
  3868. --- endif
  3869. --- <This is equivalent to: >vim
  3870. --- if filename =~ '^Make.*\.mak$'
  3871. --- " ...
  3872. --- endif
  3873. --- <When {string} is an empty string the result is "^$", match an
  3874. --- empty string.
  3875. --- Note that the result depends on the system. On MS-Windows
  3876. --- a backslash usually means a path separator.
  3877. ---
  3878. --- @param string string
  3879. --- @return string
  3880. function vim.fn.glob2regpat(string) end
  3881. --- Perform glob() for String {expr} on all directories in {path}
  3882. --- and concatenate the results. Example: >vim
  3883. --- echo globpath(&rtp, "syntax/c.vim")
  3884. --- <
  3885. --- {path} is a comma-separated list of directory names. Each
  3886. --- directory name is prepended to {expr} and expanded like with
  3887. --- |glob()|. A path separator is inserted when needed.
  3888. --- To add a comma inside a directory name escape it with a
  3889. --- backslash. Note that on MS-Windows a directory may have a
  3890. --- trailing backslash, remove it if you put a comma after it.
  3891. --- If the expansion fails for one of the directories, there is no
  3892. --- error message.
  3893. ---
  3894. --- Unless the optional {nosuf} argument is given and is |TRUE|,
  3895. --- the 'suffixes' and 'wildignore' options apply: Names matching
  3896. --- one of the patterns in 'wildignore' will be skipped and
  3897. --- 'suffixes' affect the ordering of matches.
  3898. ---
  3899. --- When {list} is present and it is |TRUE| the result is a |List|
  3900. --- with all matching files. The advantage of using a List is, you
  3901. --- also get filenames containing newlines correctly. Otherwise
  3902. --- the result is a String and when there are several matches,
  3903. --- they are separated by <NL> characters. Example: >vim
  3904. --- echo globpath(&rtp, "syntax/c.vim", 0, 1)
  3905. --- <
  3906. --- {allinks} is used as with |glob()|.
  3907. ---
  3908. --- The "**" item can be used to search in a directory tree.
  3909. --- For example, to find all "README.txt" files in the directories
  3910. --- in 'runtimepath' and below: >vim
  3911. --- echo globpath(&rtp, "**/README.txt")
  3912. --- <Upwards search and limiting the depth of "**" is not
  3913. --- supported, thus using 'path' will not always work properly.
  3914. ---
  3915. --- @param path string
  3916. --- @param expr string
  3917. --- @param nosuf? boolean
  3918. --- @param list? boolean
  3919. --- @param allinks? boolean
  3920. --- @return any
  3921. function vim.fn.globpath(path, expr, nosuf, list, allinks) end
  3922. --- Returns 1 if {feature} is supported, 0 otherwise. The
  3923. --- {feature} argument is a feature name like "nvim-0.2.1" or
  3924. --- "win32", see below. See also |exists()|.
  3925. ---
  3926. --- To get the system name use |vim.uv|.os_uname() in Lua: >lua
  3927. --- print(vim.uv.os_uname().sysname)
  3928. ---
  3929. --- <If the code has a syntax error then Vimscript may skip the
  3930. --- rest of the line. Put |:if| and |:endif| on separate lines to
  3931. --- avoid the syntax error: >vim
  3932. --- if has('feature')
  3933. --- let x = this_breaks_without_the_feature()
  3934. --- endif
  3935. --- <
  3936. --- Vim's compile-time feature-names (prefixed with "+") are not
  3937. --- recognized because Nvim is always compiled with all possible
  3938. --- features. |feature-compile|
  3939. ---
  3940. --- Feature names can be:
  3941. --- 1. Nvim version. For example the "nvim-0.2.1" feature means
  3942. --- that Nvim is version 0.2.1 or later: >vim
  3943. --- if has("nvim-0.2.1")
  3944. --- " ...
  3945. --- endif
  3946. ---
  3947. --- <2. Runtime condition or other pseudo-feature. For example the
  3948. --- "win32" feature checks if the current system is Windows: >vim
  3949. --- if has("win32")
  3950. --- " ...
  3951. --- endif
  3952. --- < *feature-list*
  3953. --- List of supported pseudo-feature names:
  3954. --- acl |ACL| support.
  3955. --- bsd BSD system (not macOS, use "mac" for that).
  3956. --- clipboard |clipboard| provider is available.
  3957. --- fname_case Case in file names matters (for Darwin and MS-Windows
  3958. --- this is not present).
  3959. --- gui_running Nvim has a GUI.
  3960. --- hurd GNU/Hurd system.
  3961. --- iconv Can use |iconv()| for conversion.
  3962. --- linux Linux system.
  3963. --- mac MacOS system.
  3964. --- nvim This is Nvim.
  3965. --- python3 Legacy Vim |python3| interface. |has-python|
  3966. --- pythonx Legacy Vim |python_x| interface. |has-pythonx|
  3967. --- sun SunOS system.
  3968. --- ttyin input is a terminal (tty).
  3969. --- ttyout output is a terminal (tty).
  3970. --- unix Unix system.
  3971. --- *vim_starting* True during |startup|.
  3972. --- win32 Windows system (32 or 64 bit).
  3973. --- win64 Windows system (64 bit).
  3974. --- wsl WSL (Windows Subsystem for Linux) system.
  3975. ---
  3976. --- *has-patch*
  3977. --- 3. Vim patch. For example the "patch123" feature means that
  3978. --- Vim patch 123 at the current |v:version| was included: >vim
  3979. --- if v:version > 602 || v:version == 602 && has("patch148")
  3980. --- " ...
  3981. --- endif
  3982. ---
  3983. --- <4. Vim version. For example the "patch-7.4.237" feature means
  3984. --- that Nvim is Vim-compatible to version 7.4.237 or later. >vim
  3985. --- if has("patch-7.4.237")
  3986. --- " ...
  3987. --- endif
  3988. --- <
  3989. ---
  3990. --- @param feature string
  3991. --- @return 0|1
  3992. function vim.fn.has(feature) end
  3993. --- The result is a Number, which is TRUE if |Dictionary| {dict}
  3994. --- has an entry with key {key}. FALSE otherwise. The {key}
  3995. --- argument is a string.
  3996. ---
  3997. --- @param dict table
  3998. --- @param key string
  3999. --- @return 0|1
  4000. function vim.fn.has_key(dict, key) end
  4001. --- The result is a Number, which is 1 when the window has set a
  4002. --- local path via |:lcd| or when {winnr} is -1 and the tabpage
  4003. --- has set a local path via |:tcd|, otherwise 0.
  4004. ---
  4005. --- Tabs and windows are identified by their respective numbers,
  4006. --- 0 means current tab or window. Missing argument implies 0.
  4007. --- Thus the following are equivalent: >vim
  4008. --- echo haslocaldir()
  4009. --- echo haslocaldir(0)
  4010. --- echo haslocaldir(0, 0)
  4011. --- <With {winnr} use that window in the current tabpage.
  4012. --- With {winnr} and {tabnr} use the window in that tabpage.
  4013. --- {winnr} can be the window number or the |window-ID|.
  4014. --- If {winnr} is -1 it is ignored, only the tab is resolved.
  4015. --- Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  4016. ---
  4017. --- @param winnr? integer
  4018. --- @param tabnr? integer
  4019. --- @return 0|1
  4020. function vim.fn.haslocaldir(winnr, tabnr) end
  4021. --- The result is a Number, which is TRUE if there is a mapping
  4022. --- that contains {what} in somewhere in the rhs (what it is
  4023. --- mapped to) and this mapping exists in one of the modes
  4024. --- indicated by {mode}.
  4025. --- The arguments {what} and {mode} are strings.
  4026. --- When {abbr} is there and it is |TRUE| use abbreviations
  4027. --- instead of mappings. Don't forget to specify Insert and/or
  4028. --- Command-line mode.
  4029. --- Both the global mappings and the mappings local to the current
  4030. --- buffer are checked for a match.
  4031. --- If no matching mapping is found FALSE is returned.
  4032. --- The following characters are recognized in {mode}:
  4033. --- n Normal mode
  4034. --- v Visual and Select mode
  4035. --- x Visual mode
  4036. --- s Select mode
  4037. --- o Operator-pending mode
  4038. --- i Insert mode
  4039. --- l Language-Argument ("r", "f", "t", etc.)
  4040. --- c Command-line mode
  4041. --- When {mode} is omitted, "nvo" is used.
  4042. ---
  4043. --- This function is useful to check if a mapping already exists
  4044. --- to a function in a Vim script. Example: >vim
  4045. --- if !hasmapto('\ABCdoit')
  4046. --- map <Leader>d \ABCdoit
  4047. --- endif
  4048. --- <This installs the mapping to "\ABCdoit" only if there isn't
  4049. --- already a mapping to "\ABCdoit".
  4050. ---
  4051. --- @param what any
  4052. --- @param mode? string
  4053. --- @param abbr? boolean
  4054. --- @return 0|1
  4055. function vim.fn.hasmapto(what, mode, abbr) end
  4056. --- @deprecated
  4057. --- Obsolete name for |hlID()|.
  4058. ---
  4059. --- @param name string
  4060. --- @return any
  4061. function vim.fn.highlightID(name) end
  4062. --- @deprecated
  4063. --- Obsolete name for |hlexists()|.
  4064. ---
  4065. --- @param name string
  4066. --- @return any
  4067. function vim.fn.highlight_exists(name) end
  4068. --- Add the String {item} to the history {history} which can be
  4069. --- one of: *hist-names*
  4070. --- "cmd" or ":" command line history
  4071. --- "search" or "/" search pattern history
  4072. --- "expr" or "=" typed expression history
  4073. --- "input" or "\@" input line history
  4074. --- "debug" or ">" debug command history
  4075. --- empty the current or last used history
  4076. --- The {history} string does not need to be the whole name, one
  4077. --- character is sufficient.
  4078. --- If {item} does already exist in the history, it will be
  4079. --- shifted to become the newest entry.
  4080. --- The result is a Number: TRUE if the operation was successful,
  4081. --- otherwise FALSE is returned.
  4082. ---
  4083. --- Example: >vim
  4084. --- call histadd("input", strftime("%Y %b %d"))
  4085. --- let date=input("Enter date: ")
  4086. --- <This function is not available in the |sandbox|.
  4087. ---
  4088. --- @param history string
  4089. --- @param item any
  4090. --- @return 0|1
  4091. function vim.fn.histadd(history, item) end
  4092. --- Clear {history}, i.e. delete all its entries. See |hist-names|
  4093. --- for the possible values of {history}.
  4094. ---
  4095. --- If the parameter {item} evaluates to a String, it is used as a
  4096. --- regular expression. All entries matching that expression will
  4097. --- be removed from the history (if there are any).
  4098. --- Upper/lowercase must match, unless "\c" is used |/\c|.
  4099. --- If {item} evaluates to a Number, it will be interpreted as
  4100. --- an index, see |:history-indexing|. The respective entry will
  4101. --- be removed if it exists.
  4102. ---
  4103. --- The result is TRUE for a successful operation, otherwise FALSE
  4104. --- is returned.
  4105. ---
  4106. --- Examples:
  4107. --- Clear expression register history: >vim
  4108. --- call histdel("expr")
  4109. --- <
  4110. --- Remove all entries starting with "*" from the search history: >vim
  4111. --- call histdel("/", '^\*')
  4112. --- <
  4113. --- The following three are equivalent: >vim
  4114. --- call histdel("search", histnr("search"))
  4115. --- call histdel("search", -1)
  4116. --- call histdel("search", '^' .. histget("search", -1) .. '$')
  4117. --- <
  4118. --- To delete the last search pattern and use the last-but-one for
  4119. --- the "n" command and 'hlsearch': >vim
  4120. --- call histdel("search", -1)
  4121. --- let \@/ = histget("search", -1)
  4122. --- <
  4123. ---
  4124. --- @param history string
  4125. --- @param item? any
  4126. --- @return 0|1
  4127. function vim.fn.histdel(history, item) end
  4128. --- The result is a String, the entry with Number {index} from
  4129. --- {history}. See |hist-names| for the possible values of
  4130. --- {history}, and |:history-indexing| for {index}. If there is
  4131. --- no such entry, an empty String is returned. When {index} is
  4132. --- omitted, the most recent item from the history is used.
  4133. ---
  4134. --- Examples:
  4135. --- Redo the second last search from history. >vim
  4136. --- execute '/' .. histget("search", -2)
  4137. ---
  4138. --- <Define an Ex command ":H {num}" that supports re-execution of
  4139. --- the {num}th entry from the output of |:history|. >vim
  4140. --- command -nargs=1 H execute histget("cmd", 0+<args>)
  4141. --- <
  4142. ---
  4143. --- @param history string
  4144. --- @param index? integer|string
  4145. --- @return string
  4146. function vim.fn.histget(history, index) end
  4147. --- The result is the Number of the current entry in {history}.
  4148. --- See |hist-names| for the possible values of {history}.
  4149. --- If an error occurred, -1 is returned.
  4150. ---
  4151. --- Example: >vim
  4152. --- let inp_index = histnr("expr")
  4153. --- <
  4154. ---
  4155. --- @param history string
  4156. --- @return integer
  4157. function vim.fn.histnr(history) end
  4158. --- The result is a Number, which is the ID of the highlight group
  4159. --- with name {name}. When the highlight group doesn't exist,
  4160. --- zero is returned.
  4161. --- This can be used to retrieve information about the highlight
  4162. --- group. For example, to get the background color of the
  4163. --- "Comment" group: >vim
  4164. --- echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  4165. --- <
  4166. ---
  4167. --- @param name string
  4168. --- @return integer
  4169. function vim.fn.hlID(name) end
  4170. --- The result is a Number, which is TRUE if a highlight group
  4171. --- called {name} exists. This is when the group has been
  4172. --- defined in some way. Not necessarily when highlighting has
  4173. --- been defined for it, it may also have been used for a syntax
  4174. --- item.
  4175. ---
  4176. --- @param name string
  4177. --- @return 0|1
  4178. function vim.fn.hlexists(name) end
  4179. --- The result is a String, which is the name of the machine on
  4180. --- which Vim is currently running. Machine names greater than
  4181. --- 256 characters long are truncated.
  4182. ---
  4183. --- @return string
  4184. function vim.fn.hostname() end
  4185. --- The result is a String, which is the text {string} converted
  4186. --- from encoding {from} to encoding {to}.
  4187. --- When the conversion completely fails an empty string is
  4188. --- returned. When some characters could not be converted they
  4189. --- are replaced with "?".
  4190. --- The encoding names are whatever the iconv() library function
  4191. --- can accept, see ":!man 3 iconv".
  4192. --- Note that Vim uses UTF-8 for all Unicode encodings, conversion
  4193. --- from/to UCS-2 is automatically changed to use UTF-8. You
  4194. --- cannot use UCS-2 in a string anyway, because of the NUL bytes.
  4195. ---
  4196. --- @param string string
  4197. --- @param from string
  4198. --- @param to string
  4199. --- @return string
  4200. function vim.fn.iconv(string, from, to) end
  4201. --- Returns a |String| which is a unique identifier of the
  4202. --- container type (|List|, |Dict|, |Blob| and |Partial|). It is
  4203. --- guaranteed that for the mentioned types `id(v1) ==# id(v2)`
  4204. --- returns true iff `type(v1) == type(v2) && v1 is v2`.
  4205. --- Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
  4206. --- `v:_null_blob` have the same `id()` with different types
  4207. --- because they are internally represented as NULL pointers.
  4208. --- `id()` returns a hexadecimal representation of the pointers to
  4209. --- the containers (i.e. like `0x994a40`), same as `printf("%p",
  4210. --- {expr})`, but it is advised against counting on the exact
  4211. --- format of the return value.
  4212. ---
  4213. --- It is not guaranteed that `id(no_longer_existing_container)`
  4214. --- will not be equal to some other `id()`: new containers may
  4215. --- reuse identifiers of the garbage-collected ones.
  4216. ---
  4217. --- @param expr any
  4218. --- @return string
  4219. function vim.fn.id(expr) end
  4220. --- The result is a Number, which is indent of line {lnum} in the
  4221. --- current buffer. The indent is counted in spaces, the value
  4222. --- of 'tabstop' is relevant. {lnum} is used just like in
  4223. --- |getline()|.
  4224. --- When {lnum} is invalid -1 is returned.
  4225. ---
  4226. --- To get or set indent of lines in a string, see |vim.text.indent()|.
  4227. ---
  4228. --- @param lnum integer|string
  4229. --- @return integer
  4230. function vim.fn.indent(lnum) end
  4231. --- Find {expr} in {object} and return its index. See
  4232. --- |indexof()| for using a lambda to select the item.
  4233. ---
  4234. --- If {object} is a |List| return the lowest index where the item
  4235. --- has a value equal to {expr}. There is no automatic
  4236. --- conversion, so the String "4" is different from the Number 4.
  4237. --- And the Number 4 is different from the Float 4.0. The value
  4238. --- of 'ignorecase' is not used here, case matters as indicated by
  4239. --- the {ic} argument.
  4240. ---
  4241. --- If {object} is a |Blob| return the lowest index where the byte
  4242. --- value is equal to {expr}.
  4243. ---
  4244. --- If {start} is given then start looking at the item with index
  4245. --- {start} (may be negative for an item relative to the end).
  4246. ---
  4247. --- When {ic} is given and it is |TRUE|, ignore case. Otherwise
  4248. --- case must match.
  4249. ---
  4250. --- -1 is returned when {expr} is not found in {object}.
  4251. --- Example: >vim
  4252. --- let idx = index(words, "the")
  4253. --- if index(numbers, 123) >= 0
  4254. --- " ...
  4255. --- endif
  4256. --- <
  4257. ---
  4258. --- @param object any
  4259. --- @param expr any
  4260. --- @param start? integer
  4261. --- @param ic? boolean
  4262. --- @return integer
  4263. function vim.fn.index(object, expr, start, ic) end
  4264. --- Returns the index of an item in {object} where {expr} is
  4265. --- v:true. {object} must be a |List| or a |Blob|.
  4266. ---
  4267. --- If {object} is a |List|, evaluate {expr} for each item in the
  4268. --- List until the expression is v:true and return the index of
  4269. --- this item.
  4270. ---
  4271. --- If {object} is a |Blob| evaluate {expr} for each byte in the
  4272. --- Blob until the expression is v:true and return the index of
  4273. --- this byte.
  4274. ---
  4275. --- {expr} must be a |string| or |Funcref|.
  4276. ---
  4277. --- If {expr} is a |string|: If {object} is a |List|, inside
  4278. --- {expr} |v:key| has the index of the current List item and
  4279. --- |v:val| has the value of the item. If {object} is a |Blob|,
  4280. --- inside {expr} |v:key| has the index of the current byte and
  4281. --- |v:val| has the byte value.
  4282. ---
  4283. --- If {expr} is a |Funcref| it must take two arguments:
  4284. --- 1. the key or the index of the current item.
  4285. --- 2. the value of the current item.
  4286. --- The function must return |TRUE| if the item is found and the
  4287. --- search should stop.
  4288. ---
  4289. --- The optional argument {opts} is a Dict and supports the
  4290. --- following items:
  4291. --- startidx start evaluating {expr} at the item with this
  4292. --- index; may be negative for an item relative to
  4293. --- the end
  4294. --- Returns -1 when {expr} evaluates to v:false for all the items.
  4295. --- Example: >vim
  4296. --- let l = [#{n: 10}, #{n: 20}, #{n: 30}]
  4297. --- echo indexof(l, "v:val.n == 20")
  4298. --- echo indexof(l, {i, v -> v.n == 30})
  4299. --- echo indexof(l, "v:val.n == 20", #{startidx: 1})
  4300. --- <
  4301. ---
  4302. --- @param object any
  4303. --- @param expr any
  4304. --- @param opts? table
  4305. --- @return integer
  4306. function vim.fn.indexof(object, expr, opts) end
  4307. ---
  4308. --- @param prompt string
  4309. --- @param text? string
  4310. --- @param completion? string
  4311. --- @return string
  4312. function vim.fn.input(prompt, text, completion) end
  4313. --- The result is a String, which is whatever the user typed on
  4314. --- the command-line. The {prompt} argument is either a prompt
  4315. --- string, or a blank string (for no prompt). A '\n' can be used
  4316. --- in the prompt to start a new line.
  4317. ---
  4318. --- In the second form it accepts a single dictionary with the
  4319. --- following keys, any of which may be omitted:
  4320. ---
  4321. --- Key Default Description ~
  4322. --- prompt "" Same as {prompt} in the first form.
  4323. --- default "" Same as {text} in the first form.
  4324. --- completion nothing Same as {completion} in the first form.
  4325. --- cancelreturn "" The value returned when the dialog is
  4326. --- cancelled.
  4327. --- highlight nothing Highlight handler: |Funcref|.
  4328. ---
  4329. --- The highlighting set with |:echohl| is used for the prompt.
  4330. --- The input is entered just like a command-line, with the same
  4331. --- editing commands and mappings. There is a separate history
  4332. --- for lines typed for input().
  4333. --- Example: >vim
  4334. --- if input("Coffee or beer? ") == "beer"
  4335. --- echo "Cheers!"
  4336. --- endif
  4337. --- <
  4338. --- If the optional {text} argument is present and not empty, this
  4339. --- is used for the default reply, as if the user typed this.
  4340. --- Example: >vim
  4341. --- let color = input("Color? ", "white")
  4342. ---
  4343. --- <The optional {completion} argument specifies the type of
  4344. --- completion supported for the input. Without it completion is
  4345. --- not performed. The supported completion types are the same as
  4346. --- that can be supplied to a user-defined command using the
  4347. --- "-complete=" argument. Refer to |:command-completion| for
  4348. --- more information. Example: >vim
  4349. --- let fname = input("File: ", "", "file")
  4350. ---
  4351. --- < *input()-highlight* *E5400* *E5402*
  4352. --- The optional `highlight` key allows specifying function which
  4353. --- will be used for highlighting user input. This function
  4354. --- receives user input as its only argument and must return
  4355. --- a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
  4356. --- where
  4357. --- hl_start_col is the first highlighted column,
  4358. --- hl_end_col is the last highlighted column (+ 1!),
  4359. --- hl_group is |:hi| group used for highlighting.
  4360. --- *E5403* *E5404* *E5405* *E5406*
  4361. --- Both hl_start_col and hl_end_col + 1 must point to the start
  4362. --- of the multibyte character (highlighting must not break
  4363. --- multibyte characters), hl_end_col + 1 may be equal to the
  4364. --- input length. Start column must be in range [0, len(input)),
  4365. --- end column must be in range (hl_start_col, len(input)],
  4366. --- sections must be ordered so that next hl_start_col is greater
  4367. --- then or equal to previous hl_end_col.
  4368. ---
  4369. --- Example (try some input with parentheses): >vim
  4370. --- highlight RBP1 guibg=Red ctermbg=red
  4371. --- highlight RBP2 guibg=Yellow ctermbg=yellow
  4372. --- highlight RBP3 guibg=Green ctermbg=green
  4373. --- highlight RBP4 guibg=Blue ctermbg=blue
  4374. --- let g:rainbow_levels = 4
  4375. --- function! RainbowParens(cmdline)
  4376. --- let ret = []
  4377. --- let i = 0
  4378. --- let lvl = 0
  4379. --- while i < len(a:cmdline)
  4380. --- if a:cmdline[i] is# '('
  4381. --- call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4382. --- let lvl += 1
  4383. --- elseif a:cmdline[i] is# ')'
  4384. --- let lvl -= 1
  4385. --- call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4386. --- endif
  4387. --- let i += 1
  4388. --- endwhile
  4389. --- return ret
  4390. --- endfunction
  4391. --- call input({'prompt':'>','highlight':'RainbowParens'})
  4392. --- <
  4393. --- Highlight function is called at least once for each new
  4394. --- displayed input string, before command-line is redrawn. It is
  4395. --- expected that function is pure for the duration of one input()
  4396. --- call, i.e. it produces the same output for the same input, so
  4397. --- output may be memoized. Function is run like under |:silent|
  4398. --- modifier. If the function causes any errors, it will be
  4399. --- skipped for the duration of the current input() call.
  4400. ---
  4401. --- Highlighting is disabled if command-line contains arabic
  4402. --- characters.
  4403. ---
  4404. --- NOTE: This function must not be used in a startup file, for
  4405. --- the versions that only run in GUI mode (e.g., the Win32 GUI).
  4406. --- Note: When input() is called from within a mapping it will
  4407. --- consume remaining characters from that mapping, because a
  4408. --- mapping is handled like the characters were typed.
  4409. --- Use |inputsave()| before input() and |inputrestore()|
  4410. --- after input() to avoid that. Another solution is to avoid
  4411. --- that further characters follow in the mapping, e.g., by using
  4412. --- |:execute| or |:normal|.
  4413. ---
  4414. --- Example with a mapping: >vim
  4415. --- nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
  4416. --- function GetFoo()
  4417. --- call inputsave()
  4418. --- let g:Foo = input("enter search pattern: ")
  4419. --- call inputrestore()
  4420. --- endfunction
  4421. --- <
  4422. ---
  4423. --- @param opts table
  4424. --- @return string
  4425. function vim.fn.input(opts) end
  4426. --- @deprecated
  4427. --- Use |input()| instead.
  4428. ---
  4429. --- @param ... any
  4430. --- @return any
  4431. function vim.fn.inputdialog(...) end
  4432. --- {textlist} must be a |List| of strings. This |List| is
  4433. --- displayed, one string per line. The user will be prompted to
  4434. --- enter a number, which is returned.
  4435. --- The user can also select an item by clicking on it with the
  4436. --- mouse, if the mouse is enabled in the command line ('mouse' is
  4437. --- "a" or includes "c"). For the first string 0 is returned.
  4438. --- When clicking above the first item a negative number is
  4439. --- returned. When clicking on the prompt one more than the
  4440. --- length of {textlist} is returned.
  4441. --- Make sure {textlist} has less than 'lines' entries, otherwise
  4442. --- it won't work. It's a good idea to put the entry number at
  4443. --- the start of the string. And put a prompt in the first item.
  4444. --- Example: >vim
  4445. --- let color = inputlist(['Select color:', '1. red',
  4446. --- \ '2. green', '3. blue'])
  4447. ---
  4448. --- @param textlist string[]
  4449. --- @return any
  4450. function vim.fn.inputlist(textlist) end
  4451. --- Restore typeahead that was saved with a previous |inputsave()|.
  4452. --- Should be called the same number of times inputsave() is
  4453. --- called. Calling it more often is harmless though.
  4454. --- Returns TRUE when there is nothing to restore, FALSE otherwise.
  4455. ---
  4456. --- @return integer
  4457. function vim.fn.inputrestore() end
  4458. --- Preserve typeahead (also from mappings) and clear it, so that
  4459. --- a following prompt gets input from the user. Should be
  4460. --- followed by a matching inputrestore() after the prompt. Can
  4461. --- be used several times, in which case there must be just as
  4462. --- many inputrestore() calls.
  4463. --- Returns TRUE when out of memory, FALSE otherwise.
  4464. ---
  4465. --- @return integer
  4466. function vim.fn.inputsave() end
  4467. --- This function acts much like the |input()| function with but
  4468. --- two exceptions:
  4469. --- a) the user's response will be displayed as a sequence of
  4470. --- asterisks ("*") thereby keeping the entry secret, and
  4471. --- b) the user's response will not be recorded on the input
  4472. --- |history| stack.
  4473. --- The result is a String, which is whatever the user actually
  4474. --- typed on the command-line in response to the issued prompt.
  4475. --- NOTE: Command-line completion is not supported.
  4476. ---
  4477. --- @param prompt string
  4478. --- @param text? string
  4479. --- @return string
  4480. function vim.fn.inputsecret(prompt, text) end
  4481. --- When {object} is a |List| or a |Blob| insert {item} at the start
  4482. --- of it.
  4483. ---
  4484. --- If {idx} is specified insert {item} before the item with index
  4485. --- {idx}. If {idx} is zero it goes before the first item, just
  4486. --- like omitting {idx}. A negative {idx} is also possible, see
  4487. --- |list-index|. -1 inserts just before the last item.
  4488. ---
  4489. --- Returns the resulting |List| or |Blob|. Examples: >vim
  4490. --- let mylist = insert([2, 3, 5], 1)
  4491. --- call insert(mylist, 4, -1)
  4492. --- call insert(mylist, 6, len(mylist))
  4493. --- <The last example can be done simpler with |add()|.
  4494. --- Note that when {item} is a |List| it is inserted as a single
  4495. --- item. Use |extend()| to concatenate |Lists|.
  4496. ---
  4497. --- @param object any
  4498. --- @param item any
  4499. --- @param idx? integer
  4500. --- @return any
  4501. function vim.fn.insert(object, item, idx) end
  4502. --- Interrupt script execution. It works more or less like the
  4503. --- user typing CTRL-C, most commands won't execute and control
  4504. --- returns to the user. This is useful to abort execution
  4505. --- from lower down, e.g. in an autocommand. Example: >vim
  4506. --- function s:check_typoname(file)
  4507. --- if fnamemodify(a:file, ':t') == '['
  4508. --- echomsg 'Maybe typo'
  4509. --- call interrupt()
  4510. --- endif
  4511. --- endfunction
  4512. --- au BufWritePre * call s:check_typoname(expand('<amatch>'))
  4513. --- <
  4514. ---
  4515. --- @return any
  4516. function vim.fn.interrupt() end
  4517. --- Bitwise invert. The argument is converted to a number. A
  4518. --- List, Dict or Float argument causes an error. Example: >vim
  4519. --- let bits = invert(bits)
  4520. --- <
  4521. ---
  4522. --- @param expr integer
  4523. --- @return integer
  4524. function vim.fn.invert(expr) end
  4525. --- The result is a Number, which is |TRUE| when {path} is an
  4526. --- absolute path.
  4527. --- On Unix, a path is considered absolute when it starts with '/'.
  4528. --- On MS-Windows, it is considered absolute when it starts with an
  4529. --- optional drive prefix and is followed by a '\' or '/'. UNC paths
  4530. --- are always absolute.
  4531. --- Example: >vim
  4532. --- echo isabsolutepath('/usr/share/') " 1
  4533. --- echo isabsolutepath('./foobar') " 0
  4534. --- echo isabsolutepath('C:\Windows') " 1
  4535. --- echo isabsolutepath('foobar') " 0
  4536. --- echo isabsolutepath('\\remote\file') " 1
  4537. --- <
  4538. ---
  4539. --- @param path string
  4540. --- @return 0|1
  4541. function vim.fn.isabsolutepath(path) end
  4542. --- The result is a Number, which is |TRUE| when a directory
  4543. --- with the name {directory} exists. If {directory} doesn't
  4544. --- exist, or isn't a directory, the result is |FALSE|. {directory}
  4545. --- is any expression, which is used as a String.
  4546. ---
  4547. --- @param directory string
  4548. --- @return 0|1
  4549. function vim.fn.isdirectory(directory) end
  4550. --- Return 1 if {expr} is a positive infinity, or -1 a negative
  4551. --- infinity, otherwise 0. >vim
  4552. --- echo isinf(1.0 / 0.0)
  4553. --- < 1 >vim
  4554. --- echo isinf(-1.0 / 0.0)
  4555. --- < -1
  4556. ---
  4557. --- @param expr number
  4558. --- @return 1|0|-1
  4559. function vim.fn.isinf(expr) end
  4560. --- The result is a Number, which is |TRUE| when {expr} is the
  4561. --- name of a locked variable.
  4562. --- The string argument {expr} must be the name of a variable,
  4563. --- |List| item or |Dictionary| entry, not the variable itself!
  4564. --- Example: >vim
  4565. --- let alist = [0, ['a', 'b'], 2, 3]
  4566. --- lockvar 1 alist
  4567. --- echo islocked('alist') " 1
  4568. --- echo islocked('alist[1]') " 0
  4569. ---
  4570. --- <When {expr} is a variable that does not exist you get an error
  4571. --- message. Use |exists()| to check for existence.
  4572. ---
  4573. --- @param expr any
  4574. --- @return 0|1
  4575. function vim.fn.islocked(expr) end
  4576. --- Return |TRUE| if {expr} is a float with value NaN. >vim
  4577. --- echo isnan(0.0 / 0.0)
  4578. --- < 1
  4579. ---
  4580. --- @param expr number
  4581. --- @return 0|1
  4582. function vim.fn.isnan(expr) end
  4583. --- Return a |List| with all the key-value pairs of {dict}. Each
  4584. --- |List| item is a list with two items: the key of a {dict}
  4585. --- entry and the value of this entry. The |List| is in arbitrary
  4586. --- order. Also see |keys()| and |values()|.
  4587. --- Example: >vim
  4588. --- for [key, value] in items(mydict)
  4589. --- echo key .. ': ' .. value
  4590. --- endfor
  4591. --- <
  4592. --- A List or a String argument is also supported. In these
  4593. --- cases, items() returns a List with the index and the value at
  4594. --- the index.
  4595. ---
  4596. --- @param dict table
  4597. --- @return any
  4598. function vim.fn.items(dict) end
  4599. --- @deprecated
  4600. --- Obsolete name for |chanclose()|
  4601. ---
  4602. --- @param ... any
  4603. --- @return any
  4604. function vim.fn.jobclose(...) end
  4605. --- Return the PID (process id) of |job-id| {job}.
  4606. ---
  4607. --- @param job integer
  4608. --- @return integer
  4609. function vim.fn.jobpid(job) end
  4610. --- Resize the pseudo terminal window of |job-id| {job} to {width}
  4611. --- columns and {height} rows.
  4612. --- Fails if the job was not started with `"pty":v:true`.
  4613. ---
  4614. --- @param job integer
  4615. --- @param width integer
  4616. --- @param height integer
  4617. --- @return any
  4618. function vim.fn.jobresize(job, width, height) end
  4619. --- @deprecated
  4620. --- Obsolete name for |chansend()|
  4621. ---
  4622. --- @param ... any
  4623. --- @return any
  4624. function vim.fn.jobsend(...) end
  4625. --- Note: Prefer |vim.system()| in Lua (unless using `rpc`, `pty`, or `term`).
  4626. ---
  4627. --- Spawns {cmd} as a job.
  4628. --- If {cmd} is a List it runs directly (no 'shell').
  4629. --- If {cmd} is a String it runs in the 'shell', like this: >vim
  4630. --- call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  4631. --- <(See |shell-unquoting| for details.)
  4632. ---
  4633. --- Example: start a job and handle its output: >vim
  4634. --- call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}})
  4635. --- <
  4636. --- Example: start a job in a |terminal| connected to the current buffer: >vim
  4637. --- call jobstart(['nvim', '-h'], {'term':v:true})
  4638. --- <
  4639. --- Returns |job-id| on success, 0 on invalid arguments (or job
  4640. --- table is full), -1 if {cmd}[0] or 'shell' is not executable.
  4641. --- The returned job-id is a valid |channel-id| representing the
  4642. --- job's stdio streams. Use |chansend()| (or |rpcnotify()| and
  4643. --- |rpcrequest()| if "rpc" was enabled) to send data to stdin and
  4644. --- |chanclose()| to close the streams without stopping the job.
  4645. ---
  4646. --- See |job-control| and |RPC|.
  4647. ---
  4648. --- NOTE: on Windows if {cmd} is a List:
  4649. --- - cmd[0] must be an executable (not a "built-in"). If it is
  4650. --- in $PATH it can be called by name, without an extension: >vim
  4651. --- call jobstart(['ping', 'neovim.io'])
  4652. --- < If it is a full or partial path, extension is required: >vim
  4653. --- call jobstart(['System32\ping.exe', 'neovim.io'])
  4654. --- < - {cmd} is collapsed to a string of quoted args as expected
  4655. --- by CommandLineToArgvW https://msdn.microsoft.com/bb776391
  4656. --- unless cmd[0] is some form of "cmd.exe".
  4657. ---
  4658. --- *jobstart-env*
  4659. --- The job environment is initialized as follows:
  4660. --- $NVIM is set to |v:servername| of the parent Nvim
  4661. --- $NVIM_LISTEN_ADDRESS is unset
  4662. --- $NVIM_LOG_FILE is unset
  4663. --- $VIM is unset
  4664. --- $VIMRUNTIME is unset
  4665. --- You can set these with the `env` option.
  4666. ---
  4667. --- *jobstart-options*
  4668. --- {opts} is a dictionary with these keys:
  4669. --- clear_env: (boolean) `env` defines the job environment
  4670. --- exactly, instead of merging current environment.
  4671. --- cwd: (string, default=|current-directory|) Working
  4672. --- directory of the job.
  4673. --- detach: (boolean) Detach the job process: it will not be
  4674. --- killed when Nvim exits. If the process exits
  4675. --- before Nvim, `on_exit` will be invoked.
  4676. --- env: (dict) Map of environment variable name:value
  4677. --- pairs extending (or replace with "clear_env")
  4678. --- the current environment. |jobstart-env|
  4679. --- height: (number) Height of the `pty` terminal.
  4680. --- |on_exit|: (function) Callback invoked when the job exits.
  4681. --- |on_stdout|: (function) Callback invoked when the job emits
  4682. --- stdout data.
  4683. --- |on_stderr|: (function) Callback invoked when the job emits
  4684. --- stderr data.
  4685. --- overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
  4686. --- stdio passed to the child process. Only on
  4687. --- MS-Windows; ignored on other platforms.
  4688. --- pty: (boolean) Connect the job to a new pseudo
  4689. --- terminal, and its streams to the master file
  4690. --- descriptor. `on_stdout` receives all output,
  4691. --- `on_stderr` is ignored. |terminal-start|
  4692. --- rpc: (boolean) Use |msgpack-rpc| to communicate with
  4693. --- the job over stdio. Then `on_stdout` is ignored,
  4694. --- but `on_stderr` can still be used.
  4695. --- stderr_buffered: (boolean) Collect data until EOF (stream closed)
  4696. --- before invoking `on_stderr`. |channel-buffered|
  4697. --- stdout_buffered: (boolean) Collect data until EOF (stream
  4698. --- closed) before invoking `on_stdout`. |channel-buffered|
  4699. --- stdin: (string) Either "pipe" (default) to connect the
  4700. --- job's stdin to a channel or "null" to disconnect
  4701. --- stdin.
  4702. --- term: (boolean) Spawns {cmd} in a new pseudo-terminal session
  4703. --- connected to the current (unmodified) buffer. Implies "pty".
  4704. --- Default "height" and "width" are set to the current window
  4705. --- dimensions. |jobstart()|. Defaults $TERM to "xterm-256color".
  4706. --- width: (number) Width of the `pty` terminal.
  4707. ---
  4708. --- {opts} is passed as |self| dictionary to the callback; the
  4709. --- caller may set other keys to pass application-specific data.
  4710. ---
  4711. --- Returns:
  4712. --- - |channel-id| on success
  4713. --- - 0 on invalid arguments
  4714. --- - -1 if {cmd}[0] is not executable.
  4715. --- See also |job-control|, |channel|, |msgpack-rpc|.
  4716. ---
  4717. --- @param cmd string|string[]
  4718. --- @param opts? table
  4719. --- @return integer
  4720. function vim.fn.jobstart(cmd, opts) end
  4721. --- Stop |job-id| {id} by sending SIGTERM to the job process. If
  4722. --- the process does not terminate after a timeout then SIGKILL
  4723. --- will be sent. When the job terminates its |on_exit| handler
  4724. --- (if any) will be invoked.
  4725. --- See |job-control|.
  4726. ---
  4727. --- Returns 1 for valid job id, 0 for invalid id, including jobs have
  4728. --- exited or stopped.
  4729. ---
  4730. --- @param id integer
  4731. --- @return integer
  4732. function vim.fn.jobstop(id) end
  4733. --- Waits for jobs and their |on_exit| handlers to complete.
  4734. ---
  4735. --- {jobs} is a List of |job-id|s to wait for.
  4736. --- {timeout} is the maximum waiting time in milliseconds. If
  4737. --- omitted or -1, wait forever.
  4738. ---
  4739. --- Timeout of 0 can be used to check the status of a job: >vim
  4740. --- let running = jobwait([{job-id}], 0)[0] == -1
  4741. --- <
  4742. --- During jobwait() callbacks for jobs not in the {jobs} list may
  4743. --- be invoked. The screen will not redraw unless |:redraw| is
  4744. --- invoked by a callback.
  4745. ---
  4746. --- Returns a list of len({jobs}) integers, where each integer is
  4747. --- the status of the corresponding job:
  4748. --- Exit-code, if the job exited
  4749. --- -1 if the timeout was exceeded
  4750. --- -2 if the job was interrupted (by |CTRL-C|)
  4751. --- -3 if the job-id is invalid
  4752. ---
  4753. --- @param jobs integer[]
  4754. --- @param timeout? integer
  4755. --- @return integer[]
  4756. function vim.fn.jobwait(jobs, timeout) end
  4757. --- Join the items in {list} together into one String.
  4758. --- When {sep} is specified it is put in between the items. If
  4759. --- {sep} is omitted a single space is used.
  4760. --- Note that {sep} is not added at the end. You might want to
  4761. --- add it there too: >vim
  4762. --- let lines = join(mylist, "\n") .. "\n"
  4763. --- <String items are used as-is. |Lists| and |Dictionaries| are
  4764. --- converted into a string like with |string()|.
  4765. --- The opposite function is |split()|.
  4766. ---
  4767. --- @param list any[]
  4768. --- @param sep? string
  4769. --- @return string
  4770. function vim.fn.join(list, sep) end
  4771. --- Convert {expr} from JSON object. Accepts |readfile()|-style
  4772. --- list as the input, as well as regular string. May output any
  4773. --- Vim value. In the following cases it will output
  4774. --- |msgpack-special-dict|:
  4775. --- 1. Dictionary contains duplicate key.
  4776. --- 2. String contains NUL byte. Two special dictionaries: for
  4777. --- dictionary and for string will be emitted in case string
  4778. --- with NUL byte was a dictionary key.
  4779. ---
  4780. --- Note: function treats its input as UTF-8 always. The JSON
  4781. --- standard allows only a few encodings, of which UTF-8 is
  4782. --- recommended and the only one required to be supported.
  4783. --- Non-UTF-8 characters are an error.
  4784. ---
  4785. --- @param expr any
  4786. --- @return any
  4787. function vim.fn.json_decode(expr) end
  4788. --- Convert {expr} into a JSON string. Accepts
  4789. --- |msgpack-special-dict| as the input. Will not convert
  4790. --- |Funcref|s, mappings with non-string keys (can be created as
  4791. --- |msgpack-special-dict|), values with self-referencing
  4792. --- containers, strings which contain non-UTF-8 characters,
  4793. --- pseudo-UTF-8 strings which contain codepoints reserved for
  4794. --- surrogate pairs (such strings are not valid UTF-8 strings).
  4795. --- Non-printable characters are converted into "\u1234" escapes
  4796. --- or special escapes like "\t", other are dumped as-is.
  4797. --- |Blob|s are converted to arrays of the individual bytes.
  4798. ---
  4799. --- @param expr any
  4800. --- @return string
  4801. function vim.fn.json_encode(expr) end
  4802. --- Return a |List| with all the keys of {dict}. The |List| is in
  4803. --- arbitrary order. Also see |items()| and |values()|.
  4804. ---
  4805. --- @param dict table
  4806. --- @return string[]
  4807. function vim.fn.keys(dict) end
  4808. --- Turn the internal byte representation of keys into a form that
  4809. --- can be used for |:map|. E.g. >vim
  4810. --- let xx = "\<C-Home>"
  4811. --- echo keytrans(xx)
  4812. --- < <C-Home>
  4813. ---
  4814. --- @param string string
  4815. --- @return string
  4816. function vim.fn.keytrans(string) end
  4817. --- @deprecated
  4818. --- Obsolete name for bufnr("$").
  4819. ---
  4820. --- @return any
  4821. function vim.fn.last_buffer_nr() end
  4822. --- The result is a Number, which is the length of the argument.
  4823. --- When {expr} is a String or a Number the length in bytes is
  4824. --- used, as with |strlen()|.
  4825. --- When {expr} is a |List| the number of items in the |List| is
  4826. --- returned.
  4827. --- When {expr} is a |Blob| the number of bytes is returned.
  4828. --- When {expr} is a |Dictionary| the number of entries in the
  4829. --- |Dictionary| is returned.
  4830. --- Otherwise an error is given and returns zero.
  4831. ---
  4832. --- @param expr any[]
  4833. --- @return integer
  4834. function vim.fn.len(expr) end
  4835. --- Call function {funcname} in the run-time library {libname}
  4836. --- with single argument {argument}.
  4837. --- This is useful to call functions in a library that you
  4838. --- especially made to be used with Vim. Since only one argument
  4839. --- is possible, calling standard library functions is rather
  4840. --- limited.
  4841. --- The result is the String returned by the function. If the
  4842. --- function returns NULL, this will appear as an empty string ""
  4843. --- to Vim.
  4844. --- If the function returns a number, use libcallnr()!
  4845. --- If {argument} is a number, it is passed to the function as an
  4846. --- int; if {argument} is a string, it is passed as a
  4847. --- null-terminated string.
  4848. ---
  4849. --- libcall() allows you to write your own 'plug-in' extensions to
  4850. --- Vim without having to recompile the program. It is NOT a
  4851. --- means to call system functions! If you try to do so Vim will
  4852. --- very probably crash.
  4853. ---
  4854. --- For Win32, the functions you write must be placed in a DLL
  4855. --- and use the normal C calling convention (NOT Pascal which is
  4856. --- used in Windows System DLLs). The function must take exactly
  4857. --- one parameter, either a character pointer or a long integer,
  4858. --- and must return a character pointer or NULL. The character
  4859. --- pointer returned must point to memory that will remain valid
  4860. --- after the function has returned (e.g. in static data in the
  4861. --- DLL). If it points to allocated memory, that memory will
  4862. --- leak away. Using a static buffer in the function should work,
  4863. --- it's then freed when the DLL is unloaded.
  4864. ---
  4865. --- WARNING: If the function returns a non-valid pointer, Vim may
  4866. --- crash! This also happens if the function returns a number,
  4867. --- because Vim thinks it's a pointer.
  4868. --- For Win32 systems, {libname} should be the filename of the DLL
  4869. --- without the ".DLL" suffix. A full path is only required if
  4870. --- the DLL is not in the usual places.
  4871. --- For Unix: When compiling your own plugins, remember that the
  4872. --- object code must be compiled as position-independent ('PIC').
  4873. --- Examples: >vim
  4874. --- echo libcall("libc.so", "getenv", "HOME")
  4875. ---
  4876. --- @param libname string
  4877. --- @param funcname string
  4878. --- @param argument any
  4879. --- @return any
  4880. function vim.fn.libcall(libname, funcname, argument) end
  4881. --- Just like |libcall()|, but used for a function that returns an
  4882. --- int instead of a string.
  4883. --- Examples: >vim
  4884. --- echo libcallnr("/usr/lib/libc.so", "getpid", "")
  4885. --- call libcallnr("libc.so", "printf", "Hello World!\n")
  4886. --- call libcallnr("libc.so", "sleep", 10)
  4887. --- <
  4888. ---
  4889. --- @param libname string
  4890. --- @param funcname string
  4891. --- @param argument any
  4892. --- @return any
  4893. function vim.fn.libcallnr(libname, funcname, argument) end
  4894. --- See |getpos()| for accepted positions.
  4895. ---
  4896. --- To get the column number use |col()|. To get both use
  4897. --- |getpos()|.
  4898. ---
  4899. --- With the optional {winid} argument the values are obtained for
  4900. --- that window instead of the current window.
  4901. ---
  4902. --- Returns 0 for invalid values of {expr} and {winid}.
  4903. ---
  4904. --- Examples: >vim
  4905. --- echo line(".") " line number of the cursor
  4906. --- echo line(".", winid) " idem, in window "winid"
  4907. --- echo line("'t") " line number of mark t
  4908. --- echo line("'" .. marker) " line number of mark marker
  4909. --- <
  4910. --- To jump to the last known position when opening a file see
  4911. --- |last-position-jump|.
  4912. ---
  4913. --- @param expr string|integer[]
  4914. --- @param winid? integer
  4915. --- @return integer
  4916. function vim.fn.line(expr, winid) end
  4917. --- Return the byte count from the start of the buffer for line
  4918. --- {lnum}. This includes the end-of-line character, depending on
  4919. --- the 'fileformat' option for the current buffer. The first
  4920. --- line returns 1. UTF-8 encoding is used, 'fileencoding' is
  4921. --- ignored. This can also be used to get the byte count for the
  4922. --- line just below the last line: >vim
  4923. --- echo line2byte(line("$") + 1)
  4924. --- <This is the buffer size plus one. If 'fileencoding' is empty
  4925. --- it is the file size plus one. {lnum} is used like with
  4926. --- |getline()|. When {lnum} is invalid -1 is returned.
  4927. --- Also see |byte2line()|, |go| and |:goto|.
  4928. ---
  4929. --- @param lnum integer
  4930. --- @return integer
  4931. function vim.fn.line2byte(lnum) end
  4932. --- Get the amount of indent for line {lnum} according the lisp
  4933. --- indenting rules, as with 'lisp'.
  4934. --- The indent is counted in spaces, the value of 'tabstop' is
  4935. --- relevant. {lnum} is used just like in |getline()|.
  4936. --- When {lnum} is invalid, -1 is returned.
  4937. ---
  4938. --- @param lnum integer
  4939. --- @return integer
  4940. function vim.fn.lispindent(lnum) end
  4941. --- Return a Blob concatenating all the number values in {list}.
  4942. --- Examples: >vim
  4943. --- echo list2blob([1, 2, 3, 4]) " returns 0z01020304
  4944. --- echo list2blob([]) " returns 0z
  4945. --- <Returns an empty Blob on error. If one of the numbers is
  4946. --- negative or more than 255 error *E1239* is given.
  4947. ---
  4948. --- |blob2list()| does the opposite.
  4949. ---
  4950. --- @param list any[]
  4951. --- @return string
  4952. function vim.fn.list2blob(list) end
  4953. --- Convert each number in {list} to a character string can
  4954. --- concatenate them all. Examples: >vim
  4955. --- echo list2str([32]) " returns " "
  4956. --- echo list2str([65, 66, 67]) " returns "ABC"
  4957. --- <The same can be done (slowly) with: >vim
  4958. --- echo join(map(list, {nr, val -> nr2char(val)}), '')
  4959. --- <|str2list()| does the opposite.
  4960. ---
  4961. --- UTF-8 encoding is always used, {utf8} option has no effect,
  4962. --- and exists only for backwards-compatibility.
  4963. --- With UTF-8 composing characters work as expected: >vim
  4964. --- echo list2str([97, 769]) " returns "á"
  4965. --- <
  4966. --- Returns an empty string on error.
  4967. ---
  4968. --- @param list any[]
  4969. --- @param utf8? boolean
  4970. --- @return string
  4971. function vim.fn.list2str(list, utf8) end
  4972. --- Return the current time, measured as seconds since 1st Jan
  4973. --- 1970. See also |strftime()|, |strptime()| and |getftime()|.
  4974. ---
  4975. --- @return integer
  4976. function vim.fn.localtime() end
  4977. --- Return the natural logarithm (base e) of {expr} as a |Float|.
  4978. --- {expr} must evaluate to a |Float| or a |Number| in the range
  4979. --- (0, inf].
  4980. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4981. --- Examples: >vim
  4982. --- echo log(10)
  4983. --- < 2.302585 >vim
  4984. --- echo log(exp(5))
  4985. --- < 5.0
  4986. ---
  4987. --- @param expr number
  4988. --- @return number
  4989. function vim.fn.log(expr) end
  4990. --- Return the logarithm of Float {expr} to base 10 as a |Float|.
  4991. --- {expr} must evaluate to a |Float| or a |Number|.
  4992. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4993. --- Examples: >vim
  4994. --- echo log10(1000)
  4995. --- < 3.0 >vim
  4996. --- echo log10(0.01)
  4997. --- < -2.0
  4998. ---
  4999. --- @param expr number
  5000. --- @return number
  5001. function vim.fn.log10(expr) end
  5002. --- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  5003. --- When {expr1} is a |List| or |Dictionary|, replace each
  5004. --- item in {expr1} with the result of evaluating {expr2}.
  5005. --- For a |Blob| each byte is replaced.
  5006. --- For a |String|, each character, including composing
  5007. --- characters, is replaced.
  5008. --- If the item type changes you may want to use |mapnew()| to
  5009. --- create a new List or Dictionary.
  5010. ---
  5011. --- {expr2} must be a |String| or |Funcref|.
  5012. ---
  5013. --- If {expr2} is a |String|, inside {expr2} |v:val| has the value
  5014. --- of the current item. For a |Dictionary| |v:key| has the key
  5015. --- of the current item and for a |List| |v:key| has the index of
  5016. --- the current item. For a |Blob| |v:key| has the index of the
  5017. --- current byte. For a |String| |v:key| has the index of the
  5018. --- current character.
  5019. --- Example: >vim
  5020. --- call map(mylist, '"> " .. v:val .. " <"')
  5021. --- <This puts "> " before and " <" after each item in "mylist".
  5022. ---
  5023. --- Note that {expr2} is the result of an expression and is then
  5024. --- used as an expression again. Often it is good to use a
  5025. --- |literal-string| to avoid having to double backslashes. You
  5026. --- still have to double ' quotes
  5027. ---
  5028. --- If {expr2} is a |Funcref| it is called with two arguments:
  5029. --- 1. The key or the index of the current item.
  5030. --- 2. the value of the current item.
  5031. --- The function must return the new value of the item. Example
  5032. --- that changes each value by "key-value": >vim
  5033. --- func KeyValue(key, val)
  5034. --- return a:key .. '-' .. a:val
  5035. --- endfunc
  5036. --- call map(myDict, function('KeyValue'))
  5037. --- <It is shorter when using a |lambda|: >vim
  5038. --- call map(myDict, {key, val -> key .. '-' .. val})
  5039. --- <If you do not use "val" you can leave it out: >vim
  5040. --- call map(myDict, {key -> 'item: ' .. key})
  5041. --- <If you do not use "key" you can use a short name: >vim
  5042. --- call map(myDict, {_, val -> 'item: ' .. val})
  5043. --- <
  5044. --- The operation is done in-place for a |List| and |Dictionary|.
  5045. --- If you want it to remain unmodified make a copy first: >vim
  5046. --- let tlist = map(copy(mylist), ' v:val .. "\t"')
  5047. ---
  5048. --- <Returns {expr1}, the |List| or |Dictionary| that was filtered,
  5049. --- or a new |Blob| or |String|.
  5050. --- When an error is encountered while evaluating {expr2} no
  5051. --- further items in {expr1} are processed.
  5052. --- When {expr2} is a Funcref errors inside a function are ignored,
  5053. --- unless it was defined with the "abort" flag.
  5054. ---
  5055. --- @param expr1 string|table|any[]
  5056. --- @param expr2 string|function
  5057. --- @return any
  5058. function vim.fn.map(expr1, expr2) end
  5059. --- When {dict} is omitted or zero: Return the rhs of mapping
  5060. --- {name} in mode {mode}. The returned String has special
  5061. --- characters translated like in the output of the ":map" command
  5062. --- listing. When {dict} is TRUE a dictionary is returned, see
  5063. --- below. To get a list of all mappings see |maplist()|.
  5064. ---
  5065. --- When there is no mapping for {name}, an empty String is
  5066. --- returned if {dict} is FALSE, otherwise returns an empty Dict.
  5067. --- When the mapping for {name} is empty, then "<Nop>" is
  5068. --- returned.
  5069. ---
  5070. --- The {name} can have special key names, like in the ":map"
  5071. --- command.
  5072. ---
  5073. --- {mode} can be one of these strings:
  5074. --- "n" Normal
  5075. --- "v" Visual (including Select)
  5076. --- "o" Operator-pending
  5077. --- "i" Insert
  5078. --- "c" Cmd-line
  5079. --- "s" Select
  5080. --- "x" Visual
  5081. --- "l" langmap |language-mapping|
  5082. --- "t" Terminal
  5083. --- "" Normal, Visual and Operator-pending
  5084. --- When {mode} is omitted, the modes for "" are used.
  5085. ---
  5086. --- When {abbr} is there and it is |TRUE| use abbreviations
  5087. --- instead of mappings.
  5088. ---
  5089. --- When {dict} is |TRUE|, return a dictionary describing the
  5090. --- mapping, with these items: *mapping-dict*
  5091. --- "lhs" The {lhs} of the mapping as it would be typed
  5092. --- "lhsraw" The {lhs} of the mapping as raw bytes
  5093. --- "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
  5094. --- form, only present when it differs from "lhsraw"
  5095. --- "rhs" The {rhs} of the mapping as typed.
  5096. --- "callback" Lua function, if RHS was defined as such.
  5097. --- "silent" 1 for a |:map-silent| mapping, else 0.
  5098. --- "noremap" 1 if the {rhs} of the mapping is not remappable.
  5099. --- "script" 1 if mapping was defined with <script>.
  5100. --- "expr" 1 for an expression mapping (|:map-<expr>|).
  5101. --- "buffer" 1 for a buffer local mapping (|:map-local|).
  5102. --- "mode" Modes for which the mapping is defined. In
  5103. --- addition to the modes mentioned above, these
  5104. --- characters will be used:
  5105. --- " " Normal, Visual and Operator-pending
  5106. --- "!" Insert and Commandline mode
  5107. --- (|mapmode-ic|)
  5108. --- "sid" The script local ID, used for <sid> mappings
  5109. --- (|<SID>|). Negative for special contexts.
  5110. --- "scriptversion" The version of the script, always 1.
  5111. --- "lnum" The line number in "sid", zero if unknown.
  5112. --- "nowait" Do not wait for other, longer mappings.
  5113. --- (|:map-<nowait>|).
  5114. --- "abbr" True if this is an |abbreviation|.
  5115. --- "mode_bits" Nvim's internal binary representation of "mode".
  5116. --- |mapset()| ignores this; only "mode" is used.
  5117. --- See |maplist()| for usage examples. The values
  5118. --- are from src/nvim/state_defs.h and may change in
  5119. --- the future.
  5120. ---
  5121. --- The dictionary can be used to restore a mapping with
  5122. --- |mapset()|.
  5123. ---
  5124. --- The mappings local to the current buffer are checked first,
  5125. --- then the global mappings.
  5126. --- This function can be used to map a key even when it's already
  5127. --- mapped, and have it do the original mapping too. Sketch: >vim
  5128. --- exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
  5129. --- <
  5130. ---
  5131. --- @param name string
  5132. --- @param mode? string
  5133. --- @param abbr? boolean
  5134. --- @param dict? false
  5135. --- @return string
  5136. function vim.fn.maparg(name, mode, abbr, dict) end
  5137. --- @param name string
  5138. --- @param mode string
  5139. --- @param abbr boolean
  5140. --- @param dict true
  5141. --- @return table<string,any>
  5142. function vim.fn.maparg(name, mode, abbr, dict) end
  5143. --- Check if there is a mapping that matches with {name} in mode
  5144. --- {mode}. See |maparg()| for {mode} and special names in
  5145. --- {name}.
  5146. --- When {abbr} is there and it is non-zero use abbreviations
  5147. --- instead of mappings.
  5148. --- A match happens with a mapping that starts with {name} and
  5149. --- with a mapping which is equal to the start of {name}.
  5150. ---
  5151. --- matches mapping "a" "ab" "abc" ~
  5152. --- mapcheck("a") yes yes yes
  5153. --- mapcheck("abc") yes yes yes
  5154. --- mapcheck("ax") yes no no
  5155. --- mapcheck("b") no no no
  5156. ---
  5157. --- The difference with maparg() is that mapcheck() finds a
  5158. --- mapping that matches with {name}, while maparg() only finds a
  5159. --- mapping for {name} exactly.
  5160. --- When there is no mapping that starts with {name}, an empty
  5161. --- String is returned. If there is one, the RHS of that mapping
  5162. --- is returned. If there are several mappings that start with
  5163. --- {name}, the RHS of one of them is returned. This will be
  5164. --- "<Nop>" if the RHS is empty.
  5165. --- The mappings local to the current buffer are checked first,
  5166. --- then the global mappings.
  5167. --- This function can be used to check if a mapping can be added
  5168. --- without being ambiguous. Example: >vim
  5169. --- if mapcheck("_vv") == ""
  5170. --- map _vv :set guifont=7x13<CR>
  5171. --- endif
  5172. --- <This avoids adding the "_vv" mapping when there already is a
  5173. --- mapping for "_v" or for "_vvv".
  5174. ---
  5175. --- @param name string
  5176. --- @param mode? string
  5177. --- @param abbr? boolean
  5178. --- @return any
  5179. function vim.fn.mapcheck(name, mode, abbr) end
  5180. --- Returns a |List| of all mappings. Each List item is a |Dict|,
  5181. --- the same as what is returned by |maparg()|, see
  5182. --- |mapping-dict|. When {abbr} is there and it is |TRUE| use
  5183. --- abbreviations instead of mappings.
  5184. ---
  5185. --- Example to show all mappings with "MultiMatch" in rhs: >vim
  5186. --- echo maplist()->filter({_, m ->
  5187. --- \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
  5188. --- \ })
  5189. --- <It can be tricky to find mappings for particular |:map-modes|.
  5190. --- |mapping-dict|'s "mode_bits" can simplify this. For example,
  5191. --- the mode_bits for Normal, Insert or Command-line modes are
  5192. --- 0x19. To find all the mappings available in those modes you
  5193. --- can do: >vim
  5194. --- let saved_maps = []
  5195. --- for m in maplist()
  5196. --- if and(m.mode_bits, 0x19) != 0
  5197. --- eval saved_maps->add(m)
  5198. --- endif
  5199. --- endfor
  5200. --- echo saved_maps->mapnew({_, m -> m.lhs})
  5201. --- <The values of the mode_bits are defined in Nvim's
  5202. --- src/nvim/state_defs.h file and they can be discovered at
  5203. --- runtime using |:map-commands| and "maplist()". Example: >vim
  5204. --- omap xyzzy <Nop>
  5205. --- let op_bit = maplist()->filter(
  5206. --- \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
  5207. --- ounmap xyzzy
  5208. --- echo printf("Operator-pending mode bit: 0x%x", op_bit)
  5209. --- <
  5210. ---
  5211. --- @param abbr? 0|1
  5212. --- @return table[]
  5213. function vim.fn.maplist(abbr) end
  5214. --- Like |map()| but instead of replacing items in {expr1} a new
  5215. --- List or Dictionary is created and returned. {expr1} remains
  5216. --- unchanged. Items can still be changed by {expr2}, if you
  5217. --- don't want that use |deepcopy()| first.
  5218. ---
  5219. --- @param expr1 any
  5220. --- @param expr2 any
  5221. --- @return any
  5222. function vim.fn.mapnew(expr1, expr2) end
  5223. --- @param mode string
  5224. --- @param abbr? boolean
  5225. --- @param dict? boolean
  5226. --- @return any
  5227. function vim.fn.mapset(mode, abbr, dict) end
  5228. --- Restore a mapping from a dictionary, possibly returned by
  5229. --- |maparg()| or |maplist()|. A buffer mapping, when dict.buffer
  5230. --- is true, is set on the current buffer; it is up to the caller
  5231. --- to ensure that the intended buffer is the current buffer. This
  5232. --- feature allows copying mappings from one buffer to another.
  5233. --- The dict.mode value may restore a single mapping that covers
  5234. --- more than one mode, like with mode values of '!', ' ', "nox",
  5235. --- or 'v'. *E1276*
  5236. ---
  5237. --- In the first form, {mode} and {abbr} should be the same as
  5238. --- for the call to |maparg()|. *E460*
  5239. --- {mode} is used to define the mode in which the mapping is set,
  5240. --- not the "mode" entry in {dict}.
  5241. --- Example for saving and restoring a mapping: >vim
  5242. --- let save_map = maparg('K', 'n', 0, 1)
  5243. --- nnoremap K somethingelse
  5244. --- " ...
  5245. --- call mapset('n', 0, save_map)
  5246. --- <Note that if you are going to replace a map in several modes,
  5247. --- e.g. with `:map!`, you need to save/restore the mapping for
  5248. --- all of them, when they might differ.
  5249. ---
  5250. --- In the second form, with {dict} as the only argument, mode
  5251. --- and abbr are taken from the dict.
  5252. --- Example: >vim
  5253. --- let save_maps = maplist()->filter(
  5254. --- \ {_, m -> m.lhs == 'K'})
  5255. --- nnoremap K somethingelse
  5256. --- cnoremap K somethingelse2
  5257. --- " ...
  5258. --- unmap K
  5259. --- for d in save_maps
  5260. --- call mapset(d)
  5261. --- endfor
  5262. --- <
  5263. ---
  5264. --- @param dict boolean
  5265. --- @return any
  5266. function vim.fn.mapset(dict) end
  5267. --- When {expr} is a |List| then this returns the index of the
  5268. --- first item where {pat} matches. Each item is used as a
  5269. --- String, |Lists| and |Dictionaries| are used as echoed.
  5270. ---
  5271. --- Otherwise, {expr} is used as a String. The result is a
  5272. --- Number, which gives the index (byte offset) in {expr} where
  5273. --- {pat} matches.
  5274. ---
  5275. --- A match at the first character or |List| item returns zero.
  5276. --- If there is no match -1 is returned.
  5277. ---
  5278. --- For getting submatches see |matchlist()|.
  5279. --- Example: >vim
  5280. --- echo match("testing", "ing") " results in 4
  5281. --- echo match([1, 'x'], '\a') " results in 1
  5282. --- <See |string-match| for how {pat} is used.
  5283. --- *strpbrk()*
  5284. --- Vim doesn't have a strpbrk() function. But you can do: >vim
  5285. --- let sepidx = match(line, '[.,;: \t]')
  5286. --- < *strcasestr()*
  5287. --- Vim doesn't have a strcasestr() function. But you can add
  5288. --- "\c" to the pattern to ignore case: >vim
  5289. --- let idx = match(haystack, '\cneedle')
  5290. --- <
  5291. --- If {start} is given, the search starts from byte index
  5292. --- {start} in a String or item {start} in a |List|.
  5293. --- The result, however, is still the index counted from the
  5294. --- first character/item. Example: >vim
  5295. --- echo match("testing", "ing", 2)
  5296. --- <result is again "4". >vim
  5297. --- echo match("testing", "ing", 4)
  5298. --- <result is again "4". >vim
  5299. --- echo match("testing", "t", 2)
  5300. --- <result is "3".
  5301. --- For a String, if {start} > 0 then it is like the string starts
  5302. --- {start} bytes later, thus "^" will match at {start}. Except
  5303. --- when {count} is given, then it's like matches before the
  5304. --- {start} byte are ignored (this is a bit complicated to keep it
  5305. --- backwards compatible).
  5306. --- For a String, if {start} < 0, it will be set to 0. For a list
  5307. --- the index is counted from the end.
  5308. --- If {start} is out of range ({start} > strlen({expr}) for a
  5309. --- String or {start} > len({expr}) for a |List|) -1 is returned.
  5310. ---
  5311. --- When {count} is given use the {count}th match. When a match
  5312. --- is found in a String the search for the next one starts one
  5313. --- character further. Thus this example results in 1: >vim
  5314. --- echo match("testing", "..", 0, 2)
  5315. --- <In a |List| the search continues in the next item.
  5316. --- Note that when {count} is added the way {start} works changes,
  5317. --- see above.
  5318. ---
  5319. --- *match-pattern*
  5320. --- See |pattern| for the patterns that are accepted.
  5321. --- The 'ignorecase' option is used to set the ignore-caseness of
  5322. --- the pattern. 'smartcase' is NOT used. The matching is always
  5323. --- done like 'magic' is set and 'cpoptions' is empty.
  5324. --- Note that a match at the start is preferred, thus when the
  5325. --- pattern is using "*" (any number of matches) it tends to find
  5326. --- zero matches at the start instead of a number of matches
  5327. --- further down in the text.
  5328. ---
  5329. --- @param expr string|any[]
  5330. --- @param pat string
  5331. --- @param start? integer
  5332. --- @param count? integer
  5333. --- @return any
  5334. function vim.fn.match(expr, pat, start, count) end
  5335. --- Defines a pattern to be highlighted in the current window (a
  5336. --- "match"). It will be highlighted with {group}. Returns an
  5337. --- identification number (ID), which can be used to delete the
  5338. --- match using |matchdelete()|. The ID is bound to the window.
  5339. --- Matching is case sensitive and magic, unless case sensitivity
  5340. --- or magicness are explicitly overridden in {pattern}. The
  5341. --- 'magic', 'smartcase' and 'ignorecase' options are not used.
  5342. --- The "Conceal" value is special, it causes the match to be
  5343. --- concealed.
  5344. ---
  5345. --- The optional {priority} argument assigns a priority to the
  5346. --- match. A match with a high priority will have its
  5347. --- highlighting overrule that of a match with a lower priority.
  5348. --- A priority is specified as an integer (negative numbers are no
  5349. --- exception). If the {priority} argument is not specified, the
  5350. --- default priority is 10. The priority of 'hlsearch' is zero,
  5351. --- hence all matches with a priority greater than zero will
  5352. --- overrule it. Syntax highlighting (see 'syntax') is a separate
  5353. --- mechanism, and regardless of the chosen priority a match will
  5354. --- always overrule syntax highlighting.
  5355. ---
  5356. --- The optional {id} argument allows the request for a specific
  5357. --- match ID. If a specified ID is already taken, an error
  5358. --- message will appear and the match will not be added. An ID
  5359. --- is specified as a positive integer (zero excluded). IDs 1, 2
  5360. --- and 3 are reserved for |:match|, |:2match| and |:3match|,
  5361. --- respectively. 3 is reserved for use by the |matchparen|
  5362. --- plugin.
  5363. --- If the {id} argument is not specified or -1, |matchadd()|
  5364. --- automatically chooses a free ID, which is at least 1000.
  5365. ---
  5366. --- The optional {dict} argument allows for further custom
  5367. --- values. Currently this is used to specify a match specific
  5368. --- conceal character that will be shown for |hl-Conceal|
  5369. --- highlighted matches. The dict can have the following members:
  5370. ---
  5371. --- conceal Special character to show instead of the
  5372. --- match (only for |hl-Conceal| highlighted
  5373. --- matches, see |:syn-cchar|)
  5374. --- window Instead of the current window use the
  5375. --- window with this number or window ID.
  5376. ---
  5377. --- The number of matches is not limited, as it is the case with
  5378. --- the |:match| commands.
  5379. ---
  5380. --- Returns -1 on error.
  5381. ---
  5382. --- Example: >vim
  5383. --- highlight MyGroup ctermbg=green guibg=green
  5384. --- let m = matchadd("MyGroup", "TODO")
  5385. --- <Deletion of the pattern: >vim
  5386. --- call matchdelete(m)
  5387. ---
  5388. --- <A list of matches defined by |matchadd()| and |:match| are
  5389. --- available from |getmatches()|. All matches can be deleted in
  5390. --- one operation by |clearmatches()|.
  5391. ---
  5392. --- @param group integer|string
  5393. --- @param pattern string
  5394. --- @param priority? integer
  5395. --- @param id? integer
  5396. --- @param dict? string
  5397. --- @return any
  5398. function vim.fn.matchadd(group, pattern, priority, id, dict) end
  5399. --- Same as |matchadd()|, but requires a list of positions {pos}
  5400. --- instead of a pattern. This command is faster than |matchadd()|
  5401. --- because it does not handle regular expressions and it sets
  5402. --- buffer line boundaries to redraw screen. It is supposed to be
  5403. --- used when fast match additions and deletions are required, for
  5404. --- example to highlight matching parentheses.
  5405. --- *E5030* *E5031*
  5406. --- {pos} is a list of positions. Each position can be one of
  5407. --- these:
  5408. --- - A number. This whole line will be highlighted. The first
  5409. --- line has number 1.
  5410. --- - A list with one number, e.g., [23]. The whole line with this
  5411. --- number will be highlighted.
  5412. --- - A list with two numbers, e.g., [23, 11]. The first number is
  5413. --- the line number, the second one is the column number (first
  5414. --- column is 1, the value must correspond to the byte index as
  5415. --- |col()| would return). The character at this position will
  5416. --- be highlighted.
  5417. --- - A list with three numbers, e.g., [23, 11, 3]. As above, but
  5418. --- the third number gives the length of the highlight in bytes.
  5419. ---
  5420. --- Entries with zero and negative line numbers are silently
  5421. --- ignored, as well as entries with negative column numbers and
  5422. --- lengths.
  5423. ---
  5424. --- Returns -1 on error.
  5425. ---
  5426. --- Example: >vim
  5427. --- highlight MyGroup ctermbg=green guibg=green
  5428. --- let m = matchaddpos("MyGroup", [[23, 24], 34])
  5429. --- <Deletion of the pattern: >vim
  5430. --- call matchdelete(m)
  5431. ---
  5432. --- <Matches added by |matchaddpos()| are returned by
  5433. --- |getmatches()|.
  5434. ---
  5435. --- @param group integer|string
  5436. --- @param pos any[]
  5437. --- @param priority? integer
  5438. --- @param id? integer
  5439. --- @param dict? string
  5440. --- @return any
  5441. function vim.fn.matchaddpos(group, pos, priority, id, dict) end
  5442. --- Selects the {nr} match item, as set with a |:match|,
  5443. --- |:2match| or |:3match| command.
  5444. --- Return a |List| with two elements:
  5445. --- The name of the highlight group used
  5446. --- The pattern used.
  5447. --- When {nr} is not 1, 2 or 3 returns an empty |List|.
  5448. --- When there is no match item set returns ['', ''].
  5449. --- This is useful to save and restore a |:match|.
  5450. --- Highlighting matches using the |:match| commands are limited
  5451. --- to three matches. |matchadd()| does not have this limitation.
  5452. ---
  5453. --- @param nr integer
  5454. --- @return any
  5455. function vim.fn.matcharg(nr) end
  5456. --- Returns the |List| of matches in lines from {lnum} to {end} in
  5457. --- buffer {buf} where {pat} matches.
  5458. ---
  5459. --- {lnum} and {end} can either be a line number or the string "$"
  5460. --- to refer to the last line in {buf}.
  5461. ---
  5462. --- The {dict} argument supports following items:
  5463. --- submatches include submatch information (|/\(|)
  5464. ---
  5465. --- For each match, a |Dict| with the following items is returned:
  5466. --- byteidx starting byte index of the match
  5467. --- lnum line number where there is a match
  5468. --- text matched string
  5469. --- Note that there can be multiple matches in a single line.
  5470. ---
  5471. --- This function works only for loaded buffers. First call
  5472. --- |bufload()| if needed.
  5473. ---
  5474. --- See |match-pattern| for information about the effect of some
  5475. --- option settings on the pattern.
  5476. ---
  5477. --- When {buf} is not a valid buffer, the buffer is not loaded or
  5478. --- {lnum} or {end} is not valid then an error is given and an
  5479. --- empty |List| is returned.
  5480. ---
  5481. --- Examples: >vim
  5482. --- " Assuming line 3 in buffer 5 contains "a"
  5483. --- echo matchbufline(5, '\<\k\+\>', 3, 3)
  5484. --- < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
  5485. --- " Assuming line 4 in buffer 10 contains "tik tok"
  5486. --- echo matchbufline(10, '\<\k\+\>', 1, 4)
  5487. --- < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
  5488. ---
  5489. --- If {submatch} is present and is v:true, then submatches like
  5490. --- "\1", "\2", etc. are also returned. Example: >vim
  5491. --- " Assuming line 2 in buffer 2 contains "acd"
  5492. --- echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
  5493. --- \ {'submatches': v:true})
  5494. --- < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5495. --- The "submatches" List always contains 9 items. If a submatch
  5496. --- is not found, then an empty string is returned for that
  5497. --- submatch.
  5498. ---
  5499. --- @param buf string|integer
  5500. --- @param pat string
  5501. --- @param lnum string|integer
  5502. --- @param end_ string|integer
  5503. --- @param dict? table
  5504. --- @return any
  5505. function vim.fn.matchbufline(buf, pat, lnum, end_, dict) end
  5506. --- Deletes a match with ID {id} previously defined by |matchadd()|
  5507. --- or one of the |:match| commands. Returns 0 if successful,
  5508. --- otherwise -1. See example for |matchadd()|. All matches can
  5509. --- be deleted in one operation by |clearmatches()|.
  5510. --- If {win} is specified, use the window with this number or
  5511. --- window ID instead of the current window.
  5512. ---
  5513. --- @param id integer
  5514. --- @param win? integer
  5515. --- @return any
  5516. function vim.fn.matchdelete(id, win) end
  5517. --- Same as |match()|, but return the index of first character
  5518. --- after the match. Example: >vim
  5519. --- echo matchend("testing", "ing")
  5520. --- <results in "7".
  5521. --- *strspn()* *strcspn()*
  5522. --- Vim doesn't have a strspn() or strcspn() function, but you can
  5523. --- do it with matchend(): >vim
  5524. --- let span = matchend(line, '[a-zA-Z]')
  5525. --- let span = matchend(line, '[^a-zA-Z]')
  5526. --- <Except that -1 is returned when there are no matches.
  5527. ---
  5528. --- The {start}, if given, has the same meaning as for |match()|. >vim
  5529. --- echo matchend("testing", "ing", 2)
  5530. --- <results in "7". >vim
  5531. --- echo matchend("testing", "ing", 5)
  5532. --- <result is "-1".
  5533. --- When {expr} is a |List| the result is equal to |match()|.
  5534. ---
  5535. --- @param expr any
  5536. --- @param pat string
  5537. --- @param start? integer
  5538. --- @param count? integer
  5539. --- @return any
  5540. function vim.fn.matchend(expr, pat, start, count) end
  5541. --- If {list} is a list of strings, then returns a |List| with all
  5542. --- the strings in {list} that fuzzy match {str}. The strings in
  5543. --- the returned list are sorted based on the matching score.
  5544. ---
  5545. --- The optional {dict} argument always supports the following
  5546. --- items:
  5547. --- matchseq When this item is present return only matches
  5548. --- that contain the characters in {str} in the
  5549. --- given sequence.
  5550. --- limit Maximum number of matches in {list} to be
  5551. --- returned. Zero means no limit.
  5552. ---
  5553. --- If {list} is a list of dictionaries, then the optional {dict}
  5554. --- argument supports the following additional items:
  5555. --- key Key of the item which is fuzzy matched against
  5556. --- {str}. The value of this item should be a
  5557. --- string.
  5558. --- text_cb |Funcref| that will be called for every item
  5559. --- in {list} to get the text for fuzzy matching.
  5560. --- This should accept a dictionary item as the
  5561. --- argument and return the text for that item to
  5562. --- use for fuzzy matching.
  5563. ---
  5564. --- {str} is treated as a literal string and regular expression
  5565. --- matching is NOT supported. The maximum supported {str} length
  5566. --- is 256.
  5567. ---
  5568. --- When {str} has multiple words each separated by white space,
  5569. --- then the list of strings that have all the words is returned.
  5570. ---
  5571. --- If there are no matching strings or there is an error, then an
  5572. --- empty list is returned. If length of {str} is greater than
  5573. --- 256, then returns an empty list.
  5574. ---
  5575. --- When {limit} is given, matchfuzzy() will find up to this
  5576. --- number of matches in {list} and return them in sorted order.
  5577. ---
  5578. --- Refer to |fuzzy-matching| for more information about fuzzy
  5579. --- matching strings.
  5580. ---
  5581. --- Example: >vim
  5582. --- echo matchfuzzy(["clay", "crow"], "cay")
  5583. --- <results in ["clay"]. >vim
  5584. --- echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
  5585. --- <results in a list of buffer names fuzzy matching "ndl". >vim
  5586. --- echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
  5587. --- <results in a list of buffer information dicts with buffer
  5588. --- names fuzzy matching "ndl". >vim
  5589. --- echo getbufinfo()->matchfuzzy("spl",
  5590. --- \ {'text_cb' : {v -> v.name}})
  5591. --- <results in a list of buffer information dicts with buffer
  5592. --- names fuzzy matching "spl". >vim
  5593. --- echo v:oldfiles->matchfuzzy("test")
  5594. --- <results in a list of file names fuzzy matching "test". >vim
  5595. --- let l = readfile("buffer.c")->matchfuzzy("str")
  5596. --- <results in a list of lines in "buffer.c" fuzzy matching "str". >vim
  5597. --- echo ['one two', 'two one']->matchfuzzy('two one')
  5598. --- <results in `['two one', 'one two']` . >vim
  5599. --- echo ['one two', 'two one']->matchfuzzy('two one',
  5600. --- \ {'matchseq': 1})
  5601. --- <results in `['two one']`.
  5602. ---
  5603. --- @param list any[]
  5604. --- @param str string
  5605. --- @param dict? string
  5606. --- @return any
  5607. function vim.fn.matchfuzzy(list, str, dict) end
  5608. --- Same as |matchfuzzy()|, but returns the list of matched
  5609. --- strings, the list of character positions where characters
  5610. --- in {str} matches and a list of matching scores. You can
  5611. --- use |byteidx()| to convert a character position to a byte
  5612. --- position.
  5613. ---
  5614. --- If {str} matches multiple times in a string, then only the
  5615. --- positions for the best match is returned.
  5616. ---
  5617. --- If there are no matching strings or there is an error, then a
  5618. --- list with three empty list items is returned.
  5619. ---
  5620. --- Example: >vim
  5621. --- echo matchfuzzypos(['testing'], 'tsg')
  5622. --- <results in [["testing"], [[0, 2, 6]], [99]] >vim
  5623. --- echo matchfuzzypos(['clay', 'lacy'], 'la')
  5624. --- <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
  5625. --- echo [{'text': 'hello', 'id' : 10}]
  5626. --- \ ->matchfuzzypos('ll', {'key' : 'text'})
  5627. --- <results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
  5628. ---
  5629. --- @param list any[]
  5630. --- @param str string
  5631. --- @param dict? string
  5632. --- @return any
  5633. function vim.fn.matchfuzzypos(list, str, dict) end
  5634. --- Same as |match()|, but return a |List|. The first item in the
  5635. --- list is the matched string, same as what matchstr() would
  5636. --- return. Following items are submatches, like "\1", "\2", etc.
  5637. --- in |:substitute|. When an optional submatch didn't match an
  5638. --- empty string is used. Example: >vim
  5639. --- echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
  5640. --- <Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
  5641. --- When there is no match an empty list is returned.
  5642. ---
  5643. --- You can pass in a List, but that is not very useful.
  5644. ---
  5645. --- @param expr any
  5646. --- @param pat string
  5647. --- @param start? integer
  5648. --- @param count? integer
  5649. --- @return any
  5650. function vim.fn.matchlist(expr, pat, start, count) end
  5651. --- Same as |match()|, but return the matched string. Example: >vim
  5652. --- echo matchstr("testing", "ing")
  5653. --- <results in "ing".
  5654. --- When there is no match "" is returned.
  5655. --- The {start}, if given, has the same meaning as for |match()|. >vim
  5656. --- echo matchstr("testing", "ing", 2)
  5657. --- <results in "ing". >vim
  5658. --- echo matchstr("testing", "ing", 5)
  5659. --- <result is "".
  5660. --- When {expr} is a |List| then the matching item is returned.
  5661. --- The type isn't changed, it's not necessarily a String.
  5662. ---
  5663. --- @param expr any
  5664. --- @param pat string
  5665. --- @param start? integer
  5666. --- @param count? integer
  5667. --- @return any
  5668. function vim.fn.matchstr(expr, pat, start, count) end
  5669. --- Returns the |List| of matches in {list} where {pat} matches.
  5670. --- {list} is a |List| of strings. {pat} is matched against each
  5671. --- string in {list}.
  5672. ---
  5673. --- The {dict} argument supports following items:
  5674. --- submatches include submatch information (|/\(|)
  5675. ---
  5676. --- For each match, a |Dict| with the following items is returned:
  5677. --- byteidx starting byte index of the match.
  5678. --- idx index in {list} of the match.
  5679. --- text matched string
  5680. --- submatches a List of submatches. Present only if
  5681. --- "submatches" is set to v:true in {dict}.
  5682. ---
  5683. --- See |match-pattern| for information about the effect of some
  5684. --- option settings on the pattern.
  5685. ---
  5686. --- Example: >vim
  5687. --- echo matchstrlist(['tik tok'], '\<\k\+\>')
  5688. --- < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
  5689. --- echo matchstrlist(['a', 'b'], '\<\k\+\>')
  5690. --- < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
  5691. ---
  5692. --- If "submatches" is present and is v:true, then submatches like
  5693. --- "\1", "\2", etc. are also returned. Example: >vim
  5694. --- echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
  5695. --- \ #{submatches: v:true})
  5696. --- < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5697. --- The "submatches" List always contains 9 items. If a submatch
  5698. --- is not found, then an empty string is returned for that
  5699. --- submatch.
  5700. ---
  5701. --- @param list string[]
  5702. --- @param pat string
  5703. --- @param dict? table
  5704. --- @return any
  5705. function vim.fn.matchstrlist(list, pat, dict) end
  5706. --- Same as |matchstr()|, but return the matched string, the start
  5707. --- position and the end position of the match. Example: >vim
  5708. --- echo matchstrpos("testing", "ing")
  5709. --- <results in ["ing", 4, 7].
  5710. --- When there is no match ["", -1, -1] is returned.
  5711. --- The {start}, if given, has the same meaning as for |match()|. >vim
  5712. --- echo matchstrpos("testing", "ing", 2)
  5713. --- <results in ["ing", 4, 7]. >vim
  5714. --- echo matchstrpos("testing", "ing", 5)
  5715. --- <result is ["", -1, -1].
  5716. --- When {expr} is a |List| then the matching item, the index
  5717. --- of first item where {pat} matches, the start position and the
  5718. --- end position of the match are returned. >vim
  5719. --- echo matchstrpos([1, '__x'], '\a')
  5720. --- <result is ["x", 1, 2, 3].
  5721. --- The type isn't changed, it's not necessarily a String.
  5722. ---
  5723. --- @param expr any
  5724. --- @param pat string
  5725. --- @param start? integer
  5726. --- @param count? integer
  5727. --- @return any
  5728. function vim.fn.matchstrpos(expr, pat, start, count) end
  5729. --- Return the maximum value of all items in {expr}. Example: >vim
  5730. --- echo max([apples, pears, oranges])
  5731. ---
  5732. --- <{expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5733. --- it returns the maximum of all values in the Dictionary.
  5734. --- If {expr} is neither a List nor a Dictionary, or one of the
  5735. --- items in {expr} cannot be used as a Number this results in
  5736. --- an error. An empty |List| or |Dictionary| results in zero.
  5737. ---
  5738. --- @param expr any
  5739. --- @return number
  5740. function vim.fn.max(expr) end
  5741. --- Returns a |List| of |Dictionaries| describing |menus| (defined
  5742. --- by |:menu|, |:amenu|, …), including |hidden-menus|.
  5743. ---
  5744. --- {path} matches a menu by name, or all menus if {path} is an
  5745. --- empty string. Example: >vim
  5746. --- echo menu_get('File','')
  5747. --- echo menu_get('')
  5748. --- <
  5749. --- {modes} is a string of zero or more modes (see |maparg()| or
  5750. --- |creating-menus| for the list of modes). "a" means "all".
  5751. ---
  5752. --- Example: >vim
  5753. --- nnoremenu &Test.Test inormal
  5754. --- inoremenu Test.Test insert
  5755. --- vnoremenu Test.Test x
  5756. --- echo menu_get("")
  5757. ---
  5758. --- <returns something like this: >
  5759. ---
  5760. --- [ {
  5761. --- "hidden": 0,
  5762. --- "name": "Test",
  5763. --- "priority": 500,
  5764. --- "shortcut": 84,
  5765. --- "submenus": [ {
  5766. --- "hidden": 0,
  5767. --- "mappings": {
  5768. --- i": {
  5769. --- "enabled": 1,
  5770. --- "noremap": 1,
  5771. --- "rhs": "insert",
  5772. --- "sid": 1,
  5773. --- "silent": 0
  5774. --- },
  5775. --- n": { ... },
  5776. --- s": { ... },
  5777. --- v": { ... }
  5778. --- },
  5779. --- "name": "Test",
  5780. --- "priority": 500,
  5781. --- "shortcut": 0
  5782. --- } ]
  5783. --- } ]
  5784. --- <
  5785. ---
  5786. --- @param path string
  5787. --- @param modes? string
  5788. --- @return any
  5789. function vim.fn.menu_get(path, modes) end
  5790. --- Return information about the specified menu {name} in
  5791. --- mode {mode}. The menu name should be specified without the
  5792. --- shortcut character ('&'). If {name} is "", then the top-level
  5793. --- menu names are returned.
  5794. ---
  5795. --- {mode} can be one of these strings:
  5796. --- "n" Normal
  5797. --- "v" Visual (including Select)
  5798. --- "o" Operator-pending
  5799. --- "i" Insert
  5800. --- "c" Cmd-line
  5801. --- "s" Select
  5802. --- "x" Visual
  5803. --- "t" Terminal-Job
  5804. --- "" Normal, Visual and Operator-pending
  5805. --- "!" Insert and Cmd-line
  5806. --- When {mode} is omitted, the modes for "" are used.
  5807. ---
  5808. --- Returns a |Dictionary| containing the following items:
  5809. --- accel menu item accelerator text |menu-text|
  5810. --- display display name (name without '&')
  5811. --- enabled v:true if this menu item is enabled
  5812. --- Refer to |:menu-enable|
  5813. --- icon name of the icon file (for toolbar)
  5814. --- |toolbar-icon|
  5815. --- iconidx index of a built-in icon
  5816. --- modes modes for which the menu is defined. In
  5817. --- addition to the modes mentioned above, these
  5818. --- characters will be used:
  5819. --- " " Normal, Visual and Operator-pending
  5820. --- name menu item name.
  5821. --- noremenu v:true if the {rhs} of the menu item is not
  5822. --- remappable else v:false.
  5823. --- priority menu order priority |menu-priority|
  5824. --- rhs right-hand-side of the menu item. The returned
  5825. --- string has special characters translated like
  5826. --- in the output of the ":menu" command listing.
  5827. --- When the {rhs} of a menu item is empty, then
  5828. --- "<Nop>" is returned.
  5829. --- script v:true if script-local remapping of {rhs} is
  5830. --- allowed else v:false. See |:menu-script|.
  5831. --- shortcut shortcut key (character after '&' in
  5832. --- the menu name) |menu-shortcut|
  5833. --- silent v:true if the menu item is created
  5834. --- with <silent> argument |:menu-silent|
  5835. --- submenus |List| containing the names of
  5836. --- all the submenus. Present only if the menu
  5837. --- item has submenus.
  5838. ---
  5839. --- Returns an empty dictionary if the menu item is not found.
  5840. ---
  5841. --- Examples: >vim
  5842. --- echo menu_info('Edit.Cut')
  5843. --- echo menu_info('File.Save', 'n')
  5844. ---
  5845. --- " Display the entire menu hierarchy in a buffer
  5846. --- func ShowMenu(name, pfx)
  5847. --- let m = menu_info(a:name)
  5848. --- call append(line('$'), a:pfx .. m.display)
  5849. --- for child in m->get('submenus', [])
  5850. --- call ShowMenu(a:name .. '.' .. escape(child, '.'),
  5851. --- \ a:pfx .. ' ')
  5852. --- endfor
  5853. --- endfunc
  5854. --- new
  5855. --- for topmenu in menu_info('').submenus
  5856. --- call ShowMenu(topmenu, '')
  5857. --- endfor
  5858. --- <
  5859. ---
  5860. --- @param name string
  5861. --- @param mode? string
  5862. --- @return any
  5863. function vim.fn.menu_info(name, mode) end
  5864. --- Return the minimum value of all items in {expr}. Example: >vim
  5865. --- echo min([apples, pears, oranges])
  5866. ---
  5867. --- <{expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5868. --- it returns the minimum of all values in the Dictionary.
  5869. --- If {expr} is neither a List nor a Dictionary, or one of the
  5870. --- items in {expr} cannot be used as a Number this results in
  5871. --- an error. An empty |List| or |Dictionary| results in zero.
  5872. ---
  5873. --- @param expr any
  5874. --- @return number
  5875. function vim.fn.min(expr) end
  5876. --- Create directory {name}.
  5877. ---
  5878. --- When {flags} is present it must be a string. An empty string
  5879. --- has no effect.
  5880. ---
  5881. --- {flags} can contain these character flags:
  5882. --- "p" intermediate directories will be created as necessary
  5883. --- "D" {name} will be deleted at the end of the current
  5884. --- function, but not recursively |:defer|
  5885. --- "R" {name} will be deleted recursively at the end of the
  5886. --- current function |:defer|
  5887. ---
  5888. --- Note that when {name} has more than one part and "p" is used
  5889. --- some directories may already exist. Only the first one that
  5890. --- is created and what it contains is scheduled to be deleted.
  5891. --- E.g. when using: >vim
  5892. --- call mkdir('subdir/tmp/autoload', 'pR')
  5893. --- <and "subdir" already exists then "subdir/tmp" will be
  5894. --- scheduled for deletion, like with: >vim
  5895. --- defer delete('subdir/tmp', 'rf')
  5896. --- <
  5897. --- If {prot} is given it is used to set the protection bits of
  5898. --- the new directory. The default is 0o755 (rwxr-xr-x: r/w for
  5899. --- the user, readable for others). Use 0o700 to make it
  5900. --- unreadable for others.
  5901. ---
  5902. --- {prot} is applied for all parts of {name}. Thus if you create
  5903. --- /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
  5904. --- call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
  5905. ---
  5906. --- <This function is not available in the |sandbox|.
  5907. ---
  5908. --- If you try to create an existing directory with {flags} set to
  5909. --- "p" mkdir() will silently exit.
  5910. ---
  5911. --- The function result is a Number, which is TRUE if the call was
  5912. --- successful or FALSE if the directory creation failed or partly
  5913. --- failed.
  5914. ---
  5915. --- @param name string
  5916. --- @param flags? string
  5917. --- @param prot? string
  5918. --- @return integer
  5919. function vim.fn.mkdir(name, flags, prot) end
  5920. --- Return a string that indicates the current mode.
  5921. --- If {expr} is supplied and it evaluates to a non-zero Number or
  5922. --- a non-empty String (|non-zero-arg|), then the full mode is
  5923. --- returned, otherwise only the first letter is returned.
  5924. --- Also see |state()|.
  5925. ---
  5926. --- n Normal
  5927. --- no Operator-pending
  5928. --- nov Operator-pending (forced charwise |o_v|)
  5929. --- noV Operator-pending (forced linewise |o_V|)
  5930. --- noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
  5931. --- CTRL-V is one character
  5932. --- niI Normal using |i_CTRL-O| in |Insert-mode|
  5933. --- niR Normal using |i_CTRL-O| in |Replace-mode|
  5934. --- niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
  5935. --- nt Normal in |terminal-emulator| (insert goes to
  5936. --- Terminal mode)
  5937. --- ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
  5938. --- v Visual by character
  5939. --- vs Visual by character using |v_CTRL-O| in Select mode
  5940. --- V Visual by line
  5941. --- Vs Visual by line using |v_CTRL-O| in Select mode
  5942. --- CTRL-V Visual blockwise
  5943. --- CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
  5944. --- s Select by character
  5945. --- S Select by line
  5946. --- CTRL-S Select blockwise
  5947. --- i Insert
  5948. --- ic Insert mode completion |compl-generic|
  5949. --- ix Insert mode |i_CTRL-X| completion
  5950. --- R Replace |R|
  5951. --- Rc Replace mode completion |compl-generic|
  5952. --- Rx Replace mode |i_CTRL-X| completion
  5953. --- Rv Virtual Replace |gR|
  5954. --- Rvc Virtual Replace mode completion |compl-generic|
  5955. --- Rvx Virtual Replace mode |i_CTRL-X| completion
  5956. --- c Command-line editing
  5957. --- cr Command-line editing overstrike mode |c_<Insert>|
  5958. --- cv Vim Ex mode |gQ|
  5959. --- cvr Vim Ex mode while in overstrike mode |c_<Insert>|
  5960. --- r Hit-enter prompt
  5961. --- rm The -- more -- prompt
  5962. --- r? A |:confirm| query of some sort
  5963. --- ! Shell or external command is executing
  5964. --- t Terminal mode: keys go to the job
  5965. ---
  5966. --- This is useful in the 'statusline' option or RPC calls. In
  5967. --- most other places it always returns "c" or "n".
  5968. --- Note that in the future more modes and more specific modes may
  5969. --- be added. It's better not to compare the whole string but only
  5970. --- the leading character(s).
  5971. --- Also see |visualmode()|.
  5972. ---
  5973. --- @param expr? any
  5974. --- @return any
  5975. function vim.fn.mode(expr) end
  5976. --- Convert a list of Vimscript objects to msgpack. Returned value is a
  5977. --- |readfile()|-style list. When {type} contains "B", a |Blob| is
  5978. --- returned instead. Example: >vim
  5979. --- call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
  5980. --- <or, using a |Blob|: >vim
  5981. --- call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
  5982. --- <
  5983. --- This will write the single 0x80 byte to a `fname.mpack` file
  5984. --- (dictionary with zero items is represented by 0x80 byte in
  5985. --- messagepack).
  5986. ---
  5987. --- Limitations: *E5004* *E5005*
  5988. --- 1. |Funcref|s cannot be dumped.
  5989. --- 2. Containers that reference themselves cannot be dumped.
  5990. --- 3. Dictionary keys are always dumped as STR strings.
  5991. --- 4. Other strings and |Blob|s are always dumped as BIN strings.
  5992. --- 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
  5993. ---
  5994. --- @param list any
  5995. --- @param type? any
  5996. --- @return any
  5997. function vim.fn.msgpackdump(list, type) end
  5998. --- Convert a |readfile()|-style list or a |Blob| to a list of
  5999. --- Vimscript objects.
  6000. --- Example: >vim
  6001. --- let fname = expand('~/.config/nvim/shada/main.shada')
  6002. --- let mpack = readfile(fname, 'b')
  6003. --- let shada_objects = msgpackparse(mpack)
  6004. --- <This will read ~/.config/nvim/shada/main.shada file to
  6005. --- `shada_objects` list.
  6006. ---
  6007. --- Limitations:
  6008. --- 1. Mapping ordering is not preserved unless messagepack
  6009. --- mapping is dumped using generic mapping
  6010. --- (|msgpack-special-map|).
  6011. --- 2. Since the parser aims to preserve all data untouched
  6012. --- (except for 1.) some strings are parsed to
  6013. --- |msgpack-special-dict| format which is not convenient to
  6014. --- use.
  6015. --- *msgpack-special-dict*
  6016. --- Some messagepack strings may be parsed to special
  6017. --- dictionaries. Special dictionaries are dictionaries which
  6018. ---
  6019. --- 1. Contain exactly two keys: `_TYPE` and `_VAL`.
  6020. --- 2. `_TYPE` key is one of the types found in |v:msgpack_types|
  6021. --- variable.
  6022. --- 3. Value for `_VAL` has the following format (Key column
  6023. --- contains name of the key from |v:msgpack_types|):
  6024. ---
  6025. --- Key Value ~
  6026. --- nil Zero, ignored when dumping. Not returned by
  6027. --- |msgpackparse()| since |v:null| was introduced.
  6028. --- boolean One or zero. When dumping it is only checked that
  6029. --- value is a |Number|. Not returned by |msgpackparse()|
  6030. --- since |v:true| and |v:false| were introduced.
  6031. --- integer |List| with four numbers: sign (-1 or 1), highest two
  6032. --- bits, number with bits from 62nd to 31st, lowest 31
  6033. --- bits. I.e. to get actual number one will need to use
  6034. --- code like >
  6035. --- _VAL[0] * ((_VAL[1] << 62)
  6036. --- & (_VAL[2] << 31)
  6037. --- & _VAL[3])
  6038. --- < Special dictionary with this type will appear in
  6039. --- |msgpackparse()| output under one of the following
  6040. --- circumstances:
  6041. --- 1. |Number| is 32-bit and value is either above
  6042. --- INT32_MAX or below INT32_MIN.
  6043. --- 2. |Number| is 64-bit and value is above INT64_MAX. It
  6044. --- cannot possibly be below INT64_MIN because msgpack
  6045. --- C parser does not support such values.
  6046. --- float |Float|. This value cannot possibly appear in
  6047. --- |msgpackparse()| output.
  6048. --- string |String|, or |Blob| if binary string contains zero
  6049. --- byte. This value cannot appear in |msgpackparse()|
  6050. --- output since blobs were introduced.
  6051. --- array |List|. This value cannot appear in |msgpackparse()|
  6052. --- output.
  6053. --- *msgpack-special-map*
  6054. --- map |List| of |List|s with two items (key and value) each.
  6055. --- This value will appear in |msgpackparse()| output if
  6056. --- parsed mapping contains one of the following keys:
  6057. --- 1. Any key that is not a string (including keys which
  6058. --- are binary strings).
  6059. --- 2. String with NUL byte inside.
  6060. --- 3. Duplicate key.
  6061. --- ext |List| with two values: first is a signed integer
  6062. --- representing extension type. Second is
  6063. --- |readfile()|-style list of strings.
  6064. ---
  6065. --- @param data any
  6066. --- @return any
  6067. function vim.fn.msgpackparse(data) end
  6068. --- Return the line number of the first line at or below {lnum}
  6069. --- that is not blank. Example: >vim
  6070. --- if getline(nextnonblank(1)) =~ "Java" | endif
  6071. --- <When {lnum} is invalid or there is no non-blank line at or
  6072. --- below it, zero is returned.
  6073. --- {lnum} is used like with |getline()|.
  6074. --- See also |prevnonblank()|.
  6075. ---
  6076. --- @param lnum integer
  6077. --- @return integer
  6078. function vim.fn.nextnonblank(lnum) end
  6079. --- Return a string with a single character, which has the number
  6080. --- value {expr}. Examples: >vim
  6081. --- echo nr2char(64) " returns '\@'
  6082. --- echo nr2char(32) " returns ' '
  6083. --- <Example for "utf-8": >vim
  6084. --- echo nr2char(300) " returns I with bow character
  6085. --- <
  6086. --- UTF-8 encoding is always used, {utf8} option has no effect,
  6087. --- and exists only for backwards-compatibility.
  6088. --- Note that a NUL character in the file is specified with
  6089. --- nr2char(10), because NULs are represented with newline
  6090. --- characters. nr2char(0) is a real NUL and terminates the
  6091. --- string, thus results in an empty string.
  6092. ---
  6093. --- @param expr integer
  6094. --- @param utf8? boolean
  6095. --- @return string
  6096. function vim.fn.nr2char(expr, utf8) end
  6097. --- Bitwise OR on the two arguments. The arguments are converted
  6098. --- to a number. A List, Dict or Float argument causes an error.
  6099. --- Also see `and()` and `xor()`.
  6100. --- Example: >vim
  6101. --- let bits = or(bits, 0x80)
  6102. ---
  6103. --- <Rationale: The reason this is a function and not using the "|"
  6104. --- character like many languages, is that Vi has always used "|"
  6105. --- to separate commands. In many places it would not be clear if
  6106. --- "|" is an operator or a command separator.
  6107. ---
  6108. --- @param expr number
  6109. --- @param expr1 number
  6110. --- @return any
  6111. vim.fn['or'] = function(expr, expr1) end
  6112. --- Shorten directory names in the path {path} and return the
  6113. --- result. The tail, the file name, is kept as-is. The other
  6114. --- components in the path are reduced to {len} letters in length.
  6115. --- If {len} is omitted or smaller than 1 then 1 is used (single
  6116. --- letters). Leading '~' and '.' characters are kept. Examples: >vim
  6117. --- echo pathshorten('~/.config/nvim/autoload/file1.vim')
  6118. --- < ~/.c/n/a/file1.vim ~
  6119. --- >vim
  6120. --- echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
  6121. --- < ~/.co/nv/au/file2.vim ~
  6122. --- It doesn't matter if the path exists or not.
  6123. --- Returns an empty string on error.
  6124. ---
  6125. --- @param path string
  6126. --- @param len? integer
  6127. --- @return string
  6128. function vim.fn.pathshorten(path, len) end
  6129. --- Evaluate |perl| expression {expr} and return its result
  6130. --- converted to Vim data structures.
  6131. --- Numbers and strings are returned as they are (strings are
  6132. --- copied though).
  6133. --- Lists are represented as Vim |List| type.
  6134. --- Dictionaries are represented as Vim |Dictionary| type,
  6135. --- non-string keys result in error.
  6136. ---
  6137. --- Note: If you want an array or hash, {expr} must return a
  6138. --- reference to it.
  6139. --- Example: >vim
  6140. --- echo perleval('[1 .. 4]')
  6141. --- < [1, 2, 3, 4]
  6142. ---
  6143. --- @param expr any
  6144. --- @return any
  6145. function vim.fn.perleval(expr) end
  6146. --- Return the power of {x} to the exponent {y} as a |Float|.
  6147. --- {x} and {y} must evaluate to a |Float| or a |Number|.
  6148. --- Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
  6149. --- Examples: >vim
  6150. --- echo pow(3, 3)
  6151. --- < 27.0 >vim
  6152. --- echo pow(2, 16)
  6153. --- < 65536.0 >vim
  6154. --- echo pow(32, 0.20)
  6155. --- < 2.0
  6156. ---
  6157. --- @param x number
  6158. --- @param y number
  6159. --- @return number
  6160. function vim.fn.pow(x, y) end
  6161. --- Return the line number of the first line at or above {lnum}
  6162. --- that is not blank. Example: >vim
  6163. --- let ind = indent(prevnonblank(v:lnum - 1))
  6164. --- <When {lnum} is invalid or there is no non-blank line at or
  6165. --- above it, zero is returned.
  6166. --- {lnum} is used like with |getline()|.
  6167. --- Also see |nextnonblank()|.
  6168. ---
  6169. --- @param lnum integer
  6170. --- @return integer
  6171. function vim.fn.prevnonblank(lnum) end
  6172. --- Return a String with {fmt}, where "%" items are replaced by
  6173. --- the formatted form of their respective arguments. Example: >vim
  6174. --- echo printf("%4d: E%d %.30s", lnum, errno, msg)
  6175. --- <May result in:
  6176. --- " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
  6177. ---
  6178. --- When used as a |method| the base is passed as the second
  6179. --- argument: >vim
  6180. --- Compute()->printf("result: %d")
  6181. --- <
  6182. --- You can use `call()` to pass the items as a list.
  6183. ---
  6184. --- Often used items are:
  6185. --- %s string
  6186. --- %6S string right-aligned in 6 display cells
  6187. --- %6s string right-aligned in 6 bytes
  6188. --- %.9s string truncated to 9 bytes
  6189. --- %c single byte
  6190. --- %d decimal number
  6191. --- %5d decimal number padded with spaces to 5 characters
  6192. --- %b binary number
  6193. --- %08b binary number padded with zeros to at least 8 characters
  6194. --- %B binary number using upper case letters
  6195. --- %x hex number
  6196. --- %04x hex number padded with zeros to at least 4 characters
  6197. --- %X hex number using upper case letters
  6198. --- %o octal number
  6199. --- %f floating point number as 12.23, inf, -inf or nan
  6200. --- %F floating point number as 12.23, INF, -INF or NAN
  6201. --- %e floating point number as 1.23e3, inf, -inf or nan
  6202. --- %E floating point number as 1.23E3, INF, -INF or NAN
  6203. --- %g floating point number, as %f or %e depending on value
  6204. --- %G floating point number, as %F or %E depending on value
  6205. --- %% the % character itself
  6206. --- %p representation of the pointer to the container
  6207. ---
  6208. --- Conversion specifications start with '%' and end with the
  6209. --- conversion type. All other characters are copied unchanged to
  6210. --- the result.
  6211. ---
  6212. --- The "%" starts a conversion specification. The following
  6213. --- arguments appear in sequence:
  6214. ---
  6215. --- % [pos-argument] [flags] [field-width] [.precision] type
  6216. ---
  6217. --- pos-argument
  6218. --- At most one positional argument specifier. These
  6219. --- take the form {n$}, where n is >= 1.
  6220. ---
  6221. --- flags
  6222. --- Zero or more of the following flags:
  6223. ---
  6224. --- # The value should be converted to an "alternate
  6225. --- form". For c, d, and s conversions, this option
  6226. --- has no effect. For o conversions, the precision
  6227. --- of the number is increased to force the first
  6228. --- character of the output string to a zero (except
  6229. --- if a zero value is printed with an explicit
  6230. --- precision of zero).
  6231. --- For x and X conversions, a non-zero result has
  6232. --- the string "0x" (or "0X" for X conversions)
  6233. --- prepended to it.
  6234. ---
  6235. --- 0 (zero) Zero padding. For all conversions the converted
  6236. --- value is padded on the left with zeros rather
  6237. --- than blanks. If a precision is given with a
  6238. --- numeric conversion (d, o, x, and X), the 0 flag
  6239. --- is ignored.
  6240. ---
  6241. --- - A negative field width flag; the converted value
  6242. --- is to be left adjusted on the field boundary.
  6243. --- The converted value is padded on the right with
  6244. --- blanks, rather than on the left with blanks or
  6245. --- zeros. A - overrides a 0 if both are given.
  6246. ---
  6247. --- ' ' (space) A blank should be left before a positive
  6248. --- number produced by a signed conversion (d).
  6249. ---
  6250. --- + A sign must always be placed before a number
  6251. --- produced by a signed conversion. A + overrides
  6252. --- a space if both are used.
  6253. ---
  6254. --- field-width
  6255. --- An optional decimal digit string specifying a minimum
  6256. --- field width. If the converted value has fewer bytes
  6257. --- than the field width, it will be padded with spaces on
  6258. --- the left (or right, if the left-adjustment flag has
  6259. --- been given) to fill out the field width. For the S
  6260. --- conversion the count is in cells.
  6261. ---
  6262. --- .precision
  6263. --- An optional precision, in the form of a period '.'
  6264. --- followed by an optional digit string. If the digit
  6265. --- string is omitted, the precision is taken as zero.
  6266. --- This gives the minimum number of digits to appear for
  6267. --- d, o, x, and X conversions, the maximum number of
  6268. --- bytes to be printed from a string for s conversions,
  6269. --- or the maximum number of cells to be printed from a
  6270. --- string for S conversions.
  6271. --- For floating point it is the number of digits after
  6272. --- the decimal point.
  6273. ---
  6274. --- type
  6275. --- A character that specifies the type of conversion to
  6276. --- be applied, see below.
  6277. ---
  6278. --- A field width or precision, or both, may be indicated by an
  6279. --- asterisk "*" instead of a digit string. In this case, a
  6280. --- Number argument supplies the field width or precision. A
  6281. --- negative field width is treated as a left adjustment flag
  6282. --- followed by a positive field width; a negative precision is
  6283. --- treated as though it were missing. Example: >vim
  6284. --- echo printf("%d: %.*s", nr, width, line)
  6285. --- <This limits the length of the text used from "line" to
  6286. --- "width" bytes.
  6287. ---
  6288. --- If the argument to be formatted is specified using a
  6289. --- positional argument specifier, and a '*' is used to indicate
  6290. --- that a number argument is to be used to specify the width or
  6291. --- precision, the argument(s) to be used must also be specified
  6292. --- using a {n$} positional argument specifier. See |printf-$|.
  6293. ---
  6294. --- The conversion specifiers and their meanings are:
  6295. ---
  6296. --- *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
  6297. --- dbBoxX The Number argument is converted to signed decimal (d),
  6298. --- unsigned binary (b and B), unsigned octal (o), or
  6299. --- unsigned hexadecimal (x and X) notation. The letters
  6300. --- "abcdef" are used for x conversions; the letters
  6301. --- "ABCDEF" are used for X conversions. The precision, if
  6302. --- any, gives the minimum number of digits that must
  6303. --- appear; if the converted value requires fewer digits, it
  6304. --- is padded on the left with zeros. In no case does a
  6305. --- non-existent or small field width cause truncation of a
  6306. --- numeric field; if the result of a conversion is wider
  6307. --- than the field width, the field is expanded to contain
  6308. --- the conversion result.
  6309. --- The 'h' modifier indicates the argument is 16 bits.
  6310. --- The 'l' modifier indicates the argument is a long
  6311. --- integer. The size will be 32 bits or 64 bits
  6312. --- depending on your platform.
  6313. --- The "ll" modifier indicates the argument is 64 bits.
  6314. --- The b and B conversion specifiers never take a width
  6315. --- modifier and always assume their argument is a 64 bit
  6316. --- integer.
  6317. --- Generally, these modifiers are not useful. They are
  6318. --- ignored when type is known from the argument.
  6319. ---
  6320. --- i alias for d
  6321. --- D alias for ld
  6322. --- U alias for lu
  6323. --- O alias for lo
  6324. ---
  6325. --- *printf-c*
  6326. --- c The Number argument is converted to a byte, and the
  6327. --- resulting character is written.
  6328. ---
  6329. --- *printf-s*
  6330. --- s The text of the String argument is used. If a
  6331. --- precision is specified, no more bytes than the number
  6332. --- specified are used.
  6333. --- If the argument is not a String type, it is
  6334. --- automatically converted to text with the same format
  6335. --- as ":echo".
  6336. --- *printf-S*
  6337. --- S The text of the String argument is used. If a
  6338. --- precision is specified, no more display cells than the
  6339. --- number specified are used.
  6340. ---
  6341. --- *printf-f* *E807*
  6342. --- f F The Float argument is converted into a string of the
  6343. --- form 123.456. The precision specifies the number of
  6344. --- digits after the decimal point. When the precision is
  6345. --- zero the decimal point is omitted. When the precision
  6346. --- is not specified 6 is used. A really big number
  6347. --- (out of range or dividing by zero) results in "inf"
  6348. --- or "-inf" with %f (INF or -INF with %F).
  6349. --- "0.0 / 0.0" results in "nan" with %f (NAN with %F).
  6350. --- Example: >vim
  6351. --- echo printf("%.2f", 12.115)
  6352. --- < 12.12
  6353. --- Note that roundoff depends on the system libraries.
  6354. --- Use |round()| when in doubt.
  6355. ---
  6356. --- *printf-e* *printf-E*
  6357. --- e E The Float argument is converted into a string of the
  6358. --- form 1.234e+03 or 1.234E+03 when using 'E'. The
  6359. --- precision specifies the number of digits after the
  6360. --- decimal point, like with 'f'.
  6361. ---
  6362. --- *printf-g* *printf-G*
  6363. --- g G The Float argument is converted like with 'f' if the
  6364. --- value is between 0.001 (inclusive) and 10000000.0
  6365. --- (exclusive). Otherwise 'e' is used for 'g' and 'E'
  6366. --- for 'G'. When no precision is specified superfluous
  6367. --- zeroes and '+' signs are removed, except for the zero
  6368. --- immediately after the decimal point. Thus 10000000.0
  6369. --- results in 1.0e7.
  6370. ---
  6371. --- *printf-%*
  6372. --- % A '%' is written. No argument is converted. The
  6373. --- complete conversion specification is "%%".
  6374. ---
  6375. --- When a Number argument is expected a String argument is also
  6376. --- accepted and automatically converted.
  6377. --- When a Float or String argument is expected a Number argument
  6378. --- is also accepted and automatically converted.
  6379. --- Any other argument type results in an error message.
  6380. ---
  6381. --- *E766* *E767*
  6382. --- The number of {exprN} arguments must exactly match the number
  6383. --- of "%" items. If there are not sufficient or too many
  6384. --- arguments an error is given. Up to 18 arguments can be used.
  6385. ---
  6386. --- *printf-$*
  6387. --- In certain languages, error and informative messages are
  6388. --- more readable when the order of words is different from the
  6389. --- corresponding message in English. To accommodate translations
  6390. --- having a different word order, positional arguments may be
  6391. --- used to indicate this. For instance: >vim
  6392. ---
  6393. --- #, c-format
  6394. --- msgid "%s returning %s"
  6395. --- msgstr "waarde %2$s komt terug van %1$s"
  6396. --- <
  6397. --- In this example, the sentence has its 2 string arguments
  6398. --- reversed in the output. >vim
  6399. ---
  6400. --- echo printf(
  6401. --- "In The Netherlands, vim's creator's name is: %1$s %2$s",
  6402. --- "Bram", "Moolenaar")
  6403. --- < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim
  6404. ---
  6405. --- echo printf(
  6406. --- "In Belgium, vim's creator's name is: %2$s %1$s",
  6407. --- "Bram", "Moolenaar")
  6408. --- < In Belgium, vim's creator's name is: Moolenaar Bram
  6409. ---
  6410. --- Width (and precision) can be specified using the '*' specifier.
  6411. --- In this case, you must specify the field width position in the
  6412. --- argument list. >vim
  6413. ---
  6414. --- echo printf("%1$*2$.*3$d", 1, 2, 3)
  6415. --- < 001 >vim
  6416. --- echo printf("%2$*3$.*1$d", 1, 2, 3)
  6417. --- < 2 >vim
  6418. --- echo printf("%3$*1$.*2$d", 1, 2, 3)
  6419. --- < 03 >vim
  6420. --- echo printf("%1$*2$.*3$g", 1.4142, 2, 3)
  6421. --- < 1.414
  6422. ---
  6423. --- You can mix specifying the width and/or precision directly
  6424. --- and via positional arguments: >vim
  6425. ---
  6426. --- echo printf("%1$4.*2$f", 1.4142135, 6)
  6427. --- < 1.414214 >vim
  6428. --- echo printf("%1$*2$.4f", 1.4142135, 6)
  6429. --- < 1.4142 >vim
  6430. --- echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
  6431. --- < 1.41
  6432. ---
  6433. --- You will get an overflow error |E1510|, when the field-width
  6434. --- or precision will result in a string longer than 6400 chars.
  6435. ---
  6436. --- *E1500*
  6437. --- You cannot mix positional and non-positional arguments: >vim
  6438. --- echo printf("%s%1$s", "One", "Two")
  6439. --- < E1500: Cannot mix positional and non-positional arguments:
  6440. --- %s%1$s
  6441. ---
  6442. --- *E1501*
  6443. --- You cannot skip a positional argument in a format string: >vim
  6444. --- echo printf("%3$s%1$s", "One", "Two", "Three")
  6445. --- < E1501: format argument 2 unused in $-style format:
  6446. --- %3$s%1$s
  6447. ---
  6448. --- *E1502*
  6449. --- You can re-use a [field-width] (or [precision]) argument: >vim
  6450. --- echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
  6451. --- < 1 at width 2 is: 01
  6452. ---
  6453. --- However, you can't use it as a different type: >vim
  6454. --- echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
  6455. --- < E1502: Positional argument 2 used as field width reused as
  6456. --- different type: long int/int
  6457. ---
  6458. --- *E1503*
  6459. --- When a positional argument is used, but not the correct number
  6460. --- or arguments is given, an error is raised: >vim
  6461. --- echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
  6462. --- < E1503: Positional argument 3 out of bounds: %1$d at width
  6463. --- %2$d is: %01$*2$.*3$d
  6464. ---
  6465. --- Only the first error is reported: >vim
  6466. --- echo printf("%01$*2$.*3$d %4$d", 1, 2)
  6467. --- < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
  6468. --- %4$d
  6469. ---
  6470. --- *E1504*
  6471. --- A positional argument can be used more than once: >vim
  6472. --- echo printf("%1$s %2$s %1$s", "One", "Two")
  6473. --- < One Two One
  6474. ---
  6475. --- However, you can't use a different type the second time: >vim
  6476. --- echo printf("%1$s %2$s %1$d", "One", "Two")
  6477. --- < E1504: Positional argument 1 type used inconsistently:
  6478. --- int/string
  6479. ---
  6480. --- *E1505*
  6481. --- Various other errors that lead to a format string being
  6482. --- wrongly formatted lead to: >vim
  6483. --- echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
  6484. --- < E1505: Invalid format specifier: %1$d at width %2$d is:
  6485. --- %01$*2$.3$d
  6486. ---
  6487. --- *E1507*
  6488. --- This internal error indicates that the logic to parse a
  6489. --- positional format argument ran into a problem that couldn't be
  6490. --- otherwise reported. Please file a bug against Vim if you run
  6491. --- into this, copying the exact format string and parameters that
  6492. --- were used.
  6493. ---
  6494. --- @param fmt string
  6495. --- @param expr1? any
  6496. --- @return string
  6497. function vim.fn.printf(fmt, expr1) end
  6498. --- Returns the effective prompt text for buffer {buf}. {buf} can
  6499. --- be a buffer name or number. See |prompt-buffer|.
  6500. ---
  6501. --- If the buffer doesn't exist or isn't a prompt buffer, an empty
  6502. --- string is returned.
  6503. ---
  6504. --- @param buf integer|string
  6505. --- @return any
  6506. function vim.fn.prompt_getprompt(buf) end
  6507. --- Set prompt callback for buffer {buf} to {expr}. When {expr}
  6508. --- is an empty string the callback is removed. This has only
  6509. --- effect if {buf} has 'buftype' set to "prompt".
  6510. ---
  6511. --- The callback is invoked when pressing Enter. The current
  6512. --- buffer will always be the prompt buffer. A new line for a
  6513. --- prompt is added before invoking the callback, thus the prompt
  6514. --- for which the callback was invoked will be in the last but one
  6515. --- line.
  6516. --- If the callback wants to add text to the buffer, it must
  6517. --- insert it above the last line, since that is where the current
  6518. --- prompt is. This can also be done asynchronously.
  6519. --- The callback is invoked with one argument, which is the text
  6520. --- that was entered at the prompt. This can be an empty string
  6521. --- if the user only typed Enter.
  6522. --- Example: >vim
  6523. --- func s:TextEntered(text)
  6524. --- if a:text == 'exit' || a:text == 'quit'
  6525. --- stopinsert
  6526. --- " Reset 'modified' to allow the buffer to be closed.
  6527. --- " We assume there is nothing useful to be saved.
  6528. --- set nomodified
  6529. --- close
  6530. --- else
  6531. --- " Do something useful with "a:text". In this example
  6532. --- " we just repeat it.
  6533. --- call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
  6534. --- endif
  6535. --- endfunc
  6536. --- call prompt_setcallback(bufnr(), function('s:TextEntered'))
  6537. --- <
  6538. ---
  6539. --- @param buf integer|string
  6540. --- @param expr string|function
  6541. --- @return any
  6542. function vim.fn.prompt_setcallback(buf, expr) end
  6543. --- Set a callback for buffer {buf} to {expr}. When {expr} is an
  6544. --- empty string the callback is removed. This has only effect if
  6545. --- {buf} has 'buftype' set to "prompt".
  6546. ---
  6547. --- This callback will be invoked when pressing CTRL-C in Insert
  6548. --- mode. Without setting a callback Vim will exit Insert mode,
  6549. --- as in any buffer.
  6550. ---
  6551. --- @param buf integer|string
  6552. --- @param expr string|function
  6553. --- @return any
  6554. function vim.fn.prompt_setinterrupt(buf, expr) end
  6555. --- Set prompt for buffer {buf} to {text}. You most likely want
  6556. --- {text} to end in a space.
  6557. --- The result is only visible if {buf} has 'buftype' set to
  6558. --- "prompt". Example: >vim
  6559. --- call prompt_setprompt(bufnr(''), 'command: ')
  6560. --- <
  6561. ---
  6562. --- @param buf integer|string
  6563. --- @param text string
  6564. --- @return any
  6565. function vim.fn.prompt_setprompt(buf, text) end
  6566. --- If the popup menu (see |ins-completion-menu|) is not visible,
  6567. --- returns an empty |Dictionary|, otherwise, returns a
  6568. --- |Dictionary| with the following keys:
  6569. --- height nr of items visible
  6570. --- width screen cells
  6571. --- row top screen row (0 first row)
  6572. --- col leftmost screen column (0 first col)
  6573. --- size total nr of items
  6574. --- scrollbar |TRUE| if scrollbar is visible
  6575. ---
  6576. --- The values are the same as in |v:event| during |CompleteChanged|.
  6577. ---
  6578. --- @return any
  6579. function vim.fn.pum_getpos() end
  6580. --- Returns non-zero when the popup menu is visible, zero
  6581. --- otherwise. See |ins-completion-menu|.
  6582. --- This can be used to avoid some things that would remove the
  6583. --- popup menu.
  6584. ---
  6585. --- @return any
  6586. function vim.fn.pumvisible() end
  6587. --- Evaluate Python expression {expr} and return its result
  6588. --- converted to Vim data structures.
  6589. --- Numbers and strings are returned as they are (strings are
  6590. --- copied though, Unicode strings are additionally converted to
  6591. --- UTF-8).
  6592. --- Lists are represented as Vim |List| type.
  6593. --- Dictionaries are represented as Vim |Dictionary| type with
  6594. --- keys converted to strings.
  6595. ---
  6596. --- @param expr any
  6597. --- @return any
  6598. function vim.fn.py3eval(expr) end
  6599. --- Evaluate Python expression {expr} and return its result
  6600. --- converted to Vim data structures.
  6601. --- Numbers and strings are returned as they are (strings are
  6602. --- copied though).
  6603. --- Lists are represented as Vim |List| type.
  6604. --- Dictionaries are represented as Vim |Dictionary| type,
  6605. --- non-string keys result in error.
  6606. ---
  6607. --- @param expr any
  6608. --- @return any
  6609. function vim.fn.pyeval(expr) end
  6610. --- Evaluate Python expression {expr} and return its result
  6611. --- converted to Vim data structures.
  6612. --- Uses Python 2 or 3, see |python_x| and 'pyxversion'.
  6613. --- See also: |pyeval()|, |py3eval()|
  6614. ---
  6615. --- @param expr any
  6616. --- @return any
  6617. function vim.fn.pyxeval(expr) end
  6618. --- Return a pseudo-random Number generated with an xoshiro128**
  6619. --- algorithm using seed {expr}. The returned number is 32 bits,
  6620. --- also on 64 bits systems, for consistency.
  6621. --- {expr} can be initialized by |srand()| and will be updated by
  6622. --- rand(). If {expr} is omitted, an internal seed value is used
  6623. --- and updated.
  6624. --- Returns -1 if {expr} is invalid.
  6625. ---
  6626. --- Examples: >vim
  6627. --- echo rand()
  6628. --- let seed = srand()
  6629. --- echo rand(seed)
  6630. --- echo rand(seed) % 16 " random number 0 - 15
  6631. --- <
  6632. ---
  6633. --- @param expr? number
  6634. --- @return any
  6635. function vim.fn.rand(expr) end
  6636. --- Returns a |List| with Numbers:
  6637. --- - If only {expr} is specified: [0, 1, ..., {expr} - 1]
  6638. --- - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
  6639. --- - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
  6640. --- {max}] (increasing {expr} with {stride} each time, not
  6641. --- producing a value past {max}).
  6642. --- When the maximum is one before the start the result is an
  6643. --- empty list. When the maximum is more than one before the
  6644. --- start this is an error.
  6645. --- Examples: >vim
  6646. --- echo range(4) " [0, 1, 2, 3]
  6647. --- echo range(2, 4) " [2, 3, 4]
  6648. --- echo range(2, 9, 3) " [2, 5, 8]
  6649. --- echo range(2, -2, -1) " [2, 1, 0, -1, -2]
  6650. --- echo range(0) " []
  6651. --- echo range(2, 0) " error!
  6652. --- <
  6653. ---
  6654. --- @param expr any
  6655. --- @param max? integer
  6656. --- @param stride? integer
  6657. --- @return any
  6658. function vim.fn.range(expr, max, stride) end
  6659. --- Read file {fname} in binary mode and return a |Blob|.
  6660. --- If {offset} is specified, read the file from the specified
  6661. --- offset. If it is a negative value, it is used as an offset
  6662. --- from the end of the file. E.g., to read the last 12 bytes: >vim
  6663. --- echo readblob('file.bin', -12)
  6664. --- <If {size} is specified, only the specified size will be read.
  6665. --- E.g. to read the first 100 bytes of a file: >vim
  6666. --- echo readblob('file.bin', 0, 100)
  6667. --- <If {size} is -1 or omitted, the whole data starting from
  6668. --- {offset} will be read.
  6669. --- This can be also used to read the data from a character device
  6670. --- on Unix when {size} is explicitly set. Only if the device
  6671. --- supports seeking {offset} can be used. Otherwise it should be
  6672. --- zero. E.g. to read 10 bytes from a serial console: >vim
  6673. --- echo readblob('/dev/ttyS0', 0, 10)
  6674. --- <When the file can't be opened an error message is given and
  6675. --- the result is an empty |Blob|.
  6676. --- When the offset is beyond the end of the file the result is an
  6677. --- empty blob.
  6678. --- When trying to read more bytes than are available the result
  6679. --- is truncated.
  6680. --- Also see |readfile()| and |writefile()|.
  6681. ---
  6682. --- @param fname string
  6683. --- @param offset? integer
  6684. --- @param size? integer
  6685. --- @return any
  6686. function vim.fn.readblob(fname, offset, size) end
  6687. --- Return a list with file and directory names in {directory}.
  6688. --- You can also use |glob()| if you don't need to do complicated
  6689. --- things, such as limiting the number of matches.
  6690. ---
  6691. --- When {expr} is omitted all entries are included.
  6692. --- When {expr} is given, it is evaluated to check what to do:
  6693. --- If {expr} results in -1 then no further entries will
  6694. --- be handled.
  6695. --- If {expr} results in 0 then this entry will not be
  6696. --- added to the list.
  6697. --- If {expr} results in 1 then this entry will be added
  6698. --- to the list.
  6699. --- Each time {expr} is evaluated |v:val| is set to the entry name.
  6700. --- When {expr} is a function the name is passed as the argument.
  6701. --- For example, to get a list of files ending in ".txt": >vim
  6702. --- echo readdir(dirname, {n -> n =~ '.txt$'})
  6703. --- <To skip hidden and backup files: >vim
  6704. --- echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
  6705. ---
  6706. --- <If you want to get a directory tree: >vim
  6707. --- function! s:tree(dir)
  6708. --- return {a:dir : map(readdir(a:dir),
  6709. --- \ {_, x -> isdirectory(x) ?
  6710. --- \ {x : s:tree(a:dir .. '/' .. x)} : x})}
  6711. --- endfunction
  6712. --- echo s:tree(".")
  6713. --- <
  6714. --- Returns an empty List on error.
  6715. ---
  6716. --- @param directory string
  6717. --- @param expr? integer
  6718. --- @return any
  6719. function vim.fn.readdir(directory, expr) end
  6720. --- Read file {fname} and return a |List|, each line of the file
  6721. --- as an item. Lines are broken at NL characters. Macintosh
  6722. --- files separated with CR will result in a single long line
  6723. --- (unless a NL appears somewhere).
  6724. --- All NUL characters are replaced with a NL character.
  6725. --- When {type} contains "b" binary mode is used:
  6726. --- - When the last line ends in a NL an extra empty list item is
  6727. --- added.
  6728. --- - No CR characters are removed.
  6729. --- Otherwise:
  6730. --- - CR characters that appear before a NL are removed.
  6731. --- - Whether the last line ends in a NL or not does not matter.
  6732. --- - Any UTF-8 byte order mark is removed from the text.
  6733. --- When {max} is given this specifies the maximum number of lines
  6734. --- to be read. Useful if you only want to check the first ten
  6735. --- lines of a file: >vim
  6736. --- for line in readfile(fname, '', 10)
  6737. --- if line =~ 'Date' | echo line | endif
  6738. --- endfor
  6739. --- <When {max} is negative -{max} lines from the end of the file
  6740. --- are returned, or as many as there are.
  6741. --- When {max} is zero the result is an empty list.
  6742. --- Note that without {max} the whole file is read into memory.
  6743. --- Also note that there is no recognition of encoding. Read a
  6744. --- file into a buffer if you need to.
  6745. --- Deprecated (use |readblob()| instead): When {type} contains
  6746. --- "B" a |Blob| is returned with the binary data of the file
  6747. --- unmodified.
  6748. --- When the file can't be opened an error message is given and
  6749. --- the result is an empty list.
  6750. --- Also see |writefile()|.
  6751. ---
  6752. --- @param fname string
  6753. --- @param type? string
  6754. --- @param max? integer
  6755. --- @return any
  6756. function vim.fn.readfile(fname, type, max) end
  6757. --- {func} is called for every item in {object}, which can be a
  6758. --- |String|, |List| or a |Blob|. {func} is called with two
  6759. --- arguments: the result so far and current item. After
  6760. --- processing all items the result is returned.
  6761. ---
  6762. --- {initial} is the initial result. When omitted, the first item
  6763. --- in {object} is used and {func} is first called for the second
  6764. --- item. If {initial} is not given and {object} is empty no
  6765. --- result can be computed, an E998 error is given.
  6766. ---
  6767. --- Examples: >vim
  6768. --- echo reduce([1, 3, 5], { acc, val -> acc + val })
  6769. --- echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
  6770. --- echo reduce(0z1122, { acc, val -> 2 * acc + val })
  6771. --- echo reduce('xyz', { acc, val -> acc .. ',' .. val })
  6772. --- <
  6773. ---
  6774. --- @generic T
  6775. --- @param object any
  6776. --- @param func fun(accumulator: T, current: any): any
  6777. --- @param initial? any
  6778. --- @return T
  6779. function vim.fn.reduce(object, func, initial) end
  6780. --- Returns the single letter name of the register being executed.
  6781. --- Returns an empty string when no register is being executed.
  6782. --- See |\@|.
  6783. ---
  6784. --- @return any
  6785. function vim.fn.reg_executing() end
  6786. --- Returns the single letter name of the last recorded register.
  6787. --- Returns an empty string when nothing was recorded yet.
  6788. --- See |q| and |Q|.
  6789. ---
  6790. --- @return any
  6791. function vim.fn.reg_recorded() end
  6792. --- Returns the single letter name of the register being recorded.
  6793. --- Returns an empty string when not recording. See |q|.
  6794. ---
  6795. --- @return any
  6796. function vim.fn.reg_recording() end
  6797. --- @return any
  6798. function vim.fn.reltime() end
  6799. --- @param start? any
  6800. --- @return any
  6801. function vim.fn.reltime(start) end
  6802. --- Return an item that represents a time value. The item is a
  6803. --- list with items that depend on the system.
  6804. --- The item can be passed to |reltimestr()| to convert it to a
  6805. --- string or |reltimefloat()| to convert to a Float.
  6806. ---
  6807. --- Without an argument it returns the current "relative time", an
  6808. --- implementation-defined value meaningful only when used as an
  6809. --- argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
  6810. ---
  6811. --- With one argument it returns the time passed since the time
  6812. --- specified in the argument.
  6813. --- With two arguments it returns the time passed between {start}
  6814. --- and {end}.
  6815. ---
  6816. --- The {start} and {end} arguments must be values returned by
  6817. --- reltime(). Returns zero on error.
  6818. ---
  6819. --- Note: |localtime()| returns the current (non-relative) time.
  6820. ---
  6821. --- @param start? any
  6822. --- @param end_? any
  6823. --- @return any
  6824. function vim.fn.reltime(start, end_) end
  6825. --- Return a Float that represents the time value of {time}.
  6826. --- Unit of time is seconds.
  6827. --- Example:
  6828. --- let start = reltime()
  6829. --- call MyFunction()
  6830. --- let seconds = reltimefloat(reltime(start))
  6831. --- See the note of reltimestr() about overhead.
  6832. --- Also see |profiling|.
  6833. --- If there is an error an empty string is returned
  6834. ---
  6835. --- @param time any
  6836. --- @return any
  6837. function vim.fn.reltimefloat(time) end
  6838. --- Return a String that represents the time value of {time}.
  6839. --- This is the number of seconds, a dot and the number of
  6840. --- microseconds. Example: >vim
  6841. --- let start = reltime()
  6842. --- call MyFunction()
  6843. --- echo reltimestr(reltime(start))
  6844. --- <Note that overhead for the commands will be added to the time.
  6845. --- Leading spaces are used to make the string align nicely. You
  6846. --- can use split() to remove it. >vim
  6847. --- echo split(reltimestr(reltime(start)))[0]
  6848. --- <Also see |profiling|.
  6849. --- If there is an error an empty string is returned
  6850. ---
  6851. --- @param time any
  6852. --- @return any
  6853. function vim.fn.reltimestr(time) end
  6854. --- @param list any
  6855. --- @param idx integer
  6856. --- @return any
  6857. function vim.fn.remove(list, idx) end
  6858. --- Without {end}: Remove the item at {idx} from |List| {list} and
  6859. --- return the item.
  6860. --- With {end}: Remove items from {idx} to {end} (inclusive) and
  6861. --- return a |List| with these items. When {idx} points to the same
  6862. --- item as {end} a list with one item is returned. When {end}
  6863. --- points to an item before {idx} this is an error.
  6864. --- See |list-index| for possible values of {idx} and {end}.
  6865. --- Returns zero on error.
  6866. --- Example: >vim
  6867. --- echo "last item: " .. remove(mylist, -1)
  6868. --- call remove(mylist, 0, 9)
  6869. --- <
  6870. --- Use |delete()| to remove a file.
  6871. ---
  6872. --- @param list any[]
  6873. --- @param idx integer
  6874. --- @param end_? integer
  6875. --- @return any
  6876. function vim.fn.remove(list, idx, end_) end
  6877. --- @param blob any
  6878. --- @param idx integer
  6879. --- @return any
  6880. function vim.fn.remove(blob, idx) end
  6881. --- Without {end}: Remove the byte at {idx} from |Blob| {blob} and
  6882. --- return the byte.
  6883. --- With {end}: Remove bytes from {idx} to {end} (inclusive) and
  6884. --- return a |Blob| with these bytes. When {idx} points to the same
  6885. --- byte as {end} a |Blob| with one byte is returned. When {end}
  6886. --- points to a byte before {idx} this is an error.
  6887. --- Returns zero on error.
  6888. --- Example: >vim
  6889. --- echo "last byte: " .. remove(myblob, -1)
  6890. --- call remove(mylist, 0, 9)
  6891. --- <
  6892. ---
  6893. --- @param blob any
  6894. --- @param idx integer
  6895. --- @param end_? integer
  6896. --- @return any
  6897. function vim.fn.remove(blob, idx, end_) end
  6898. --- Remove the entry from {dict} with key {key} and return it.
  6899. --- Example: >vim
  6900. --- echo "removed " .. remove(dict, "one")
  6901. --- <If there is no {key} in {dict} this is an error.
  6902. --- Returns zero on error.
  6903. ---
  6904. --- @param dict any
  6905. --- @param key string
  6906. --- @return any
  6907. function vim.fn.remove(dict, key) end
  6908. --- Rename the file by the name {from} to the name {to}. This
  6909. --- should also work to move files across file systems. The
  6910. --- result is a Number, which is 0 if the file was renamed
  6911. --- successfully, and non-zero when the renaming failed.
  6912. --- NOTE: If {to} exists it is overwritten without warning.
  6913. --- This function is not available in the |sandbox|.
  6914. ---
  6915. --- @param from string
  6916. --- @param to string
  6917. --- @return integer
  6918. function vim.fn.rename(from, to) end
  6919. --- Repeat {expr} {count} times and return the concatenated
  6920. --- result. Example: >vim
  6921. --- let separator = repeat('-', 80)
  6922. --- <When {count} is zero or negative the result is empty.
  6923. --- When {expr} is a |List| or a |Blob| the result is {expr}
  6924. --- concatenated {count} times. Example: >vim
  6925. --- let longlist = repeat(['a', 'b'], 3)
  6926. --- <Results in ['a', 'b', 'a', 'b', 'a', 'b'].
  6927. ---
  6928. --- @param expr any
  6929. --- @param count integer
  6930. --- @return any
  6931. vim.fn['repeat'] = function(expr, count) end
  6932. --- On MS-Windows, when {filename} is a shortcut (a .lnk file),
  6933. --- returns the path the shortcut points to in a simplified form.
  6934. --- On Unix, repeat resolving symbolic links in all path
  6935. --- components of {filename} and return the simplified result.
  6936. --- To cope with link cycles, resolving of symbolic links is
  6937. --- stopped after 100 iterations.
  6938. --- On other systems, return the simplified {filename}.
  6939. --- The simplification step is done as by |simplify()|.
  6940. --- resolve() keeps a leading path component specifying the
  6941. --- current directory (provided the result is still a relative
  6942. --- path name) and also keeps a trailing path separator.
  6943. ---
  6944. --- @param filename string
  6945. --- @return string
  6946. function vim.fn.resolve(filename) end
  6947. --- Reverse the order of items in {object}. {object} can be a
  6948. --- |List|, a |Blob| or a |String|. For a List and a Blob the
  6949. --- items are reversed in-place and {object} is returned.
  6950. --- For a String a new String is returned.
  6951. --- Returns zero if {object} is not a List, Blob or a String.
  6952. --- If you want a List or Blob to remain unmodified make a copy
  6953. --- first: >vim
  6954. --- let revlist = reverse(copy(mylist))
  6955. --- <
  6956. ---
  6957. --- @generic T
  6958. --- @param object T[]
  6959. --- @return T[]
  6960. function vim.fn.reverse(object) end
  6961. --- Round off {expr} to the nearest integral value and return it
  6962. --- as a |Float|. If {expr} lies halfway between two integral
  6963. --- values, then use the larger one (away from zero).
  6964. --- {expr} must evaluate to a |Float| or a |Number|.
  6965. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6966. --- Examples: >vim
  6967. --- echo round(0.456)
  6968. --- < 0.0 >vim
  6969. --- echo round(4.5)
  6970. --- < 5.0 >vim
  6971. --- echo round(-4.5)
  6972. --- < -5.0
  6973. ---
  6974. --- @param expr number
  6975. --- @return number
  6976. function vim.fn.round(expr) end
  6977. --- Sends {event} to {channel} via |RPC| and returns immediately.
  6978. --- If {channel} is 0, the event is broadcast to all channels.
  6979. --- Example: >vim
  6980. --- au VimLeave call rpcnotify(0, "leaving")
  6981. --- <
  6982. ---
  6983. --- @param channel integer
  6984. --- @param event string
  6985. --- @param ... any
  6986. --- @return integer
  6987. function vim.fn.rpcnotify(channel, event, ...) end
  6988. --- Sends a request to {channel} to invoke {method} via
  6989. --- |RPC| and blocks until a response is received.
  6990. --- Example: >vim
  6991. --- let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
  6992. --- <
  6993. ---
  6994. --- @param channel integer
  6995. --- @param method string
  6996. --- @param ... any
  6997. --- @return any
  6998. function vim.fn.rpcrequest(channel, method, ...) end
  6999. --- @deprecated
  7000. --- Deprecated. Replace >vim
  7001. --- let id = rpcstart('prog', ['arg1', 'arg2'])
  7002. --- <with >vim
  7003. --- let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
  7004. --- <
  7005. ---
  7006. --- @param prog string
  7007. --- @param argv? any
  7008. --- @return any
  7009. function vim.fn.rpcstart(prog, argv) end
  7010. --- @deprecated
  7011. --- Use |jobstop()| instead to stop any job, or
  7012. --- `chanclose(id, "rpc")` to close RPC communication
  7013. --- without stopping the job. Use chanclose(id) to close
  7014. --- any socket.
  7015. ---
  7016. --- @param ... any
  7017. --- @return any
  7018. function vim.fn.rpcstop(...) end
  7019. --- Evaluate Ruby expression {expr} and return its result
  7020. --- converted to Vim data structures.
  7021. --- Numbers, floats and strings are returned as they are (strings
  7022. --- are copied though).
  7023. --- Arrays are represented as Vim |List| type.
  7024. --- Hashes are represented as Vim |Dictionary| type.
  7025. --- Other objects are represented as strings resulted from their
  7026. --- "Object#to_s" method.
  7027. ---
  7028. --- @param expr any
  7029. --- @return any
  7030. function vim.fn.rubyeval(expr) end
  7031. --- Like |screenchar()|, but return the attribute. This is a rather
  7032. --- arbitrary number that can only be used to compare to the
  7033. --- attribute at other positions.
  7034. --- Returns -1 when row or col is out of range.
  7035. ---
  7036. --- @param row integer
  7037. --- @param col integer
  7038. --- @return integer
  7039. function vim.fn.screenattr(row, col) end
  7040. --- The result is a Number, which is the character at position
  7041. --- [row, col] on the screen. This works for every possible
  7042. --- screen position, also status lines, window separators and the
  7043. --- command line. The top left position is row one, column one
  7044. --- The character excludes composing characters. For double-byte
  7045. --- encodings it may only be the first byte.
  7046. --- This is mainly to be used for testing.
  7047. --- Returns -1 when row or col is out of range.
  7048. ---
  7049. --- @param row integer
  7050. --- @param col integer
  7051. --- @return integer
  7052. function vim.fn.screenchar(row, col) end
  7053. --- The result is a |List| of Numbers. The first number is the same
  7054. --- as what |screenchar()| returns. Further numbers are
  7055. --- composing characters on top of the base character.
  7056. --- This is mainly to be used for testing.
  7057. --- Returns an empty List when row or col is out of range.
  7058. ---
  7059. --- @param row integer
  7060. --- @param col integer
  7061. --- @return integer[]
  7062. function vim.fn.screenchars(row, col) end
  7063. --- The result is a Number, which is the current screen column of
  7064. --- the cursor. The leftmost column has number 1.
  7065. --- This function is mainly used for testing.
  7066. ---
  7067. --- Note: Always returns the current screen column, thus if used
  7068. --- in a command (e.g. ":echo screencol()") it will return the
  7069. --- column inside the command line, which is 1 when the command is
  7070. --- executed. To get the cursor position in the file use one of
  7071. --- the following mappings: >vim
  7072. --- nnoremap <expr> GG ":echom " .. screencol() .. "\n"
  7073. --- nnoremap <silent> GG :echom screencol()<CR>
  7074. --- noremap GG <Cmd>echom screencol()<CR>
  7075. --- <
  7076. ---
  7077. --- @return integer[]
  7078. function vim.fn.screencol() end
  7079. --- The result is a Dict with the screen position of the text
  7080. --- character in window {winid} at buffer line {lnum} and column
  7081. --- {col}. {col} is a one-based byte index.
  7082. --- The Dict has these members:
  7083. --- row screen row
  7084. --- col first screen column
  7085. --- endcol last screen column
  7086. --- curscol cursor screen column
  7087. --- If the specified position is not visible, all values are zero.
  7088. --- The "endcol" value differs from "col" when the character
  7089. --- occupies more than one screen cell. E.g. for a Tab "col" can
  7090. --- be 1 and "endcol" can be 8.
  7091. --- The "curscol" value is where the cursor would be placed. For
  7092. --- a Tab it would be the same as "endcol", while for a double
  7093. --- width character it would be the same as "col".
  7094. --- The |conceal| feature is ignored here, the column numbers are
  7095. --- as if 'conceallevel' is zero. You can set the cursor to the
  7096. --- right position and use |screencol()| to get the value with
  7097. --- |conceal| taken into account.
  7098. --- If the position is in a closed fold the screen position of the
  7099. --- first character is returned, {col} is not used.
  7100. --- Returns an empty Dict if {winid} is invalid.
  7101. ---
  7102. --- @param winid integer
  7103. --- @param lnum integer
  7104. --- @param col integer
  7105. --- @return any
  7106. function vim.fn.screenpos(winid, lnum, col) end
  7107. --- The result is a Number, which is the current screen row of the
  7108. --- cursor. The top line has number one.
  7109. --- This function is mainly used for testing.
  7110. --- Alternatively you can use |winline()|.
  7111. ---
  7112. --- Note: Same restrictions as with |screencol()|.
  7113. ---
  7114. --- @return integer
  7115. function vim.fn.screenrow() end
  7116. --- The result is a String that contains the base character and
  7117. --- any composing characters at position [row, col] on the screen.
  7118. --- This is like |screenchars()| but returning a String with the
  7119. --- characters.
  7120. --- This is mainly to be used for testing.
  7121. --- Returns an empty String when row or col is out of range.
  7122. ---
  7123. --- @param row integer
  7124. --- @param col integer
  7125. --- @return string
  7126. function vim.fn.screenstring(row, col) end
  7127. --- Search for regexp pattern {pattern}. The search starts at the
  7128. --- cursor position (you can use |cursor()| to set it).
  7129. ---
  7130. --- When a match has been found its line number is returned.
  7131. --- If there is no match a 0 is returned and the cursor doesn't
  7132. --- move. No error message is given.
  7133. --- To get the matched string, use |matchbufline()|.
  7134. ---
  7135. --- {flags} is a String, which can contain these character flags:
  7136. --- 'b' search Backward instead of forward
  7137. --- 'c' accept a match at the Cursor position
  7138. --- 'e' move to the End of the match
  7139. --- 'n' do Not move the cursor
  7140. --- 'p' return number of matching sub-Pattern (see below)
  7141. --- 's' Set the ' mark at the previous location of the cursor
  7142. --- 'w' Wrap around the end of the file
  7143. --- 'W' don't Wrap around the end of the file
  7144. --- 'z' start searching at the cursor column instead of Zero
  7145. --- If neither 'w' or 'W' is given, the 'wrapscan' option applies.
  7146. ---
  7147. --- If the 's' flag is supplied, the ' mark is set, only if the
  7148. --- cursor is moved. The 's' flag cannot be combined with the 'n'
  7149. --- flag.
  7150. ---
  7151. --- 'ignorecase', 'smartcase' and 'magic' are used.
  7152. ---
  7153. --- When the 'z' flag is not given, forward searching always
  7154. --- starts in column zero and then matches before the cursor are
  7155. --- skipped. When the 'c' flag is present in 'cpo' the next
  7156. --- search starts after the match. Without the 'c' flag the next
  7157. --- search starts one column after the start of the match. This
  7158. --- matters for overlapping matches. See |cpo-c|. You can also
  7159. --- insert "\ze" to change where the match ends, see |/\ze|.
  7160. ---
  7161. --- When searching backwards and the 'z' flag is given then the
  7162. --- search starts in column zero, thus no match in the current
  7163. --- line will be found (unless wrapping around the end of the
  7164. --- file).
  7165. ---
  7166. --- When the {stopline} argument is given then the search stops
  7167. --- after searching this line. This is useful to restrict the
  7168. --- search to a range of lines. Examples: >vim
  7169. --- let match = search('(', 'b', line("w0"))
  7170. --- let end = search('END', '', line("w$"))
  7171. --- <When {stopline} is used and it is not zero this also implies
  7172. --- that the search does not wrap around the end of the file.
  7173. --- A zero value is equal to not giving the argument.
  7174. ---
  7175. --- When the {timeout} argument is given the search stops when
  7176. --- more than this many milliseconds have passed. Thus when
  7177. --- {timeout} is 500 the search stops after half a second.
  7178. --- The value must not be negative. A zero value is like not
  7179. --- giving the argument.
  7180. ---
  7181. --- Note: the timeout is only considered when searching, not
  7182. --- while evaluating the {skip} expression.
  7183. ---
  7184. --- If the {skip} expression is given it is evaluated with the
  7185. --- cursor positioned on the start of a match. If it evaluates to
  7186. --- non-zero this match is skipped. This can be used, for
  7187. --- example, to skip a match in a comment or a string.
  7188. --- {skip} can be a string, which is evaluated as an expression, a
  7189. --- function reference or a lambda.
  7190. --- When {skip} is omitted or empty, every match is accepted.
  7191. --- When evaluating {skip} causes an error the search is aborted
  7192. --- and -1 returned.
  7193. --- *search()-sub-match*
  7194. --- With the 'p' flag the returned value is one more than the
  7195. --- first sub-match in \(\). One if none of them matched but the
  7196. --- whole pattern did match.
  7197. --- To get the column number too use |searchpos()|.
  7198. ---
  7199. --- The cursor will be positioned at the match, unless the 'n'
  7200. --- flag is used.
  7201. ---
  7202. --- Example (goes over all files in the argument list): >vim
  7203. --- let n = 1
  7204. --- while n <= argc() " loop over all files in arglist
  7205. --- exe "argument " .. n
  7206. --- " start at the last char in the file and wrap for the
  7207. --- " first search to find match at start of file
  7208. --- normal G$
  7209. --- let flags = "w"
  7210. --- while search("foo", flags) > 0
  7211. --- s/foo/bar/g
  7212. --- let flags = "W"
  7213. --- endwhile
  7214. --- update " write the file if modified
  7215. --- let n = n + 1
  7216. --- endwhile
  7217. --- <
  7218. --- Example for using some flags: >vim
  7219. --- echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
  7220. --- <This will search for the keywords "if", "else", and "endif"
  7221. --- under or after the cursor. Because of the 'p' flag, it
  7222. --- returns 1, 2, or 3 depending on which keyword is found, or 0
  7223. --- if the search fails. With the cursor on the first word of the
  7224. --- line:
  7225. --- if (foo == 0) | let foo = foo + 1 | endif ~
  7226. --- the function returns 1. Without the 'c' flag, the function
  7227. --- finds the "endif" and returns 3. The same thing happens
  7228. --- without the 'e' flag if the cursor is on the "f" of "if".
  7229. --- The 'n' flag tells the function not to move the cursor.
  7230. ---
  7231. --- @param pattern string
  7232. --- @param flags? string
  7233. --- @param stopline? integer
  7234. --- @param timeout? integer
  7235. --- @param skip? string|function
  7236. --- @return integer
  7237. function vim.fn.search(pattern, flags, stopline, timeout, skip) end
  7238. --- Get or update the last search count, like what is displayed
  7239. --- without the "S" flag in 'shortmess'. This works even if
  7240. --- 'shortmess' does contain the "S" flag.
  7241. ---
  7242. --- This returns a |Dictionary|. The dictionary is empty if the
  7243. --- previous pattern was not set and "pattern" was not specified.
  7244. ---
  7245. --- key type meaning ~
  7246. --- current |Number| current position of match;
  7247. --- 0 if the cursor position is
  7248. --- before the first match
  7249. --- exact_match |Boolean| 1 if "current" is matched on
  7250. --- "pos", otherwise 0
  7251. --- total |Number| total count of matches found
  7252. --- incomplete |Number| 0: search was fully completed
  7253. --- 1: recomputing was timed out
  7254. --- 2: max count exceeded
  7255. ---
  7256. --- For {options} see further down.
  7257. ---
  7258. --- To get the last search count when |n| or |N| was pressed, call
  7259. --- this function with `recompute: 0` . This sometimes returns
  7260. --- wrong information because |n| and |N|'s maximum count is 99.
  7261. --- If it exceeded 99 the result must be max count + 1 (100). If
  7262. --- you want to get correct information, specify `recompute: 1`: >vim
  7263. ---
  7264. --- " result == maxcount + 1 (100) when many matches
  7265. --- let result = searchcount(#{recompute: 0})
  7266. ---
  7267. --- " Below returns correct result (recompute defaults
  7268. --- " to 1)
  7269. --- let result = searchcount()
  7270. --- <
  7271. --- The function is useful to add the count to 'statusline': >vim
  7272. --- function! LastSearchCount() abort
  7273. --- let result = searchcount(#{recompute: 0})
  7274. --- if empty(result)
  7275. --- return ''
  7276. --- endif
  7277. --- if result.incomplete ==# 1 " timed out
  7278. --- return printf(' /%s [?/??]', \@/)
  7279. --- elseif result.incomplete ==# 2 " max count exceeded
  7280. --- if result.total > result.maxcount &&
  7281. --- \ result.current > result.maxcount
  7282. --- return printf(' /%s [>%d/>%d]', \@/,
  7283. --- \ result.current, result.total)
  7284. --- elseif result.total > result.maxcount
  7285. --- return printf(' /%s [%d/>%d]', \@/,
  7286. --- \ result.current, result.total)
  7287. --- endif
  7288. --- endif
  7289. --- return printf(' /%s [%d/%d]', \@/,
  7290. --- \ result.current, result.total)
  7291. --- endfunction
  7292. --- let &statusline ..= '%{LastSearchCount()}'
  7293. ---
  7294. --- " Or if you want to show the count only when
  7295. --- " 'hlsearch' was on
  7296. --- " let &statusline ..=
  7297. --- " \ '%{v:hlsearch ? LastSearchCount() : ""}'
  7298. --- <
  7299. --- You can also update the search count, which can be useful in a
  7300. --- |CursorMoved| or |CursorMovedI| autocommand: >vim
  7301. ---
  7302. --- autocmd CursorMoved,CursorMovedI *
  7303. --- \ let s:searchcount_timer = timer_start(
  7304. --- \ 200, function('s:update_searchcount'))
  7305. --- function! s:update_searchcount(timer) abort
  7306. --- if a:timer ==# s:searchcount_timer
  7307. --- call searchcount(#{
  7308. --- \ recompute: 1, maxcount: 0, timeout: 100})
  7309. --- redrawstatus
  7310. --- endif
  7311. --- endfunction
  7312. --- <
  7313. --- This can also be used to count matched texts with specified
  7314. --- pattern in the current buffer using "pattern": >vim
  7315. ---
  7316. --- " Count '\<foo\>' in this buffer
  7317. --- " (Note that it also updates search count)
  7318. --- let result = searchcount(#{pattern: '\<foo\>'})
  7319. ---
  7320. --- " To restore old search count by old pattern,
  7321. --- " search again
  7322. --- call searchcount()
  7323. --- <
  7324. --- {options} must be a |Dictionary|. It can contain:
  7325. --- key type meaning ~
  7326. --- recompute |Boolean| if |TRUE|, recompute the count
  7327. --- like |n| or |N| was executed.
  7328. --- otherwise returns the last
  7329. --- computed result (when |n| or
  7330. --- |N| was used when "S" is not
  7331. --- in 'shortmess', or this
  7332. --- function was called).
  7333. --- (default: |TRUE|)
  7334. --- pattern |String| recompute if this was given
  7335. --- and different with |\@/|.
  7336. --- this works as same as the
  7337. --- below command is executed
  7338. --- before calling this function >vim
  7339. --- let \@/ = pattern
  7340. --- < (default: |\@/|)
  7341. --- timeout |Number| 0 or negative number is no
  7342. --- timeout. timeout milliseconds
  7343. --- for recomputing the result
  7344. --- (default: 0)
  7345. --- maxcount |Number| 0 or negative number is no
  7346. --- limit. max count of matched
  7347. --- text while recomputing the
  7348. --- result. if search exceeded
  7349. --- total count, "total" value
  7350. --- becomes `maxcount + 1`
  7351. --- (default: 0)
  7352. --- pos |List| `[lnum, col, off]` value
  7353. --- when recomputing the result.
  7354. --- this changes "current" result
  7355. --- value. see |cursor()|, |getpos()|
  7356. --- (default: cursor's position)
  7357. ---
  7358. --- @param options? table
  7359. --- @return any
  7360. function vim.fn.searchcount(options) end
  7361. --- Search for the declaration of {name}.
  7362. ---
  7363. --- With a non-zero {global} argument it works like |gD|, find
  7364. --- first match in the file. Otherwise it works like |gd|, find
  7365. --- first match in the function.
  7366. ---
  7367. --- With a non-zero {thisblock} argument matches in a {} block
  7368. --- that ends before the cursor position are ignored. Avoids
  7369. --- finding variable declarations only valid in another scope.
  7370. ---
  7371. --- Moves the cursor to the found match.
  7372. --- Returns zero for success, non-zero for failure.
  7373. --- Example: >vim
  7374. --- if searchdecl('myvar') == 0
  7375. --- echo getline('.')
  7376. --- endif
  7377. --- <
  7378. ---
  7379. --- @param name string
  7380. --- @param global? boolean
  7381. --- @param thisblock? boolean
  7382. --- @return any
  7383. function vim.fn.searchdecl(name, global, thisblock) end
  7384. --- Search for the match of a nested start-end pair. This can be
  7385. --- used to find the "endif" that matches an "if", while other
  7386. --- if/endif pairs in between are ignored.
  7387. --- The search starts at the cursor. The default is to search
  7388. --- forward, include 'b' in {flags} to search backward.
  7389. --- If a match is found, the cursor is positioned at it and the
  7390. --- line number is returned. If no match is found 0 or -1 is
  7391. --- returned and the cursor doesn't move. No error message is
  7392. --- given.
  7393. ---
  7394. --- {start}, {middle} and {end} are patterns, see |pattern|. They
  7395. --- must not contain \( \) pairs. Use of \%( \) is allowed. When
  7396. --- {middle} is not empty, it is found when searching from either
  7397. --- direction, but only when not in a nested start-end pair. A
  7398. --- typical use is: >vim
  7399. --- echo searchpair('\<if\>', '\<else\>', '\<endif\>')
  7400. --- <By leaving {middle} empty the "else" is skipped.
  7401. ---
  7402. --- {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
  7403. --- |search()|. Additionally:
  7404. --- 'r' Repeat until no more matches found; will find the
  7405. --- outer pair. Implies the 'W' flag.
  7406. --- 'm' Return number of matches instead of line number with
  7407. --- the match; will be > 1 when 'r' is used.
  7408. --- Note: it's nearly always a good idea to use the 'W' flag, to
  7409. --- avoid wrapping around the end of the file.
  7410. ---
  7411. --- When a match for {start}, {middle} or {end} is found, the
  7412. --- {skip} expression is evaluated with the cursor positioned on
  7413. --- the start of the match. It should return non-zero if this
  7414. --- match is to be skipped. E.g., because it is inside a comment
  7415. --- or a string.
  7416. --- When {skip} is omitted or empty, every match is accepted.
  7417. --- When evaluating {skip} causes an error the search is aborted
  7418. --- and -1 returned.
  7419. --- {skip} can be a string, a lambda, a funcref or a partial.
  7420. --- Anything else makes the function fail.
  7421. ---
  7422. --- For {stopline} and {timeout} see |search()|.
  7423. ---
  7424. --- The value of 'ignorecase' is used. 'magic' is ignored, the
  7425. --- patterns are used like it's on.
  7426. ---
  7427. --- The search starts exactly at the cursor. A match with
  7428. --- {start}, {middle} or {end} at the next character, in the
  7429. --- direction of searching, is the first one found. Example: >vim
  7430. --- if 1
  7431. --- if 2
  7432. --- endif 2
  7433. --- endif 1
  7434. --- <When starting at the "if 2", with the cursor on the "i", and
  7435. --- searching forwards, the "endif 2" is found. When starting on
  7436. --- the character just before the "if 2", the "endif 1" will be
  7437. --- found. That's because the "if 2" will be found first, and
  7438. --- then this is considered to be a nested if/endif from "if 2" to
  7439. --- "endif 2".
  7440. --- When searching backwards and {end} is more than one character,
  7441. --- it may be useful to put "\zs" at the end of the pattern, so
  7442. --- that when the cursor is inside a match with the end it finds
  7443. --- the matching start.
  7444. ---
  7445. --- Example, to find the "endif" command in a Vim script: >vim
  7446. ---
  7447. --- echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
  7448. --- \ 'getline(".") =~ "^\\s*\""')
  7449. ---
  7450. --- <The cursor must be at or after the "if" for which a match is
  7451. --- to be found. Note that single-quote strings are used to avoid
  7452. --- having to double the backslashes. The skip expression only
  7453. --- catches comments at the start of a line, not after a command.
  7454. --- Also, a word "en" or "if" halfway through a line is considered
  7455. --- a match.
  7456. --- Another example, to search for the matching "{" of a "}": >vim
  7457. ---
  7458. --- echo searchpair('{', '', '}', 'bW')
  7459. ---
  7460. --- <This works when the cursor is at or before the "}" for which a
  7461. --- match is to be found. To reject matches that syntax
  7462. --- highlighting recognized as strings: >vim
  7463. ---
  7464. --- echo searchpair('{', '', '}', 'bW',
  7465. --- \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
  7466. --- <
  7467. ---
  7468. --- @param start string
  7469. --- @param middle string
  7470. --- @param end_ string
  7471. --- @param flags? string
  7472. --- @param skip? string|function
  7473. --- @param stopline? integer
  7474. --- @param timeout? integer
  7475. --- @return integer
  7476. function vim.fn.searchpair(start, middle, end_, flags, skip, stopline, timeout) end
  7477. --- Same as |searchpair()|, but returns a |List| with the line and
  7478. --- column position of the match. The first element of the |List|
  7479. --- is the line number and the second element is the byte index of
  7480. --- the column position of the match. If no match is found,
  7481. --- returns [0, 0]. >vim
  7482. ---
  7483. --- let [lnum,col] = searchpairpos('{', '', '}', 'n')
  7484. --- <
  7485. --- See |match-parens| for a bigger and more useful example.
  7486. ---
  7487. --- @param start string
  7488. --- @param middle string
  7489. --- @param end_ string
  7490. --- @param flags? string
  7491. --- @param skip? string|function
  7492. --- @param stopline? integer
  7493. --- @param timeout? integer
  7494. --- @return [integer, integer]
  7495. function vim.fn.searchpairpos(start, middle, end_, flags, skip, stopline, timeout) end
  7496. --- Same as |search()|, but returns a |List| with the line and
  7497. --- column position of the match. The first element of the |List|
  7498. --- is the line number and the second element is the byte index of
  7499. --- the column position of the match. If no match is found,
  7500. --- returns [0, 0].
  7501. --- Example: >vim
  7502. --- let [lnum, col] = searchpos('mypattern', 'n')
  7503. ---
  7504. --- <When the 'p' flag is given then there is an extra item with
  7505. --- the sub-pattern match number |search()-sub-match|. Example: >vim
  7506. --- let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
  7507. --- <In this example "submatch" is 2 when a lowercase letter is
  7508. --- found |/\l|, 3 when an uppercase letter is found |/\u|.
  7509. ---
  7510. --- @param pattern string
  7511. --- @param flags? string
  7512. --- @param stopline? integer
  7513. --- @param timeout? integer
  7514. --- @param skip? string|function
  7515. --- @return any
  7516. function vim.fn.searchpos(pattern, flags, stopline, timeout, skip) end
  7517. --- Returns a list of server addresses, or empty if all servers
  7518. --- were stopped. |serverstart()| |serverstop()|
  7519. --- Example: >vim
  7520. --- echo serverlist()
  7521. --- <
  7522. ---
  7523. --- @return string[]
  7524. function vim.fn.serverlist() end
  7525. --- Opens a socket or named pipe at {address} and listens for
  7526. --- |RPC| messages. Clients can send |API| commands to the
  7527. --- returned address to control Nvim.
  7528. ---
  7529. --- Returns the address string (which may differ from the
  7530. --- {address} argument, see below).
  7531. ---
  7532. --- - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
  7533. --- where the last ":" separates host and port (empty or zero
  7534. --- assigns a random port).
  7535. --- - Else {address} is the path to a named pipe (except on Windows).
  7536. --- - If {address} has no slashes ("/") it is treated as the
  7537. --- "name" part of a generated path in this format: >vim
  7538. --- stdpath("run").."/{name}.{pid}.{counter}"
  7539. --- < - If {address} is omitted the name is "nvim". >vim
  7540. --- echo serverstart()
  7541. --- < >
  7542. --- => /tmp/nvim.bram/oknANW/nvim.15430.5
  7543. --- <
  7544. --- Example bash command to list all Nvim servers: >bash
  7545. --- ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
  7546. ---
  7547. --- <Example named pipe: >vim
  7548. --- if has('win32')
  7549. --- echo serverstart('\\.\pipe\nvim-pipe-1234')
  7550. --- else
  7551. --- echo serverstart('nvim.sock')
  7552. --- endif
  7553. --- <
  7554. --- Example TCP/IP address: >vim
  7555. --- echo serverstart('::1:12345')
  7556. --- <
  7557. ---
  7558. --- @param address? string
  7559. --- @return string
  7560. function vim.fn.serverstart(address) end
  7561. --- Closes the pipe or socket at {address}.
  7562. --- Returns TRUE if {address} is valid, else FALSE.
  7563. --- If |v:servername| is stopped it is set to the next available
  7564. --- address in |serverlist()|.
  7565. ---
  7566. --- @param address string
  7567. --- @return integer
  7568. function vim.fn.serverstop(address) end
  7569. --- Set line {lnum} to {text} in buffer {buf}. This works like
  7570. --- |setline()| for the specified buffer.
  7571. ---
  7572. --- This function works only for loaded buffers. First call
  7573. --- |bufload()| if needed.
  7574. ---
  7575. --- To insert lines use |appendbufline()|.
  7576. ---
  7577. --- {text} can be a string to set one line, or a List of strings
  7578. --- to set multiple lines. If the List extends below the last
  7579. --- line then those lines are added. If the List is empty then
  7580. --- nothing is changed and zero is returned.
  7581. ---
  7582. --- For the use of {buf}, see |bufname()| above.
  7583. ---
  7584. --- {lnum} is used like with |setline()|.
  7585. --- Use "$" to refer to the last line in buffer {buf}.
  7586. --- When {lnum} is just below the last line the {text} will be
  7587. --- added below the last line.
  7588. --- On success 0 is returned, on failure 1 is returned.
  7589. ---
  7590. --- If {buf} is not a valid buffer or {lnum} is not valid, an
  7591. --- error message is given.
  7592. ---
  7593. --- @param buf integer|string
  7594. --- @param lnum integer
  7595. --- @param text string|string[]
  7596. --- @return integer
  7597. function vim.fn.setbufline(buf, lnum, text) end
  7598. --- Set option or local variable {varname} in buffer {buf} to
  7599. --- {val}.
  7600. --- This also works for a global or local window option, but it
  7601. --- doesn't work for a global or local window variable.
  7602. --- For a local window option the global value is unchanged.
  7603. --- For the use of {buf}, see |bufname()| above.
  7604. --- The {varname} argument is a string.
  7605. --- Note that the variable name without "b:" must be used.
  7606. --- Examples: >vim
  7607. --- call setbufvar(1, "&mod", 1)
  7608. --- call setbufvar("todo", "myvar", "foobar")
  7609. --- <This function is not available in the |sandbox|.
  7610. ---
  7611. --- @param buf integer|string
  7612. --- @param varname string
  7613. --- @param val any
  7614. --- @return any
  7615. function vim.fn.setbufvar(buf, varname, val) end
  7616. --- Specify overrides for cell widths of character ranges. This
  7617. --- tells Vim how wide characters are when displayed in the
  7618. --- terminal, counted in screen cells. The values override
  7619. --- 'ambiwidth'. Example: >vim
  7620. --- call setcellwidths([
  7621. --- \ [0x111, 0x111, 1],
  7622. --- \ [0x2194, 0x2199, 2],
  7623. --- \ ])
  7624. ---
  7625. --- <The {list} argument is a List of Lists with each three
  7626. --- numbers: [{low}, {high}, {width}]. *E1109* *E1110*
  7627. --- {low} and {high} can be the same, in which case this refers to
  7628. --- one character. Otherwise it is the range of characters from
  7629. --- {low} to {high} (inclusive). *E1111* *E1114*
  7630. --- Only characters with value 0x80 and higher can be used.
  7631. ---
  7632. --- {width} must be either 1 or 2, indicating the character width
  7633. --- in screen cells. *E1112*
  7634. --- An error is given if the argument is invalid, also when a
  7635. --- range overlaps with another. *E1113*
  7636. ---
  7637. --- If the new value causes 'fillchars' or 'listchars' to become
  7638. --- invalid it is rejected and an error is given.
  7639. ---
  7640. --- To clear the overrides pass an empty {list}: >vim
  7641. --- call setcellwidths([])
  7642. ---
  7643. --- <You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
  7644. --- the effect for known emoji characters. Move the cursor
  7645. --- through the text to check if the cell widths of your terminal
  7646. --- match with what Vim knows about each emoji. If it doesn't
  7647. --- look right you need to adjust the {list} argument.
  7648. ---
  7649. --- @param list any[]
  7650. --- @return any
  7651. function vim.fn.setcellwidths(list) end
  7652. --- Same as |setpos()| but uses the specified column number as the
  7653. --- character index instead of the byte index in the line.
  7654. ---
  7655. --- Example:
  7656. --- With the text "여보세요" in line 8: >vim
  7657. --- call setcharpos('.', [0, 8, 4, 0])
  7658. --- <positions the cursor on the fourth character '요'. >vim
  7659. --- call setpos('.', [0, 8, 4, 0])
  7660. --- <positions the cursor on the second character '보'.
  7661. ---
  7662. --- @param expr string
  7663. --- @param list integer[]
  7664. --- @return any
  7665. function vim.fn.setcharpos(expr, list) end
  7666. --- Set the current character search information to {dict},
  7667. --- which contains one or more of the following entries:
  7668. ---
  7669. --- char character which will be used for a subsequent
  7670. --- |,| or |;| command; an empty string clears the
  7671. --- character search
  7672. --- forward direction of character search; 1 for forward,
  7673. --- 0 for backward
  7674. --- until type of character search; 1 for a |t| or |T|
  7675. --- character search, 0 for an |f| or |F|
  7676. --- character search
  7677. ---
  7678. --- This can be useful to save/restore a user's character search
  7679. --- from a script: >vim
  7680. --- let prevsearch = getcharsearch()
  7681. --- " Perform a command which clobbers user's search
  7682. --- call setcharsearch(prevsearch)
  7683. --- <Also see |getcharsearch()|.
  7684. ---
  7685. --- @param dict string
  7686. --- @return any
  7687. function vim.fn.setcharsearch(dict) end
  7688. --- Set the command line to {str} and set the cursor position to
  7689. --- {pos}.
  7690. --- If {pos} is omitted, the cursor is positioned after the text.
  7691. --- Returns 0 when successful, 1 when not editing the command
  7692. --- line.
  7693. ---
  7694. --- @param str string
  7695. --- @param pos? integer
  7696. --- @return integer
  7697. function vim.fn.setcmdline(str, pos) end
  7698. --- Set the cursor position in the command line to byte position
  7699. --- {pos}. The first position is 1.
  7700. --- Use |getcmdpos()| to obtain the current position.
  7701. --- Only works while editing the command line, thus you must use
  7702. --- |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
  7703. --- |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
  7704. --- set after the command line is set to the expression. For
  7705. --- |c_CTRL-R_=| it is set after evaluating the expression but
  7706. --- before inserting the resulting text.
  7707. --- When the number is too big the cursor is put at the end of the
  7708. --- line. A number smaller than one has undefined results.
  7709. --- Returns 0 when successful, 1 when not editing the command
  7710. --- line.
  7711. ---
  7712. --- @param pos integer
  7713. --- @return any
  7714. function vim.fn.setcmdpos(pos) end
  7715. --- @param lnum integer
  7716. --- @param col? integer
  7717. --- @param off? integer
  7718. --- @return any
  7719. function vim.fn.setcursorcharpos(lnum, col, off) end
  7720. --- Same as |cursor()| but uses the specified column number as the
  7721. --- character index instead of the byte index in the line.
  7722. ---
  7723. --- Example:
  7724. --- With the text "여보세요" in line 4: >vim
  7725. --- call setcursorcharpos(4, 3)
  7726. --- <positions the cursor on the third character '세'. >vim
  7727. --- call cursor(4, 3)
  7728. --- <positions the cursor on the first character '여'.
  7729. ---
  7730. --- @param list integer[]
  7731. --- @return any
  7732. function vim.fn.setcursorcharpos(list) end
  7733. --- Set environment variable {name} to {val}. Example: >vim
  7734. --- call setenv('HOME', '/home/myhome')
  7735. ---
  7736. --- <When {val} is |v:null| the environment variable is deleted.
  7737. --- See also |expr-env|.
  7738. ---
  7739. --- @param name string
  7740. --- @param val string
  7741. --- @return any
  7742. function vim.fn.setenv(name, val) end
  7743. --- Set the file permissions for {fname} to {mode}.
  7744. --- {mode} must be a string with 9 characters. It is of the form
  7745. --- "rwxrwxrwx", where each group of "rwx" flags represent, in
  7746. --- turn, the permissions of the owner of the file, the group the
  7747. --- file belongs to, and other users. A '-' character means the
  7748. --- permission is off, any other character means on. Multi-byte
  7749. --- characters are not supported.
  7750. ---
  7751. --- For example "rw-r-----" means read-write for the user,
  7752. --- readable by the group, not accessible by others. "xx-x-----"
  7753. --- would do the same thing.
  7754. ---
  7755. --- Returns non-zero for success, zero for failure.
  7756. ---
  7757. --- To read permissions see |getfperm()|.
  7758. ---
  7759. --- @param fname string
  7760. --- @param mode string
  7761. --- @return any
  7762. function vim.fn.setfperm(fname, mode) end
  7763. --- Set line {lnum} of the current buffer to {text}. To insert
  7764. --- lines use |append()|. To set lines in another buffer use
  7765. --- |setbufline()|.
  7766. ---
  7767. --- {lnum} is used like with |getline()|.
  7768. --- When {lnum} is just below the last line the {text} will be
  7769. --- added below the last line.
  7770. --- {text} can be any type or a List of any type, each item is
  7771. --- converted to a String. When {text} is an empty List then
  7772. --- nothing is changed and FALSE is returned.
  7773. ---
  7774. --- If this succeeds, FALSE is returned. If this fails (most likely
  7775. --- because {lnum} is invalid) TRUE is returned.
  7776. ---
  7777. --- Example: >vim
  7778. --- call setline(5, strftime("%c"))
  7779. ---
  7780. --- <When {text} is a |List| then line {lnum} and following lines
  7781. --- will be set to the items in the list. Example: >vim
  7782. --- call setline(5, ['aaa', 'bbb', 'ccc'])
  7783. --- <This is equivalent to: >vim
  7784. --- for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
  7785. --- call setline(n, l)
  7786. --- endfor
  7787. ---
  7788. --- <Note: The '[ and '] marks are not set.
  7789. ---
  7790. --- @param lnum integer
  7791. --- @param text any
  7792. --- @return any
  7793. function vim.fn.setline(lnum, text) end
  7794. --- Create or replace or add to the location list for window {nr}.
  7795. --- {nr} can be the window number or the |window-ID|.
  7796. --- When {nr} is zero the current window is used.
  7797. ---
  7798. --- For a location list window, the displayed location list is
  7799. --- modified. For an invalid window number {nr}, -1 is returned.
  7800. --- Otherwise, same as |setqflist()|.
  7801. --- Also see |location-list|.
  7802. ---
  7803. --- For {action} see |setqflist-action|.
  7804. ---
  7805. --- If the optional {what} dictionary argument is supplied, then
  7806. --- only the items listed in {what} are set. Refer to |setqflist()|
  7807. --- for the list of supported keys in {what}.
  7808. ---
  7809. --- @param nr integer
  7810. --- @param list any
  7811. --- @param action? string
  7812. --- @param what? table
  7813. --- @return any
  7814. function vim.fn.setloclist(nr, list, action, what) end
  7815. --- Restores a list of matches saved by |getmatches()| for the
  7816. --- current window. Returns 0 if successful, otherwise -1. All
  7817. --- current matches are cleared before the list is restored. See
  7818. --- example for |getmatches()|.
  7819. --- If {win} is specified, use the window with this number or
  7820. --- window ID instead of the current window.
  7821. ---
  7822. --- @param list any
  7823. --- @param win? integer
  7824. --- @return any
  7825. function vim.fn.setmatches(list, win) end
  7826. --- Set the position for String {expr}. Possible values:
  7827. --- . the cursor
  7828. --- 'x mark x
  7829. ---
  7830. --- {list} must be a |List| with four or five numbers:
  7831. --- [bufnum, lnum, col, off]
  7832. --- [bufnum, lnum, col, off, curswant]
  7833. ---
  7834. --- "bufnum" is the buffer number. Zero can be used for the
  7835. --- current buffer. When setting an uppercase mark "bufnum" is
  7836. --- used for the mark position. For other marks it specifies the
  7837. --- buffer to set the mark in. You can use the |bufnr()| function
  7838. --- to turn a file name into a buffer number.
  7839. --- For setting the cursor and the ' mark "bufnum" is ignored,
  7840. --- since these are associated with a window, not a buffer.
  7841. --- Does not change the jumplist.
  7842. ---
  7843. --- "lnum" and "col" are the position in the buffer. The first
  7844. --- column is 1. Use a zero "lnum" to delete a mark. If "col" is
  7845. --- smaller than 1 then 1 is used. To use the character count
  7846. --- instead of the byte count, use |setcharpos()|.
  7847. ---
  7848. --- The "off" number is only used when 'virtualedit' is set. Then
  7849. --- it is the offset in screen columns from the start of the
  7850. --- character. E.g., a position within a <Tab> or after the last
  7851. --- character.
  7852. ---
  7853. --- The "curswant" number is only used when setting the cursor
  7854. --- position. It sets the preferred column for when moving the
  7855. --- cursor vertically. When the "curswant" number is missing the
  7856. --- preferred column is not set. When it is present and setting a
  7857. --- mark position it is not used.
  7858. ---
  7859. --- Note that for '< and '> changing the line number may result in
  7860. --- the marks to be effectively be swapped, so that '< is always
  7861. --- before '>.
  7862. ---
  7863. --- Returns 0 when the position could be set, -1 otherwise.
  7864. --- An error message is given if {expr} is invalid.
  7865. ---
  7866. --- Also see |setcharpos()|, |getpos()| and |getcurpos()|.
  7867. ---
  7868. --- This does not restore the preferred column for moving
  7869. --- vertically; if you set the cursor position with this, |j| and
  7870. --- |k| motions will jump to previous columns! Use |cursor()| to
  7871. --- also set the preferred column. Also see the "curswant" key in
  7872. --- |winrestview()|.
  7873. ---
  7874. --- @param expr string
  7875. --- @param list integer[]
  7876. --- @return any
  7877. function vim.fn.setpos(expr, list) end
  7878. --- Create or replace or add to the quickfix list.
  7879. ---
  7880. --- If the optional {what} dictionary argument is supplied, then
  7881. --- only the items listed in {what} are set. The first {list}
  7882. --- argument is ignored. See below for the supported items in
  7883. --- {what}.
  7884. --- *setqflist-what*
  7885. --- When {what} is not present, the items in {list} are used. Each
  7886. --- item must be a dictionary. Non-dictionary items in {list} are
  7887. --- ignored. Each dictionary item can contain the following
  7888. --- entries:
  7889. ---
  7890. --- bufnr buffer number; must be the number of a valid
  7891. --- buffer
  7892. --- filename name of a file; only used when "bufnr" is not
  7893. --- present or it is invalid.
  7894. --- module name of a module; if given it will be used in
  7895. --- quickfix error window instead of the filename.
  7896. --- lnum line number in the file
  7897. --- end_lnum end of lines, if the item spans multiple lines
  7898. --- pattern search pattern used to locate the error
  7899. --- col column number
  7900. --- vcol when non-zero: "col" is visual column
  7901. --- when zero: "col" is byte index
  7902. --- end_col end column, if the item spans multiple columns
  7903. --- nr error number
  7904. --- text description of the error
  7905. --- type single-character error type, 'E', 'W', etc.
  7906. --- valid recognized error message
  7907. --- user_data
  7908. --- custom data associated with the item, can be
  7909. --- any type.
  7910. ---
  7911. --- The "col", "vcol", "nr", "type" and "text" entries are
  7912. --- optional. Either "lnum" or "pattern" entry can be used to
  7913. --- locate a matching error line.
  7914. --- If the "filename" and "bufnr" entries are not present or
  7915. --- neither the "lnum" or "pattern" entries are present, then the
  7916. --- item will not be handled as an error line.
  7917. --- If both "pattern" and "lnum" are present then "pattern" will
  7918. --- be used.
  7919. --- If the "valid" entry is not supplied, then the valid flag is
  7920. --- set when "bufnr" is a valid buffer or "filename" exists.
  7921. --- If you supply an empty {list}, the quickfix list will be
  7922. --- cleared.
  7923. --- Note that the list is not exactly the same as what
  7924. --- |getqflist()| returns.
  7925. ---
  7926. --- {action} values: *setqflist-action* *E927*
  7927. --- 'a' The items from {list} are added to the existing
  7928. --- quickfix list. If there is no existing list, then a
  7929. --- new list is created.
  7930. ---
  7931. --- 'r' The items from the current quickfix list are replaced
  7932. --- with the items from {list}. This can also be used to
  7933. --- clear the list: >vim
  7934. --- call setqflist([], 'r')
  7935. --- <
  7936. --- 'u' Like 'r', but tries to preserve the current selection
  7937. --- in the quickfix list.
  7938. --- 'f' All the quickfix lists in the quickfix stack are
  7939. --- freed.
  7940. ---
  7941. --- If {action} is not present or is set to ' ', then a new list
  7942. --- is created. The new quickfix list is added after the current
  7943. --- quickfix list in the stack and all the following lists are
  7944. --- freed. To add a new quickfix list at the end of the stack,
  7945. --- set "nr" in {what} to "$".
  7946. ---
  7947. --- The following items can be specified in dictionary {what}:
  7948. --- context quickfix list context. See |quickfix-context|
  7949. --- efm errorformat to use when parsing text from
  7950. --- "lines". If this is not present, then the
  7951. --- 'errorformat' option value is used.
  7952. --- See |quickfix-parse|
  7953. --- id quickfix list identifier |quickfix-ID|
  7954. --- idx index of the current entry in the quickfix
  7955. --- list specified by "id" or "nr". If set to '$',
  7956. --- then the last entry in the list is set as the
  7957. --- current entry. See |quickfix-index|
  7958. --- items list of quickfix entries. Same as the {list}
  7959. --- argument.
  7960. --- lines use 'errorformat' to parse a list of lines and
  7961. --- add the resulting entries to the quickfix list
  7962. --- {nr} or {id}. Only a |List| value is supported.
  7963. --- See |quickfix-parse|
  7964. --- nr list number in the quickfix stack; zero
  7965. --- means the current quickfix list and "$" means
  7966. --- the last quickfix list.
  7967. --- quickfixtextfunc
  7968. --- function to get the text to display in the
  7969. --- quickfix window. The value can be the name of
  7970. --- a function or a funcref or a lambda. Refer to
  7971. --- |quickfix-window-function| for an explanation
  7972. --- of how to write the function and an example.
  7973. --- title quickfix list title text. See |quickfix-title|
  7974. --- Unsupported keys in {what} are ignored.
  7975. --- If the "nr" item is not present, then the current quickfix list
  7976. --- is modified. When creating a new quickfix list, "nr" can be
  7977. --- set to a value one greater than the quickfix stack size.
  7978. --- When modifying a quickfix list, to guarantee that the correct
  7979. --- list is modified, "id" should be used instead of "nr" to
  7980. --- specify the list.
  7981. ---
  7982. --- Examples (See also |setqflist-examples|): >vim
  7983. --- call setqflist([], 'r', {'title': 'My search'})
  7984. --- call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
  7985. --- call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
  7986. --- <
  7987. --- Returns zero for success, -1 for failure.
  7988. ---
  7989. --- This function can be used to create a quickfix list
  7990. --- independent of the 'errorformat' setting. Use a command like
  7991. --- `:cc 1` to jump to the first position.
  7992. ---
  7993. --- @param list vim.quickfix.entry[]
  7994. --- @param action? string
  7995. --- @param what? vim.fn.setqflist.what
  7996. --- @return integer
  7997. function vim.fn.setqflist(list, action, what) end
  7998. --- Set the register {regname} to {value}.
  7999. --- If {regname} is "" or "\@", the unnamed register '"' is used.
  8000. --- The {regname} argument is a string.
  8001. ---
  8002. --- {value} may be any value returned by |getreg()| or
  8003. --- |getreginfo()|, including a |List| or |Dict|.
  8004. --- If {options} contains "a" or {regname} is upper case,
  8005. --- then the value is appended.
  8006. ---
  8007. --- {options} can also contain a register type specification:
  8008. --- "c" or "v" |charwise| mode
  8009. --- "l" or "V" |linewise| mode
  8010. --- "b" or "<CTRL-V>" |blockwise-visual| mode
  8011. --- If a number immediately follows "b" or "<CTRL-V>" then this is
  8012. --- used as the width of the selection - if it is not specified
  8013. --- then the width of the block is set to the number of characters
  8014. --- in the longest line (counting a <Tab> as 1 character).
  8015. --- If {options} contains "u" or '"', then the unnamed register is
  8016. --- set to point to register {regname}.
  8017. ---
  8018. --- If {options} contains no register settings, then the default
  8019. --- is to use character mode unless {value} ends in a <NL> for
  8020. --- string {value} and linewise mode for list {value}. Blockwise
  8021. --- mode is never selected automatically.
  8022. --- Returns zero for success, non-zero for failure.
  8023. ---
  8024. --- *E883*
  8025. --- Note: you may not use |List| containing more than one item to
  8026. --- set search and expression registers. Lists containing no
  8027. --- items act like empty strings.
  8028. ---
  8029. --- Examples: >vim
  8030. --- call setreg(v:register, \@*)
  8031. --- call setreg('*', \@%, 'ac')
  8032. --- call setreg('a', "1\n2\n3", 'b5')
  8033. --- call setreg('"', { 'points_to': 'a'})
  8034. ---
  8035. --- <This example shows using the functions to save and restore a
  8036. --- register: >vim
  8037. --- let var_a = getreginfo()
  8038. --- call setreg('a', var_a)
  8039. --- <or: >vim
  8040. --- let var_a = getreg('a', 1, 1)
  8041. --- let var_amode = getregtype('a')
  8042. --- " ....
  8043. --- call setreg('a', var_a, var_amode)
  8044. --- <Note: you may not reliably restore register value
  8045. --- without using the third argument to |getreg()| as without it
  8046. --- newlines are represented as newlines AND Nul bytes are
  8047. --- represented as newlines as well, see |NL-used-for-Nul|.
  8048. ---
  8049. --- You can also change the type of a register by appending
  8050. --- nothing: >vim
  8051. --- call setreg('a', '', 'al')
  8052. ---
  8053. --- @param regname string
  8054. --- @param value any
  8055. --- @param options? string
  8056. --- @return any
  8057. function vim.fn.setreg(regname, value, options) end
  8058. --- Set tab-local variable {varname} to {val} in tab page {tabnr}.
  8059. --- |t:var|
  8060. --- The {varname} argument is a string.
  8061. --- Note that the variable name without "t:" must be used.
  8062. --- Tabs are numbered starting with one.
  8063. --- This function is not available in the |sandbox|.
  8064. ---
  8065. --- @param tabnr integer
  8066. --- @param varname string
  8067. --- @param val any
  8068. --- @return any
  8069. function vim.fn.settabvar(tabnr, varname, val) end
  8070. --- Set option or local variable {varname} in window {winnr} to
  8071. --- {val}.
  8072. --- Tabs are numbered starting with one. For the current tabpage
  8073. --- use |setwinvar()|.
  8074. --- {winnr} can be the window number or the |window-ID|.
  8075. --- When {winnr} is zero the current window is used.
  8076. --- This also works for a global or local buffer option, but it
  8077. --- doesn't work for a global or local buffer variable.
  8078. --- For a local buffer option the global value is unchanged.
  8079. --- Note that the variable name without "w:" must be used.
  8080. --- Examples: >vim
  8081. --- call settabwinvar(1, 1, "&list", 0)
  8082. --- call settabwinvar(3, 2, "myvar", "foobar")
  8083. --- <This function is not available in the |sandbox|.
  8084. ---
  8085. --- @param tabnr integer
  8086. --- @param winnr integer
  8087. --- @param varname string
  8088. --- @param val any
  8089. --- @return any
  8090. function vim.fn.settabwinvar(tabnr, winnr, varname, val) end
  8091. --- Modify the tag stack of the window {nr} using {dict}.
  8092. --- {nr} can be the window number or the |window-ID|.
  8093. ---
  8094. --- For a list of supported items in {dict}, refer to
  8095. --- |gettagstack()|. "curidx" takes effect before changing the tag
  8096. --- stack.
  8097. --- *E962*
  8098. --- How the tag stack is modified depends on the {action}
  8099. --- argument:
  8100. --- - If {action} is not present or is set to 'r', then the tag
  8101. --- stack is replaced.
  8102. --- - If {action} is set to 'a', then new entries from {dict} are
  8103. --- pushed (added) onto the tag stack.
  8104. --- - If {action} is set to 't', then all the entries from the
  8105. --- current entry in the tag stack or "curidx" in {dict} are
  8106. --- removed and then new entries are pushed to the stack.
  8107. ---
  8108. --- The current index is set to one after the length of the tag
  8109. --- stack after the modification.
  8110. ---
  8111. --- Returns zero for success, -1 for failure.
  8112. ---
  8113. --- Examples (for more examples see |tagstack-examples|):
  8114. --- Empty the tag stack of window 3: >vim
  8115. --- call settagstack(3, {'items' : []})
  8116. ---
  8117. --- < Save and restore the tag stack: >vim
  8118. --- let stack = gettagstack(1003)
  8119. --- " do something else
  8120. --- call settagstack(1003, stack)
  8121. --- unlet stack
  8122. --- <
  8123. ---
  8124. --- @param nr integer
  8125. --- @param dict any
  8126. --- @param action? string
  8127. --- @return any
  8128. function vim.fn.settagstack(nr, dict, action) end
  8129. --- Like |settabwinvar()| for the current tab page.
  8130. --- Examples: >vim
  8131. --- call setwinvar(1, "&list", 0)
  8132. --- call setwinvar(2, "myvar", "foobar")
  8133. ---
  8134. --- @param nr integer
  8135. --- @param varname string
  8136. --- @param val any
  8137. --- @return any
  8138. function vim.fn.setwinvar(nr, varname, val) end
  8139. --- Returns a String with 64 hex characters, which is the SHA256
  8140. --- checksum of {string}.
  8141. ---
  8142. --- @param string string
  8143. --- @return string
  8144. function vim.fn.sha256(string) end
  8145. --- Escape {string} for use as a shell command argument.
  8146. ---
  8147. --- On Windows when 'shellslash' is not set, encloses {string} in
  8148. --- double-quotes and doubles all double-quotes within {string}.
  8149. --- Otherwise encloses {string} in single-quotes and replaces all
  8150. --- "'" with "'\''".
  8151. ---
  8152. --- The {special} argument adds additional escaping of keywords
  8153. --- used in Vim commands. If it is a |non-zero-arg|:
  8154. --- - Special items such as "!", "%", "#" and "<cword>" (as listed
  8155. --- in |expand()|) will be preceded by a backslash.
  8156. --- The backslash will be removed again by the |:!| command.
  8157. --- - The <NL> character is escaped.
  8158. ---
  8159. --- If 'shell' contains "csh" in the tail:
  8160. --- - The "!" character will be escaped. This is because csh and
  8161. --- tcsh use "!" for history replacement even in single-quotes.
  8162. --- - The <NL> character is escaped (twice if {special} is
  8163. --- a |non-zero-arg|).
  8164. ---
  8165. --- If 'shell' contains "fish" in the tail, the "\" character will
  8166. --- be escaped because in fish it is used as an escape character
  8167. --- inside single quotes.
  8168. ---
  8169. --- Example of use with a |:!| command: >vim
  8170. --- exe '!dir ' .. shellescape(expand('<cfile>'), 1)
  8171. --- <This results in a directory listing for the file under the
  8172. --- cursor. Example of use with |system()|: >vim
  8173. --- call system("chmod +w -- " .. shellescape(expand("%")))
  8174. --- <See also |::S|.
  8175. ---
  8176. --- @param string string
  8177. --- @param special? boolean
  8178. --- @return string
  8179. function vim.fn.shellescape(string, special) end
  8180. --- Returns the effective value of 'shiftwidth'. This is the
  8181. --- 'shiftwidth' value unless it is zero, in which case it is the
  8182. --- 'tabstop' value. To be backwards compatible in indent
  8183. --- plugins, use this: >vim
  8184. --- if exists('*shiftwidth')
  8185. --- func s:sw()
  8186. --- return shiftwidth()
  8187. --- endfunc
  8188. --- else
  8189. --- func s:sw()
  8190. --- return &sw
  8191. --- endfunc
  8192. --- endif
  8193. --- <And then use s:sw() instead of &sw.
  8194. ---
  8195. --- When there is one argument {col} this is used as column number
  8196. --- for which to return the 'shiftwidth' value. This matters for the
  8197. --- 'vartabstop' feature. If no {col} argument is given, column 1
  8198. --- will be assumed.
  8199. ---
  8200. --- @param col? integer
  8201. --- @return integer
  8202. function vim.fn.shiftwidth(col) end
  8203. --- @param name string
  8204. --- @param dict? vim.fn.sign_define.dict
  8205. --- @return 0|-1
  8206. function vim.fn.sign_define(name, dict) end
  8207. --- Define a new sign named {name} or modify the attributes of an
  8208. --- existing sign. This is similar to the |:sign-define| command.
  8209. ---
  8210. --- Prefix {name} with a unique text to avoid name collisions.
  8211. --- There is no {group} like with placing signs.
  8212. ---
  8213. --- The {name} can be a String or a Number. The optional {dict}
  8214. --- argument specifies the sign attributes. The following values
  8215. --- are supported:
  8216. --- icon full path to the bitmap file for the sign.
  8217. --- linehl highlight group used for the whole line the
  8218. --- sign is placed in.
  8219. --- priority default priority value of the sign
  8220. --- numhl highlight group used for the line number where
  8221. --- the sign is placed.
  8222. --- text text that is displayed when there is no icon
  8223. --- or the GUI is not being used.
  8224. --- texthl highlight group used for the text item
  8225. --- culhl highlight group used for the text item when
  8226. --- the cursor is on the same line as the sign and
  8227. --- 'cursorline' is enabled.
  8228. ---
  8229. --- If the sign named {name} already exists, then the attributes
  8230. --- of the sign are updated.
  8231. ---
  8232. --- The one argument {list} can be used to define a list of signs.
  8233. --- Each list item is a dictionary with the above items in {dict}
  8234. --- and a "name" item for the sign name.
  8235. ---
  8236. --- Returns 0 on success and -1 on failure. When the one argument
  8237. --- {list} is used, then returns a List of values one for each
  8238. --- defined sign.
  8239. ---
  8240. --- Examples: >vim
  8241. --- call sign_define("mySign", {
  8242. --- \ "text" : "=>",
  8243. --- \ "texthl" : "Error",
  8244. --- \ "linehl" : "Search"})
  8245. --- call sign_define([
  8246. --- \ {'name' : 'sign1',
  8247. --- \ 'text' : '=>'},
  8248. --- \ {'name' : 'sign2',
  8249. --- \ 'text' : '!!'}
  8250. --- \ ])
  8251. --- <
  8252. ---
  8253. --- @param list vim.fn.sign_define.dict[]
  8254. --- @return (0|-1)[]
  8255. function vim.fn.sign_define(list) end
  8256. --- Get a list of defined signs and their attributes.
  8257. --- This is similar to the |:sign-list| command.
  8258. ---
  8259. --- If the {name} is not supplied, then a list of all the defined
  8260. --- signs is returned. Otherwise the attribute of the specified
  8261. --- sign is returned.
  8262. ---
  8263. --- Each list item in the returned value is a dictionary with the
  8264. --- following entries:
  8265. --- icon full path to the bitmap file of the sign
  8266. --- linehl highlight group used for the whole line the
  8267. --- sign is placed in; not present if not set.
  8268. --- name name of the sign
  8269. --- priority default priority value of the sign
  8270. --- numhl highlight group used for the line number where
  8271. --- the sign is placed; not present if not set.
  8272. --- text text that is displayed when there is no icon
  8273. --- or the GUI is not being used.
  8274. --- texthl highlight group used for the text item; not
  8275. --- present if not set.
  8276. --- culhl highlight group used for the text item when
  8277. --- the cursor is on the same line as the sign and
  8278. --- 'cursorline' is enabled; not present if not
  8279. --- set.
  8280. ---
  8281. --- Returns an empty List if there are no signs and when {name} is
  8282. --- not found.
  8283. ---
  8284. --- Examples: >vim
  8285. --- " Get a list of all the defined signs
  8286. --- echo sign_getdefined()
  8287. ---
  8288. --- " Get the attribute of the sign named mySign
  8289. --- echo sign_getdefined("mySign")
  8290. --- <
  8291. ---
  8292. --- @param name? string
  8293. --- @return vim.fn.sign_getdefined.ret.item[]
  8294. function vim.fn.sign_getdefined(name) end
  8295. --- Return a list of signs placed in a buffer or all the buffers.
  8296. --- This is similar to the |:sign-place-list| command.
  8297. ---
  8298. --- If the optional buffer name {buf} is specified, then only the
  8299. --- list of signs placed in that buffer is returned. For the use
  8300. --- of {buf}, see |bufname()|. The optional {dict} can contain
  8301. --- the following entries:
  8302. --- group select only signs in this group
  8303. --- id select sign with this identifier
  8304. --- lnum select signs placed in this line. For the use
  8305. --- of {lnum}, see |line()|.
  8306. --- If {group} is "*", then signs in all the groups including the
  8307. --- global group are returned. If {group} is not supplied or is an
  8308. --- empty string, then only signs in the global group are
  8309. --- returned. If no arguments are supplied, then signs in the
  8310. --- global group placed in all the buffers are returned.
  8311. --- See |sign-group|.
  8312. ---
  8313. --- Each list item in the returned value is a dictionary with the
  8314. --- following entries:
  8315. --- bufnr number of the buffer with the sign
  8316. --- signs list of signs placed in {bufnr}. Each list
  8317. --- item is a dictionary with the below listed
  8318. --- entries
  8319. ---
  8320. --- The dictionary for each sign contains the following entries:
  8321. --- group sign group. Set to '' for the global group.
  8322. --- id identifier of the sign
  8323. --- lnum line number where the sign is placed
  8324. --- name name of the defined sign
  8325. --- priority sign priority
  8326. ---
  8327. --- The returned signs in a buffer are ordered by their line
  8328. --- number and priority.
  8329. ---
  8330. --- Returns an empty list on failure or if there are no placed
  8331. --- signs.
  8332. ---
  8333. --- Examples: >vim
  8334. --- " Get a List of signs placed in eval.c in the
  8335. --- " global group
  8336. --- echo sign_getplaced("eval.c")
  8337. ---
  8338. --- " Get a List of signs in group 'g1' placed in eval.c
  8339. --- echo sign_getplaced("eval.c", {'group' : 'g1'})
  8340. ---
  8341. --- " Get a List of signs placed at line 10 in eval.c
  8342. --- echo sign_getplaced("eval.c", {'lnum' : 10})
  8343. ---
  8344. --- " Get sign with identifier 10 placed in a.py
  8345. --- echo sign_getplaced("a.py", {'id' : 10})
  8346. ---
  8347. --- " Get sign with id 20 in group 'g1' placed in a.py
  8348. --- echo sign_getplaced("a.py", {'group' : 'g1',
  8349. --- \ 'id' : 20})
  8350. ---
  8351. --- " Get a List of all the placed signs
  8352. --- echo sign_getplaced()
  8353. --- <
  8354. ---
  8355. --- @param buf? integer|string
  8356. --- @param dict? vim.fn.sign_getplaced.dict
  8357. --- @return vim.fn.sign_getplaced.ret.item[]
  8358. function vim.fn.sign_getplaced(buf, dict) end
  8359. --- Open the buffer {buf} or jump to the window that contains
  8360. --- {buf} and position the cursor at sign {id} in group {group}.
  8361. --- This is similar to the |:sign-jump| command.
  8362. ---
  8363. --- If {group} is an empty string, then the global group is used.
  8364. --- For the use of {buf}, see |bufname()|.
  8365. ---
  8366. --- Returns the line number of the sign. Returns -1 if the
  8367. --- arguments are invalid.
  8368. ---
  8369. --- Example: >vim
  8370. --- " Jump to sign 10 in the current buffer
  8371. --- call sign_jump(10, '', '')
  8372. --- <
  8373. ---
  8374. --- @param id integer
  8375. --- @param group string
  8376. --- @param buf integer|string
  8377. --- @return integer
  8378. function vim.fn.sign_jump(id, group, buf) end
  8379. --- Place the sign defined as {name} at line {lnum} in file or
  8380. --- buffer {buf} and assign {id} and {group} to sign. This is
  8381. --- similar to the |:sign-place| command.
  8382. ---
  8383. --- If the sign identifier {id} is zero, then a new identifier is
  8384. --- allocated. Otherwise the specified number is used. {group} is
  8385. --- the sign group name. To use the global sign group, use an
  8386. --- empty string. {group} functions as a namespace for {id}, thus
  8387. --- two groups can use the same IDs. Refer to |sign-identifier|
  8388. --- and |sign-group| for more information.
  8389. ---
  8390. --- {name} refers to a defined sign.
  8391. --- {buf} refers to a buffer name or number. For the accepted
  8392. --- values, see |bufname()|.
  8393. ---
  8394. --- The optional {dict} argument supports the following entries:
  8395. --- lnum line number in the file or buffer
  8396. --- {buf} where the sign is to be placed.
  8397. --- For the accepted values, see |line()|.
  8398. --- priority priority of the sign. See
  8399. --- |sign-priority| for more information.
  8400. ---
  8401. --- If the optional {dict} is not specified, then it modifies the
  8402. --- placed sign {id} in group {group} to use the defined sign
  8403. --- {name}.
  8404. ---
  8405. --- Returns the sign identifier on success and -1 on failure.
  8406. ---
  8407. --- Examples: >vim
  8408. --- " Place a sign named sign1 with id 5 at line 20 in
  8409. --- " buffer json.c
  8410. --- call sign_place(5, '', 'sign1', 'json.c',
  8411. --- \ {'lnum' : 20})
  8412. ---
  8413. --- " Updates sign 5 in buffer json.c to use sign2
  8414. --- call sign_place(5, '', 'sign2', 'json.c')
  8415. ---
  8416. --- " Place a sign named sign3 at line 30 in
  8417. --- " buffer json.c with a new identifier
  8418. --- let id = sign_place(0, '', 'sign3', 'json.c',
  8419. --- \ {'lnum' : 30})
  8420. ---
  8421. --- " Place a sign named sign4 with id 10 in group 'g3'
  8422. --- " at line 40 in buffer json.c with priority 90
  8423. --- call sign_place(10, 'g3', 'sign4', 'json.c',
  8424. --- \ {'lnum' : 40, 'priority' : 90})
  8425. --- <
  8426. ---
  8427. --- @param id integer
  8428. --- @param group string
  8429. --- @param name string
  8430. --- @param buf integer|string
  8431. --- @param dict? vim.fn.sign_place.dict
  8432. --- @return integer
  8433. function vim.fn.sign_place(id, group, name, buf, dict) end
  8434. --- Place one or more signs. This is similar to the
  8435. --- |sign_place()| function. The {list} argument specifies the
  8436. --- List of signs to place. Each list item is a dict with the
  8437. --- following sign attributes:
  8438. --- buffer Buffer name or number. For the accepted
  8439. --- values, see |bufname()|.
  8440. --- group Sign group. {group} functions as a namespace
  8441. --- for {id}, thus two groups can use the same
  8442. --- IDs. If not specified or set to an empty
  8443. --- string, then the global group is used. See
  8444. --- |sign-group| for more information.
  8445. --- id Sign identifier. If not specified or zero,
  8446. --- then a new unique identifier is allocated.
  8447. --- Otherwise the specified number is used. See
  8448. --- |sign-identifier| for more information.
  8449. --- lnum Line number in the buffer where the sign is to
  8450. --- be placed. For the accepted values, see
  8451. --- |line()|.
  8452. --- name Name of the sign to place. See |sign_define()|
  8453. --- for more information.
  8454. --- priority Priority of the sign. When multiple signs are
  8455. --- placed on a line, the sign with the highest
  8456. --- priority is used. If not specified, the
  8457. --- default value of 10 is used, unless specified
  8458. --- otherwise by the sign definition. See
  8459. --- |sign-priority| for more information.
  8460. ---
  8461. --- If {id} refers to an existing sign, then the existing sign is
  8462. --- modified to use the specified {name} and/or {priority}.
  8463. ---
  8464. --- Returns a List of sign identifiers. If failed to place a
  8465. --- sign, the corresponding list item is set to -1.
  8466. ---
  8467. --- Examples: >vim
  8468. --- " Place sign s1 with id 5 at line 20 and id 10 at line
  8469. --- " 30 in buffer a.c
  8470. --- let [n1, n2] = sign_placelist([
  8471. --- \ {'id' : 5,
  8472. --- \ 'name' : 's1',
  8473. --- \ 'buffer' : 'a.c',
  8474. --- \ 'lnum' : 20},
  8475. --- \ {'id' : 10,
  8476. --- \ 'name' : 's1',
  8477. --- \ 'buffer' : 'a.c',
  8478. --- \ 'lnum' : 30}
  8479. --- \ ])
  8480. ---
  8481. --- " Place sign s1 in buffer a.c at line 40 and 50
  8482. --- " with auto-generated identifiers
  8483. --- let [n1, n2] = sign_placelist([
  8484. --- \ {'name' : 's1',
  8485. --- \ 'buffer' : 'a.c',
  8486. --- \ 'lnum' : 40},
  8487. --- \ {'name' : 's1',
  8488. --- \ 'buffer' : 'a.c',
  8489. --- \ 'lnum' : 50}
  8490. --- \ ])
  8491. --- <
  8492. ---
  8493. --- @param list vim.fn.sign_placelist.list.item[]
  8494. --- @return integer[]
  8495. function vim.fn.sign_placelist(list) end
  8496. --- @param name? string
  8497. --- @return 0|-1
  8498. function vim.fn.sign_undefine(name) end
  8499. --- Deletes a previously defined sign {name}. This is similar to
  8500. --- the |:sign-undefine| command. If {name} is not supplied, then
  8501. --- deletes all the defined signs.
  8502. ---
  8503. --- The one argument {list} can be used to undefine a list of
  8504. --- signs. Each list item is the name of a sign.
  8505. ---
  8506. --- Returns 0 on success and -1 on failure. For the one argument
  8507. --- {list} call, returns a list of values one for each undefined
  8508. --- sign.
  8509. ---
  8510. --- Examples: >vim
  8511. --- " Delete a sign named mySign
  8512. --- call sign_undefine("mySign")
  8513. ---
  8514. --- " Delete signs 'sign1' and 'sign2'
  8515. --- call sign_undefine(["sign1", "sign2"])
  8516. ---
  8517. --- " Delete all the signs
  8518. --- call sign_undefine()
  8519. --- <
  8520. ---
  8521. --- @param list? string[]
  8522. --- @return integer[]
  8523. function vim.fn.sign_undefine(list) end
  8524. --- Remove a previously placed sign in one or more buffers. This
  8525. --- is similar to the |:sign-unplace| command.
  8526. ---
  8527. --- {group} is the sign group name. To use the global sign group,
  8528. --- use an empty string. If {group} is set to "*", then all the
  8529. --- groups including the global group are used.
  8530. --- The signs in {group} are selected based on the entries in
  8531. --- {dict}. The following optional entries in {dict} are
  8532. --- supported:
  8533. --- buffer buffer name or number. See |bufname()|.
  8534. --- id sign identifier
  8535. --- If {dict} is not supplied, then all the signs in {group} are
  8536. --- removed.
  8537. ---
  8538. --- Returns 0 on success and -1 on failure.
  8539. ---
  8540. --- Examples: >vim
  8541. --- " Remove sign 10 from buffer a.vim
  8542. --- call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
  8543. ---
  8544. --- " Remove sign 20 in group 'g1' from buffer 3
  8545. --- call sign_unplace('g1', {'buffer' : 3, 'id' : 20})
  8546. ---
  8547. --- " Remove all the signs in group 'g2' from buffer 10
  8548. --- call sign_unplace('g2', {'buffer' : 10})
  8549. ---
  8550. --- " Remove sign 30 in group 'g3' from all the buffers
  8551. --- call sign_unplace('g3', {'id' : 30})
  8552. ---
  8553. --- " Remove all the signs placed in buffer 5
  8554. --- call sign_unplace('*', {'buffer' : 5})
  8555. ---
  8556. --- " Remove the signs in group 'g4' from all the buffers
  8557. --- call sign_unplace('g4')
  8558. ---
  8559. --- " Remove sign 40 from all the buffers
  8560. --- call sign_unplace('*', {'id' : 40})
  8561. ---
  8562. --- " Remove all the placed signs from all the buffers
  8563. --- call sign_unplace('*')
  8564. ---
  8565. --- @param group string
  8566. --- @param dict? vim.fn.sign_unplace.dict
  8567. --- @return 0|-1
  8568. function vim.fn.sign_unplace(group, dict) end
  8569. --- Remove previously placed signs from one or more buffers. This
  8570. --- is similar to the |sign_unplace()| function.
  8571. ---
  8572. --- The {list} argument specifies the List of signs to remove.
  8573. --- Each list item is a dict with the following sign attributes:
  8574. --- buffer buffer name or number. For the accepted
  8575. --- values, see |bufname()|. If not specified,
  8576. --- then the specified sign is removed from all
  8577. --- the buffers.
  8578. --- group sign group name. If not specified or set to an
  8579. --- empty string, then the global sign group is
  8580. --- used. If set to "*", then all the groups
  8581. --- including the global group are used.
  8582. --- id sign identifier. If not specified, then all
  8583. --- the signs in the specified group are removed.
  8584. ---
  8585. --- Returns a List where an entry is set to 0 if the corresponding
  8586. --- sign was successfully removed or -1 on failure.
  8587. ---
  8588. --- Example: >vim
  8589. --- " Remove sign with id 10 from buffer a.vim and sign
  8590. --- " with id 20 from buffer b.vim
  8591. --- call sign_unplacelist([
  8592. --- \ {'id' : 10, 'buffer' : "a.vim"},
  8593. --- \ {'id' : 20, 'buffer' : 'b.vim'},
  8594. --- \ ])
  8595. --- <
  8596. ---
  8597. --- @param list vim.fn.sign_unplacelist.list.item
  8598. --- @return (0|-1)[]
  8599. function vim.fn.sign_unplacelist(list) end
  8600. --- Simplify the file name as much as possible without changing
  8601. --- the meaning. Shortcuts (on MS-Windows) or symbolic links (on
  8602. --- Unix) are not resolved. If the first path component in
  8603. --- {filename} designates the current directory, this will be
  8604. --- valid for the result as well. A trailing path separator is
  8605. --- not removed either. On Unix "//path" is unchanged, but
  8606. --- "///path" is simplified to "/path" (this follows the Posix
  8607. --- standard).
  8608. --- Example: >vim
  8609. --- simplify("./dir/.././/file/") == "./file/"
  8610. --- <Note: The combination "dir/.." is only removed if "dir" is
  8611. --- a searchable directory or does not exist. On Unix, it is also
  8612. --- removed when "dir" is a symbolic link within the same
  8613. --- directory. In order to resolve all the involved symbolic
  8614. --- links before simplifying the path name, use |resolve()|.
  8615. ---
  8616. --- @param filename string
  8617. --- @return string
  8618. function vim.fn.simplify(filename) end
  8619. --- Return the sine of {expr}, measured in radians, as a |Float|.
  8620. --- {expr} must evaluate to a |Float| or a |Number|.
  8621. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8622. --- Examples: >vim
  8623. --- echo sin(100)
  8624. --- < -0.506366 >vim
  8625. --- echo sin(-4.01)
  8626. --- < 0.763301
  8627. ---
  8628. --- @param expr number
  8629. --- @return number
  8630. function vim.fn.sin(expr) end
  8631. --- Return the hyperbolic sine of {expr} as a |Float| in the range
  8632. --- [-inf, inf].
  8633. --- {expr} must evaluate to a |Float| or a |Number|.
  8634. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8635. --- Examples: >vim
  8636. --- echo sinh(0.5)
  8637. --- < 0.521095 >vim
  8638. --- echo sinh(-0.9)
  8639. --- < -1.026517
  8640. ---
  8641. --- @param expr number
  8642. --- @return any
  8643. function vim.fn.sinh(expr) end
  8644. --- Similar to using a |slice| "expr[start : end]", but "end" is
  8645. --- used exclusive. And for a string the indexes are used as
  8646. --- character indexes instead of byte indexes.
  8647. --- Also, composing characters are treated as a part of the
  8648. --- preceding base character.
  8649. --- When {end} is omitted the slice continues to the last item.
  8650. --- When {end} is -1 the last item is omitted.
  8651. --- Returns an empty value if {start} or {end} are invalid.
  8652. ---
  8653. --- @param expr any
  8654. --- @param start integer
  8655. --- @param end_? integer
  8656. --- @return any
  8657. function vim.fn.slice(expr, start, end_) end
  8658. --- Connect a socket to an address. If {mode} is "pipe" then
  8659. --- {address} should be the path of a local domain socket (on
  8660. --- unix) or named pipe (on Windows). If {mode} is "tcp" then
  8661. --- {address} should be of the form "host:port" where the host
  8662. --- should be an ip address or host name, and port the port
  8663. --- number.
  8664. ---
  8665. --- For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see
  8666. --- |luv-tcp-handle|.
  8667. ---
  8668. --- Returns a |channel| ID. Close the socket with |chanclose()|.
  8669. --- Use |chansend()| to send data over a bytes socket, and
  8670. --- |rpcrequest()| and |rpcnotify()| to communicate with a RPC
  8671. --- socket.
  8672. ---
  8673. --- {opts} is an optional dictionary with these keys:
  8674. --- |on_data| : callback invoked when data was read from socket
  8675. --- data_buffered : read socket data in |channel-buffered| mode.
  8676. --- rpc : If set, |msgpack-rpc| will be used to communicate
  8677. --- over the socket.
  8678. --- Returns:
  8679. --- - The channel ID on success (greater than zero)
  8680. --- - 0 on invalid arguments or connection failure.
  8681. ---
  8682. --- @param mode string
  8683. --- @param address string
  8684. --- @param opts? table
  8685. --- @return any
  8686. function vim.fn.sockconnect(mode, address, opts) end
  8687. --- Sort the items in {list} in-place. Returns {list}.
  8688. ---
  8689. --- If you want a list to remain unmodified make a copy first: >vim
  8690. --- let sortedlist = sort(copy(mylist))
  8691. ---
  8692. --- <When {how} is omitted or is a string, then sort() uses the
  8693. --- string representation of each item to sort on. Numbers sort
  8694. --- after Strings, |Lists| after Numbers. For sorting text in the
  8695. --- current buffer use |:sort|.
  8696. ---
  8697. --- When {how} is given and it is 'i' then case is ignored.
  8698. --- For backwards compatibility, the value one can be used to
  8699. --- ignore case. Zero means to not ignore case.
  8700. ---
  8701. --- When {how} is given and it is 'l' then the current collation
  8702. --- locale is used for ordering. Implementation details: strcoll()
  8703. --- is used to compare strings. See |:language| check or set the
  8704. --- collation locale. |v:collate| can also be used to check the
  8705. --- current locale. Sorting using the locale typically ignores
  8706. --- case. Example: >vim
  8707. --- " ö is sorted similarly to o with English locale.
  8708. --- language collate en_US.UTF8
  8709. --- echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8710. --- < ['n', 'o', 'O', 'ö', 'p', 'z'] ~
  8711. --- >vim
  8712. --- " ö is sorted after z with Swedish locale.
  8713. --- language collate sv_SE.UTF8
  8714. --- echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8715. --- < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
  8716. --- This does not work properly on Mac.
  8717. ---
  8718. --- When {how} is given and it is 'n' then all items will be
  8719. --- sorted numerical (Implementation detail: this uses the
  8720. --- strtod() function to parse numbers, Strings, Lists, Dicts and
  8721. --- Funcrefs will be considered as being 0).
  8722. ---
  8723. --- When {how} is given and it is 'N' then all items will be
  8724. --- sorted numerical. This is like 'n' but a string containing
  8725. --- digits will be used as the number they represent.
  8726. ---
  8727. --- When {how} is given and it is 'f' then all items will be
  8728. --- sorted numerical. All values must be a Number or a Float.
  8729. ---
  8730. --- When {how} is a |Funcref| or a function name, this function
  8731. --- is called to compare items. The function is invoked with two
  8732. --- items as argument and must return zero if they are equal, 1 or
  8733. --- bigger if the first one sorts after the second one, -1 or
  8734. --- smaller if the first one sorts before the second one.
  8735. ---
  8736. --- {dict} is for functions with the "dict" attribute. It will be
  8737. --- used to set the local variable "self". |Dictionary-function|
  8738. ---
  8739. --- The sort is stable, items which compare equal (as number or as
  8740. --- string) will keep their relative position. E.g., when sorting
  8741. --- on numbers, text strings will sort next to each other, in the
  8742. --- same order as they were originally.
  8743. ---
  8744. ---
  8745. --- Example: >vim
  8746. --- func MyCompare(i1, i2)
  8747. --- return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
  8748. --- endfunc
  8749. --- eval mylist->sort("MyCompare")
  8750. --- <A shorter compare version for this specific simple case, which
  8751. --- ignores overflow: >vim
  8752. --- func MyCompare(i1, i2)
  8753. --- return a:i1 - a:i2
  8754. --- endfunc
  8755. --- <For a simple expression you can use a lambda: >vim
  8756. --- eval mylist->sort({i1, i2 -> i1 - i2})
  8757. --- <
  8758. ---
  8759. --- @generic T
  8760. --- @param list T[]
  8761. --- @param how? string|function
  8762. --- @param dict? any
  8763. --- @return T[]
  8764. function vim.fn.sort(list, how, dict) end
  8765. --- Return the sound-folded equivalent of {word}. Uses the first
  8766. --- language in 'spelllang' for the current window that supports
  8767. --- soundfolding. 'spell' must be set. When no sound folding is
  8768. --- possible the {word} is returned unmodified.
  8769. --- This can be used for making spelling suggestions. Note that
  8770. --- the method can be quite slow.
  8771. ---
  8772. --- @param word string
  8773. --- @return string
  8774. function vim.fn.soundfold(word) end
  8775. --- Without argument: The result is the badly spelled word under
  8776. --- or after the cursor. The cursor is moved to the start of the
  8777. --- bad word. When no bad word is found in the cursor line the
  8778. --- result is an empty string and the cursor doesn't move.
  8779. ---
  8780. --- With argument: The result is the first word in {sentence} that
  8781. --- is badly spelled. If there are no spelling mistakes the
  8782. --- result is an empty string.
  8783. ---
  8784. --- The return value is a list with two items:
  8785. --- - The badly spelled word or an empty string.
  8786. --- - The type of the spelling error:
  8787. --- "bad" spelling mistake
  8788. --- "rare" rare word
  8789. --- "local" word only valid in another region
  8790. --- "caps" word should start with Capital
  8791. --- Example: >vim
  8792. --- echo spellbadword("the quik brown fox")
  8793. --- < ['quik', 'bad'] ~
  8794. ---
  8795. --- The spelling information for the current window and the value
  8796. --- of 'spelllang' are used.
  8797. ---
  8798. --- @param sentence? string
  8799. --- @return any
  8800. function vim.fn.spellbadword(sentence) end
  8801. --- Return a |List| with spelling suggestions to replace {word}.
  8802. --- When {max} is given up to this number of suggestions are
  8803. --- returned. Otherwise up to 25 suggestions are returned.
  8804. ---
  8805. --- When the {capital} argument is given and it's non-zero only
  8806. --- suggestions with a leading capital will be given. Use this
  8807. --- after a match with 'spellcapcheck'.
  8808. ---
  8809. --- {word} can be a badly spelled word followed by other text.
  8810. --- This allows for joining two words that were split. The
  8811. --- suggestions also include the following text, thus you can
  8812. --- replace a line.
  8813. ---
  8814. --- {word} may also be a good word. Similar words will then be
  8815. --- returned. {word} itself is not included in the suggestions,
  8816. --- although it may appear capitalized.
  8817. ---
  8818. --- The spelling information for the current window is used. The
  8819. --- values of 'spelllang' and 'spellsuggest' are used.
  8820. ---
  8821. --- @param word string
  8822. --- @param max? integer
  8823. --- @param capital? boolean
  8824. --- @return string[]
  8825. function vim.fn.spellsuggest(word, max, capital) end
  8826. --- Make a |List| out of {string}. When {pattern} is omitted or
  8827. --- empty each white space separated sequence of characters
  8828. --- becomes an item.
  8829. --- Otherwise the string is split where {pattern} matches,
  8830. --- removing the matched characters. 'ignorecase' is not used
  8831. --- here, add \c to ignore case. |/\c|
  8832. --- When the first or last item is empty it is omitted, unless the
  8833. --- {keepempty} argument is given and it's non-zero.
  8834. --- Other empty items are kept when {pattern} matches at least one
  8835. --- character or when {keepempty} is non-zero.
  8836. --- Example: >vim
  8837. --- let words = split(getline('.'), '\W\+')
  8838. --- <To split a string in individual characters: >vim
  8839. --- for c in split(mystring, '\zs') | endfor
  8840. --- <If you want to keep the separator you can also use '\zs' at
  8841. --- the end of the pattern: >vim
  8842. --- echo split('abc:def:ghi', ':\zs')
  8843. --- < >
  8844. --- ['abc:', 'def:', 'ghi']
  8845. --- <
  8846. --- Splitting a table where the first element can be empty: >vim
  8847. --- let items = split(line, ':', 1)
  8848. --- <The opposite function is |join()|.
  8849. ---
  8850. --- @param string string
  8851. --- @param pattern? string
  8852. --- @param keepempty? boolean
  8853. --- @return string[]
  8854. function vim.fn.split(string, pattern, keepempty) end
  8855. --- Return the non-negative square root of Float {expr} as a
  8856. --- |Float|.
  8857. --- {expr} must evaluate to a |Float| or a |Number|. When {expr}
  8858. --- is negative the result is NaN (Not a Number). Returns 0.0 if
  8859. --- {expr} is not a |Float| or a |Number|.
  8860. --- Examples: >vim
  8861. --- echo sqrt(100)
  8862. --- < 10.0 >vim
  8863. --- echo sqrt(-4.01)
  8864. --- < str2float("nan")
  8865. --- NaN may be different, it depends on system libraries.
  8866. ---
  8867. --- @param expr number
  8868. --- @return any
  8869. function vim.fn.sqrt(expr) end
  8870. --- Initialize seed used by |rand()|:
  8871. --- - If {expr} is not given, seed values are initialized by
  8872. --- reading from /dev/urandom, if possible, or using time(NULL)
  8873. --- a.k.a. epoch time otherwise; this only has second accuracy.
  8874. --- - If {expr} is given it must be a Number. It is used to
  8875. --- initialize the seed values. This is useful for testing or
  8876. --- when a predictable sequence is intended.
  8877. ---
  8878. --- Examples: >vim
  8879. --- let seed = srand()
  8880. --- let seed = srand(userinput)
  8881. --- echo rand(seed)
  8882. --- <
  8883. ---
  8884. --- @param expr? number
  8885. --- @return any
  8886. function vim.fn.srand(expr) end
  8887. --- Return a string which contains characters indicating the
  8888. --- current state. Mostly useful in callbacks that want to do
  8889. --- work that may not always be safe. Roughly this works like:
  8890. --- - callback uses state() to check if work is safe to do.
  8891. --- Yes: then do it right away.
  8892. --- No: add to work queue and add a |SafeState| autocommand.
  8893. --- - When SafeState is triggered and executes your autocommand,
  8894. --- check with `state()` if the work can be done now, and if yes
  8895. --- remove it from the queue and execute.
  8896. --- Remove the autocommand if the queue is now empty.
  8897. --- Also see |mode()|.
  8898. ---
  8899. --- When {what} is given only characters in this string will be
  8900. --- added. E.g, this checks if the screen has scrolled: >vim
  8901. --- if state('s') == ''
  8902. --- " screen has not scrolled
  8903. --- <
  8904. --- These characters indicate the state, generally indicating that
  8905. --- something is busy:
  8906. --- m halfway a mapping, :normal command, feedkeys() or
  8907. --- stuffed command
  8908. --- o operator pending, e.g. after |d|
  8909. --- a Insert mode autocomplete active
  8910. --- x executing an autocommand
  8911. --- S not triggering SafeState, e.g. after |f| or a count
  8912. --- c callback invoked, including timer (repeats for
  8913. --- recursiveness up to "ccc")
  8914. --- s screen has scrolled for messages
  8915. ---
  8916. --- @param what? string
  8917. --- @return any
  8918. function vim.fn.state(what) end
  8919. --- With |--headless| this opens stdin and stdout as a |channel|.
  8920. --- May be called only once. See |channel-stdio|. stderr is not
  8921. --- handled by this function, see |v:stderr|.
  8922. ---
  8923. --- Close the stdio handles with |chanclose()|. Use |chansend()|
  8924. --- to send data to stdout, and |rpcrequest()| and |rpcnotify()|
  8925. --- to communicate over RPC.
  8926. ---
  8927. --- {opts} is a dictionary with these keys:
  8928. --- |on_stdin| : callback invoked when stdin is written to.
  8929. --- on_print : callback invoked when Nvim needs to print a
  8930. --- message, with the message (whose type is string)
  8931. --- as sole argument.
  8932. --- stdin_buffered : read stdin in |channel-buffered| mode.
  8933. --- rpc : If set, |msgpack-rpc| will be used to communicate
  8934. --- over stdio
  8935. --- Returns:
  8936. --- - |channel-id| on success (value is always 1)
  8937. --- - 0 on invalid arguments
  8938. ---
  8939. --- @param opts table
  8940. --- @return any
  8941. function vim.fn.stdioopen(opts) end
  8942. --- Returns |standard-path| locations of various default files and
  8943. --- directories. The locations are driven by |base-directories|
  8944. --- which you can configure via |$NVIM_APPNAME| or the `$XDG_…`
  8945. --- environment variables.
  8946. ---
  8947. --- {what} Type Description ~
  8948. --- cache String Cache directory: arbitrary temporary
  8949. --- storage for plugins, etc.
  8950. --- config String User configuration directory. |init.vim|
  8951. --- is stored here.
  8952. --- config_dirs List Other configuration directories.
  8953. --- data String User data directory.
  8954. --- data_dirs List Other data directories.
  8955. --- log String Logs directory (for use by plugins too).
  8956. --- run String Run directory: temporary, local storage
  8957. --- for sockets, named pipes, etc.
  8958. --- state String Session state directory: storage for file
  8959. --- drafts, swap, undo, |shada|.
  8960. ---
  8961. --- Example: >vim
  8962. --- echo stdpath("config")
  8963. --- <
  8964. ---
  8965. --- @param what 'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'
  8966. --- @return string|string[]
  8967. function vim.fn.stdpath(what) end
  8968. --- @param what 'cache'|'config'|'data'|'log'|'run'|'state'
  8969. --- @return string
  8970. function vim.fn.stdpath(what) end
  8971. --- @param what 'config_dirs'|'data_dirs'
  8972. --- @return string[]
  8973. function vim.fn.stdpath(what) end
  8974. --- Convert String {string} to a Float. This mostly works the
  8975. --- same as when using a floating point number in an expression,
  8976. --- see |floating-point-format|. But it's a bit more permissive.
  8977. --- E.g., "1e40" is accepted, while in an expression you need to
  8978. --- write "1.0e40". The hexadecimal form "0x123" is also
  8979. --- accepted, but not others, like binary or octal.
  8980. --- When {quoted} is present and non-zero then embedded single
  8981. --- quotes before the dot are ignored, thus "1'000.0" is a
  8982. --- thousand.
  8983. --- Text after the number is silently ignored.
  8984. --- The decimal point is always '.', no matter what the locale is
  8985. --- set to. A comma ends the number: "12,345.67" is converted to
  8986. --- 12.0. You can strip out thousands separators with
  8987. --- |substitute()|: >vim
  8988. --- let f = str2float(substitute(text, ',', '', 'g'))
  8989. --- <
  8990. --- Returns 0.0 if the conversion fails.
  8991. ---
  8992. --- @param string string
  8993. --- @param quoted? boolean
  8994. --- @return any
  8995. function vim.fn.str2float(string, quoted) end
  8996. --- Return a list containing the number values which represent
  8997. --- each character in String {string}. Examples: >vim
  8998. --- echo str2list(" ") " returns [32]
  8999. --- echo str2list("ABC") " returns [65, 66, 67]
  9000. --- <|list2str()| does the opposite.
  9001. ---
  9002. --- UTF-8 encoding is always used, {utf8} option has no effect,
  9003. --- and exists only for backwards-compatibility.
  9004. --- With UTF-8 composing characters are handled properly: >vim
  9005. --- echo str2list("á") " returns [97, 769]
  9006. --- <
  9007. ---
  9008. --- @param string string
  9009. --- @param utf8? boolean
  9010. --- @return any
  9011. function vim.fn.str2list(string, utf8) end
  9012. --- Convert string {string} to a number.
  9013. --- {base} is the conversion base, it can be 2, 8, 10 or 16.
  9014. --- When {quoted} is present and non-zero then embedded single
  9015. --- quotes are ignored, thus "1'000'000" is a million.
  9016. ---
  9017. --- When {base} is omitted base 10 is used. This also means that
  9018. --- a leading zero doesn't cause octal conversion to be used, as
  9019. --- with the default String to Number conversion. Example: >vim
  9020. --- let nr = str2nr('0123')
  9021. --- <
  9022. --- When {base} is 16 a leading "0x" or "0X" is ignored. With a
  9023. --- different base the result will be zero. Similarly, when
  9024. --- {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
  9025. --- {base} is 2 a leading "0b" or "0B" is ignored.
  9026. --- Text after the number is silently ignored.
  9027. ---
  9028. --- Returns 0 if {string} is empty or on error.
  9029. ---
  9030. --- @param string string
  9031. --- @param base? integer
  9032. --- @return any
  9033. function vim.fn.str2nr(string, base) end
  9034. --- The result is a Number, which is the number of characters
  9035. --- in String {string}. Composing characters are ignored.
  9036. --- |strchars()| can count the number of characters, counting
  9037. --- composing characters separately.
  9038. ---
  9039. --- Returns 0 if {string} is empty or on error.
  9040. ---
  9041. --- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  9042. ---
  9043. --- @param string string
  9044. --- @return any
  9045. function vim.fn.strcharlen(string) end
  9046. --- Like |strpart()| but using character index and length instead
  9047. --- of byte index and length.
  9048. --- When {skipcc} is omitted or zero, composing characters are
  9049. --- counted separately.
  9050. --- When {skipcc} set to 1, composing characters are treated as a
  9051. --- part of the preceding base character, similar to |slice()|.
  9052. --- When a character index is used where a character does not
  9053. --- exist it is omitted and counted as one character. For
  9054. --- example: >vim
  9055. --- echo strcharpart('abc', -1, 2)
  9056. --- <results in 'a'.
  9057. ---
  9058. --- Returns an empty string on error.
  9059. ---
  9060. --- @param src string
  9061. --- @param start integer
  9062. --- @param len? integer
  9063. --- @param skipcc? boolean
  9064. --- @return any
  9065. function vim.fn.strcharpart(src, start, len, skipcc) end
  9066. --- The result is a Number, which is the number of characters
  9067. --- in String {string}.
  9068. --- When {skipcc} is omitted or zero, composing characters are
  9069. --- counted separately.
  9070. --- When {skipcc} set to 1, composing characters are ignored.
  9071. --- |strcharlen()| always does this.
  9072. ---
  9073. --- Returns zero on error.
  9074. ---
  9075. --- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  9076. ---
  9077. --- {skipcc} is only available after 7.4.755. For backward
  9078. --- compatibility, you can define a wrapper function: >vim
  9079. --- if has("patch-7.4.755")
  9080. --- function s:strchars(str, skipcc)
  9081. --- return strchars(a:str, a:skipcc)
  9082. --- endfunction
  9083. --- else
  9084. --- function s:strchars(str, skipcc)
  9085. --- if a:skipcc
  9086. --- return strlen(substitute(a:str, ".", "x", "g"))
  9087. --- else
  9088. --- return strchars(a:str)
  9089. --- endif
  9090. --- endfunction
  9091. --- endif
  9092. --- <
  9093. ---
  9094. --- @param string string
  9095. --- @param skipcc? boolean
  9096. --- @return integer
  9097. function vim.fn.strchars(string, skipcc) end
  9098. --- The result is a Number, which is the number of display cells
  9099. --- String {string} occupies on the screen when it starts at {col}
  9100. --- (first column is zero). When {col} is omitted zero is used.
  9101. --- Otherwise it is the screen column where to start. This
  9102. --- matters for Tab characters.
  9103. --- The option settings of the current window are used. This
  9104. --- matters for anything that's displayed differently, such as
  9105. --- 'tabstop' and 'display'.
  9106. --- When {string} contains characters with East Asian Width Class
  9107. --- Ambiguous, this function's return value depends on 'ambiwidth'.
  9108. --- Returns zero on error.
  9109. --- Also see |strlen()|, |strwidth()| and |strchars()|.
  9110. ---
  9111. --- @param string string
  9112. --- @param col? integer
  9113. --- @return integer
  9114. function vim.fn.strdisplaywidth(string, col) end
  9115. --- The result is a String, which is a formatted date and time, as
  9116. --- specified by the {format} string. The given {time} is used,
  9117. --- or the current time if no time is given. The accepted
  9118. --- {format} depends on your system, thus this is not portable!
  9119. --- See the manual page of the C function strftime() for the
  9120. --- format. The maximum length of the result is 80 characters.
  9121. --- See also |localtime()|, |getftime()| and |strptime()|.
  9122. --- The language can be changed with the |:language| command.
  9123. --- Examples: >vim
  9124. --- echo strftime("%c") " Sun Apr 27 11:49:23 1997
  9125. --- echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
  9126. --- echo strftime("%y%m%d %T") " 970427 11:53:55
  9127. --- echo strftime("%H:%M") " 11:55
  9128. --- echo strftime("%c", getftime("file.c"))
  9129. --- " Show mod time of file.c.
  9130. ---
  9131. --- @param format string
  9132. --- @param time? number
  9133. --- @return string
  9134. function vim.fn.strftime(format, time) end
  9135. --- Get a Number corresponding to the character at {index} in
  9136. --- {str}. This uses a zero-based character index, not a byte
  9137. --- index. Composing characters are considered separate
  9138. --- characters here. Use |nr2char()| to convert the Number to a
  9139. --- String.
  9140. --- Returns -1 if {index} is invalid.
  9141. --- Also see |strcharpart()| and |strchars()|.
  9142. ---
  9143. --- @param str string
  9144. --- @param index integer
  9145. --- @return integer
  9146. function vim.fn.strgetchar(str, index) end
  9147. --- The result is a Number, which gives the byte index in
  9148. --- {haystack} of the first occurrence of the String {needle}.
  9149. --- If {start} is specified, the search starts at index {start}.
  9150. --- This can be used to find a second match: >vim
  9151. --- let colon1 = stridx(line, ":")
  9152. --- let colon2 = stridx(line, ":", colon1 + 1)
  9153. --- <The search is done case-sensitive.
  9154. --- For pattern searches use |match()|.
  9155. --- -1 is returned if the {needle} does not occur in {haystack}.
  9156. --- See also |strridx()|.
  9157. --- Examples: >vim
  9158. --- echo stridx("An Example", "Example") " 3
  9159. --- echo stridx("Starting point", "Start") " 0
  9160. --- echo stridx("Starting point", "start") " -1
  9161. --- < *strstr()* *strchr()*
  9162. --- stridx() works similar to the C function strstr(). When used
  9163. --- with a single character it works similar to strchr().
  9164. ---
  9165. --- @param haystack string
  9166. --- @param needle string
  9167. --- @param start? integer
  9168. --- @return integer
  9169. function vim.fn.stridx(haystack, needle, start) end
  9170. --- Return {expr} converted to a String. If {expr} is a Number,
  9171. --- Float, String, Blob or a composition of them, then the result
  9172. --- can be parsed back with |eval()|.
  9173. --- {expr} type result ~
  9174. --- String 'string'
  9175. --- Number 123
  9176. --- Float 123.123456 or 1.123456e8 or
  9177. --- `str2float('inf')`
  9178. --- Funcref `function('name')`
  9179. --- Blob 0z00112233.44556677.8899
  9180. --- List [item, item]
  9181. --- Dictionary `{key: value, key: value}`
  9182. --- Note that in String values the ' character is doubled.
  9183. --- Also see |strtrans()|.
  9184. --- Note 2: Output format is mostly compatible with YAML, except
  9185. --- for infinite and NaN floating-point values representations
  9186. --- which use |str2float()|. Strings are also dumped literally,
  9187. --- only single quote is escaped, which does not allow using YAML
  9188. --- for parsing back binary strings. |eval()| should always work
  9189. --- for strings and floats though, and this is the only official
  9190. --- method. Use |msgpackdump()| or |json_encode()| if you need to
  9191. --- share data with other applications.
  9192. ---
  9193. --- @param expr any
  9194. --- @return string
  9195. function vim.fn.string(expr) end
  9196. --- The result is a Number, which is the length of the String
  9197. --- {string} in bytes.
  9198. --- If the argument is a Number it is first converted to a String.
  9199. --- For other types an error is given and zero is returned.
  9200. --- If you want to count the number of multibyte characters use
  9201. --- |strchars()|.
  9202. --- Also see |len()|, |strdisplaywidth()| and |strwidth()|.
  9203. ---
  9204. --- @param string string
  9205. --- @return integer
  9206. function vim.fn.strlen(string) end
  9207. --- The result is a String, which is part of {src}, starting from
  9208. --- byte {start}, with the byte length {len}.
  9209. --- When {chars} is present and TRUE then {len} is the number of
  9210. --- characters positions (composing characters are not counted
  9211. --- separately, thus "1" means one base character and any
  9212. --- following composing characters).
  9213. --- To count {start} as characters instead of bytes use
  9214. --- |strcharpart()|.
  9215. ---
  9216. --- When bytes are selected which do not exist, this doesn't
  9217. --- result in an error, the bytes are simply omitted.
  9218. --- If {len} is missing, the copy continues from {start} till the
  9219. --- end of the {src}. >vim
  9220. --- echo strpart("abcdefg", 3, 2) " returns 'de'
  9221. --- echo strpart("abcdefg", -2, 4) " returns 'ab'
  9222. --- echo strpart("abcdefg", 5, 4) " returns 'fg'
  9223. --- echo strpart("abcdefg", 3) " returns 'defg'
  9224. ---
  9225. --- <Note: To get the first character, {start} must be 0. For
  9226. --- example, to get the character under the cursor: >vim
  9227. --- strpart(getline("."), col(".") - 1, 1, v:true)
  9228. --- <
  9229. --- Returns an empty string on error.
  9230. ---
  9231. --- @param src string
  9232. --- @param start integer
  9233. --- @param len? integer
  9234. --- @param chars? 0|1
  9235. --- @return string
  9236. function vim.fn.strpart(src, start, len, chars) end
  9237. --- The result is a Number, which is a unix timestamp representing
  9238. --- the date and time in {timestring}, which is expected to match
  9239. --- the format specified in {format}.
  9240. ---
  9241. --- The accepted {format} depends on your system, thus this is not
  9242. --- portable! See the manual page of the C function strptime()
  9243. --- for the format. Especially avoid "%c". The value of $TZ also
  9244. --- matters.
  9245. ---
  9246. --- If the {timestring} cannot be parsed with {format} zero is
  9247. --- returned. If you do not know the format of {timestring} you
  9248. --- can try different {format} values until you get a non-zero
  9249. --- result.
  9250. ---
  9251. --- See also |strftime()|.
  9252. --- Examples: >vim
  9253. --- echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
  9254. --- < 862156163 >vim
  9255. --- echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
  9256. --- < Sun Apr 27 11:53:55 1997 >vim
  9257. --- echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
  9258. --- < Sun Apr 27 12:53:55 1997
  9259. ---
  9260. --- @param format string
  9261. --- @param timestring string
  9262. --- @return integer
  9263. function vim.fn.strptime(format, timestring) end
  9264. --- The result is a Number, which gives the byte index in
  9265. --- {haystack} of the last occurrence of the String {needle}.
  9266. --- When {start} is specified, matches beyond this index are
  9267. --- ignored. This can be used to find a match before a previous
  9268. --- match: >vim
  9269. --- let lastcomma = strridx(line, ",")
  9270. --- let comma2 = strridx(line, ",", lastcomma - 1)
  9271. --- <The search is done case-sensitive.
  9272. --- For pattern searches use |match()|.
  9273. --- -1 is returned if the {needle} does not occur in {haystack}.
  9274. --- If the {needle} is empty the length of {haystack} is returned.
  9275. --- See also |stridx()|. Examples: >vim
  9276. --- echo strridx("an angry armadillo", "an") 3
  9277. --- < *strrchr()*
  9278. --- When used with a single character it works similar to the C
  9279. --- function strrchr().
  9280. ---
  9281. --- @param haystack string
  9282. --- @param needle string
  9283. --- @param start? integer
  9284. --- @return integer
  9285. function vim.fn.strridx(haystack, needle, start) end
  9286. --- The result is a String, which is {string} with all unprintable
  9287. --- characters translated into printable characters |'isprint'|.
  9288. --- Like they are shown in a window. Example: >vim
  9289. --- echo strtrans(\@a)
  9290. --- <This displays a newline in register a as "^\@" instead of
  9291. --- starting a new line.
  9292. ---
  9293. --- Returns an empty string on error.
  9294. ---
  9295. --- @param string string
  9296. --- @return string
  9297. function vim.fn.strtrans(string) end
  9298. --- The result is a Number, which is the number of UTF-16 code
  9299. --- units in String {string} (after converting it to UTF-16).
  9300. ---
  9301. --- When {countcc} is TRUE, composing characters are counted
  9302. --- separately.
  9303. --- When {countcc} is omitted or FALSE, composing characters are
  9304. --- ignored.
  9305. ---
  9306. --- Returns zero on error.
  9307. ---
  9308. --- Also see |strlen()| and |strcharlen()|.
  9309. --- Examples: >vim
  9310. --- echo strutf16len('a') " returns 1
  9311. --- echo strutf16len('©') " returns 1
  9312. --- echo strutf16len('😊') " returns 2
  9313. --- echo strutf16len('ą́') " returns 1
  9314. --- echo strutf16len('ą́', v:true) " returns 3
  9315. --- <
  9316. ---
  9317. --- @param string string
  9318. --- @param countcc? 0|1
  9319. --- @return integer
  9320. function vim.fn.strutf16len(string, countcc) end
  9321. --- The result is a Number, which is the number of display cells
  9322. --- String {string} occupies. A Tab character is counted as one
  9323. --- cell, alternatively use |strdisplaywidth()|.
  9324. --- When {string} contains characters with East Asian Width Class
  9325. --- Ambiguous, this function's return value depends on 'ambiwidth'.
  9326. --- Returns zero on error.
  9327. --- Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
  9328. ---
  9329. --- @param string string
  9330. --- @return integer
  9331. function vim.fn.strwidth(string) end
  9332. --- Only for an expression in a |:substitute| command or
  9333. --- substitute() function.
  9334. --- Returns the {nr}th submatch of the matched text. When {nr}
  9335. --- is 0 the whole matched text is returned.
  9336. --- Note that a NL in the string can stand for a line break of a
  9337. --- multi-line match or a NUL character in the text.
  9338. --- Also see |sub-replace-expression|.
  9339. ---
  9340. --- If {list} is present and non-zero then submatch() returns
  9341. --- a list of strings, similar to |getline()| with two arguments.
  9342. --- NL characters in the text represent NUL characters in the
  9343. --- text.
  9344. --- Only returns more than one item for |:substitute|, inside
  9345. --- |substitute()| this list will always contain one or zero
  9346. --- items, since there are no real line breaks.
  9347. ---
  9348. --- When substitute() is used recursively only the submatches in
  9349. --- the current (deepest) call can be obtained.
  9350. ---
  9351. --- Returns an empty string or list on error.
  9352. ---
  9353. --- Examples: >vim
  9354. --- s/\d\+/\=submatch(0) + 1/
  9355. --- echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
  9356. --- <This finds the first number in the line and adds one to it.
  9357. --- A line break is included as a newline character.
  9358. ---
  9359. --- @param nr integer
  9360. --- @param list? nil
  9361. --- @return string
  9362. function vim.fn.submatch(nr, list) end
  9363. --- @param nr integer
  9364. --- @param list integer
  9365. --- @return string|string[]
  9366. function vim.fn.submatch(nr, list) end
  9367. --- The result is a String, which is a copy of {string}, in which
  9368. --- the first match of {pat} is replaced with {sub}.
  9369. --- When {flags} is "g", all matches of {pat} in {string} are
  9370. --- replaced. Otherwise {flags} should be "".
  9371. ---
  9372. --- This works like the ":substitute" command (without any flags).
  9373. --- But the matching with {pat} is always done like the 'magic'
  9374. --- option is set and 'cpoptions' is empty (to make scripts
  9375. --- portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
  9376. --- if you want to ignore or match case and ignore 'ignorecase'.
  9377. --- 'smartcase' is not used. See |string-match| for how {pat} is
  9378. --- used.
  9379. ---
  9380. --- A "~" in {sub} is not replaced with the previous {sub}.
  9381. --- Note that some codes in {sub} have a special meaning
  9382. --- |sub-replace-special|. For example, to replace something with
  9383. --- "\n" (two characters), use "\\\\n" or '\\n'.
  9384. ---
  9385. --- When {pat} does not match in {string}, {string} is returned
  9386. --- unmodified.
  9387. ---
  9388. --- Example: >vim
  9389. --- let &path = substitute(&path, ",\\=[^,]*$", "", "")
  9390. --- <This removes the last component of the 'path' option. >vim
  9391. --- echo substitute("testing", ".*", "\\U\\0", "")
  9392. --- <results in "TESTING".
  9393. ---
  9394. --- When {sub} starts with "\=", the remainder is interpreted as
  9395. --- an expression. See |sub-replace-expression|. Example: >vim
  9396. --- echo substitute(s, '%\(\x\x\)',
  9397. --- \ '\=nr2char("0x" .. submatch(1))', 'g')
  9398. ---
  9399. --- <When {sub} is a Funcref that function is called, with one
  9400. --- optional argument. Example: >vim
  9401. --- echo substitute(s, '%\(\x\x\)', SubNr, 'g')
  9402. --- <The optional argument is a list which contains the whole
  9403. --- matched string and up to nine submatches, like what
  9404. --- |submatch()| returns. Example: >vim
  9405. --- echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
  9406. ---
  9407. --- <Returns an empty string on error.
  9408. ---
  9409. --- @param string string
  9410. --- @param pat string
  9411. --- @param sub string
  9412. --- @param flags string
  9413. --- @return string
  9414. function vim.fn.substitute(string, pat, sub, flags) end
  9415. --- Returns a list of swap file names, like what "vim -r" shows.
  9416. --- See the |-r| command argument. The 'directory' option is used
  9417. --- for the directories to inspect. If you only want to get a
  9418. --- list of swap files in the current directory then temporarily
  9419. --- set 'directory' to a dot: >vim
  9420. --- let save_dir = &directory
  9421. --- let &directory = '.'
  9422. --- let swapfiles = swapfilelist()
  9423. --- let &directory = save_dir
  9424. ---
  9425. --- @return string[]
  9426. function vim.fn.swapfilelist() end
  9427. --- The result is a dictionary, which holds information about the
  9428. --- swapfile {fname}. The available fields are:
  9429. --- version Vim version
  9430. --- user user name
  9431. --- host host name
  9432. --- fname original file name
  9433. --- pid PID of the Nvim process that created the swap
  9434. --- file, or zero if not running.
  9435. --- mtime last modification time in seconds
  9436. --- inode Optional: INODE number of the file
  9437. --- dirty 1 if file was modified, 0 if not
  9438. --- In case of failure an "error" item is added with the reason:
  9439. --- Cannot open file: file not found or in accessible
  9440. --- Cannot read file: cannot read first block
  9441. --- Not a swap file: does not contain correct block ID
  9442. --- Magic number mismatch: Info in first block is invalid
  9443. ---
  9444. --- @param fname string
  9445. --- @return any
  9446. function vim.fn.swapinfo(fname) end
  9447. --- The result is the swap file path of the buffer {buf}.
  9448. --- For the use of {buf}, see |bufname()| above.
  9449. --- If buffer {buf} is the current buffer, the result is equal to
  9450. --- |:swapname| (unless there is no swap file).
  9451. --- If buffer {buf} has no swap file, returns an empty string.
  9452. ---
  9453. --- @param buf integer|string
  9454. --- @return string
  9455. function vim.fn.swapname(buf) end
  9456. --- The result is a Number, which is the syntax ID at the position
  9457. --- {lnum} and {col} in the current window.
  9458. --- The syntax ID can be used with |synIDattr()| and
  9459. --- |synIDtrans()| to obtain syntax information about text.
  9460. ---
  9461. --- {col} is 1 for the leftmost column, {lnum} is 1 for the first
  9462. --- line. 'synmaxcol' applies, in a longer line zero is returned.
  9463. --- Note that when the position is after the last character,
  9464. --- that's where the cursor can be in Insert mode, synID() returns
  9465. --- zero. {lnum} is used like with |getline()|.
  9466. ---
  9467. --- When {trans} is |TRUE|, transparent items are reduced to the
  9468. --- item that they reveal. This is useful when wanting to know
  9469. --- the effective color. When {trans} is |FALSE|, the transparent
  9470. --- item is returned. This is useful when wanting to know which
  9471. --- syntax item is effective (e.g. inside parens).
  9472. --- Warning: This function can be very slow. Best speed is
  9473. --- obtained by going through the file in forward direction.
  9474. ---
  9475. --- Returns zero on error.
  9476. ---
  9477. --- Example (echoes the name of the syntax item under the cursor): >vim
  9478. --- echo synIDattr(synID(line("."), col("."), 1), "name")
  9479. --- <
  9480. ---
  9481. --- @param lnum integer
  9482. --- @param col integer
  9483. --- @param trans 0|1
  9484. --- @return integer
  9485. function vim.fn.synID(lnum, col, trans) end
  9486. --- The result is a String, which is the {what} attribute of
  9487. --- syntax ID {synID}. This can be used to obtain information
  9488. --- about a syntax item.
  9489. --- {mode} can be "gui" or "cterm", to get the attributes
  9490. --- for that mode. When {mode} is omitted, or an invalid value is
  9491. --- used, the attributes for the currently active highlighting are
  9492. --- used (GUI or cterm).
  9493. --- Use synIDtrans() to follow linked highlight groups.
  9494. --- {what} result
  9495. --- "name" the name of the syntax item
  9496. --- "fg" foreground color (GUI: color name used to set
  9497. --- the color, cterm: color number as a string,
  9498. --- term: empty string)
  9499. --- "bg" background color (as with "fg")
  9500. --- "font" font name (only available in the GUI)
  9501. --- |highlight-font|
  9502. --- "sp" special color (as with "fg") |guisp|
  9503. --- "fg#" like "fg", but for the GUI and the GUI is
  9504. --- running the name in "#RRGGBB" form
  9505. --- "bg#" like "fg#" for "bg"
  9506. --- "sp#" like "fg#" for "sp"
  9507. --- "bold" "1" if bold
  9508. --- "italic" "1" if italic
  9509. --- "reverse" "1" if reverse
  9510. --- "inverse" "1" if inverse (= reverse)
  9511. --- "standout" "1" if standout
  9512. --- "underline" "1" if underlined
  9513. --- "undercurl" "1" if undercurled
  9514. --- "underdouble" "1" if double underlined
  9515. --- "underdotted" "1" if dotted underlined
  9516. --- "underdashed" "1" if dashed underlined
  9517. --- "strikethrough" "1" if struckthrough
  9518. --- "altfont" "1" if alternative font
  9519. --- "nocombine" "1" if nocombine
  9520. ---
  9521. --- Returns an empty string on error.
  9522. ---
  9523. --- Example (echoes the color of the syntax item under the
  9524. --- cursor): >vim
  9525. --- echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  9526. --- <
  9527. --- Can also be used as a |method|: >vim
  9528. --- echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  9529. --- <
  9530. ---
  9531. --- @param synID integer
  9532. --- @param what string
  9533. --- @param mode? string
  9534. --- @return string
  9535. function vim.fn.synIDattr(synID, what, mode) end
  9536. --- The result is a Number, which is the translated syntax ID of
  9537. --- {synID}. This is the syntax group ID of what is being used to
  9538. --- highlight the character. Highlight links given with
  9539. --- ":highlight link" are followed.
  9540. ---
  9541. --- Returns zero on error.
  9542. ---
  9543. --- @param synID integer
  9544. --- @return integer
  9545. function vim.fn.synIDtrans(synID) end
  9546. --- The result is a |List| with currently three items:
  9547. --- 1. The first item in the list is 0 if the character at the
  9548. --- position {lnum} and {col} is not part of a concealable
  9549. --- region, 1 if it is. {lnum} is used like with |getline()|.
  9550. --- 2. The second item in the list is a string. If the first item
  9551. --- is 1, the second item contains the text which will be
  9552. --- displayed in place of the concealed text, depending on the
  9553. --- current setting of 'conceallevel' and 'listchars'.
  9554. --- 3. The third and final item in the list is a number
  9555. --- representing the specific syntax region matched in the
  9556. --- line. When the character is not concealed the value is
  9557. --- zero. This allows detection of the beginning of a new
  9558. --- concealable region if there are two consecutive regions
  9559. --- with the same replacement character. For an example, if
  9560. --- the text is "123456" and both "23" and "45" are concealed
  9561. --- and replaced by the character "X", then:
  9562. --- call returns ~
  9563. --- synconcealed(lnum, 1) [0, '', 0]
  9564. --- synconcealed(lnum, 2) [1, 'X', 1]
  9565. --- synconcealed(lnum, 3) [1, 'X', 1]
  9566. --- synconcealed(lnum, 4) [1, 'X', 2]
  9567. --- synconcealed(lnum, 5) [1, 'X', 2]
  9568. --- synconcealed(lnum, 6) [0, '', 0]
  9569. ---
  9570. --- Note: Doesn't consider |matchadd()| highlighting items,
  9571. --- since syntax and matching highlighting are two different
  9572. --- mechanisms |syntax-vs-match|.
  9573. ---
  9574. --- @param lnum integer
  9575. --- @param col integer
  9576. --- @return [integer, string, integer]
  9577. function vim.fn.synconcealed(lnum, col) end
  9578. --- Return a |List|, which is the stack of syntax items at the
  9579. --- position {lnum} and {col} in the current window. {lnum} is
  9580. --- used like with |getline()|. Each item in the List is an ID
  9581. --- like what |synID()| returns.
  9582. --- The first item in the List is the outer region, following are
  9583. --- items contained in that one. The last one is what |synID()|
  9584. --- returns, unless not the whole item is highlighted or it is a
  9585. --- transparent item.
  9586. --- This function is useful for debugging a syntax file.
  9587. --- Example that shows the syntax stack under the cursor: >vim
  9588. --- for id in synstack(line("."), col("."))
  9589. --- echo synIDattr(id, "name")
  9590. --- endfor
  9591. --- <When the position specified with {lnum} and {col} is invalid
  9592. --- an empty list is returned. The position just after the last
  9593. --- character in a line and the first column in an empty line are
  9594. --- valid positions.
  9595. ---
  9596. --- @param lnum integer
  9597. --- @param col integer
  9598. --- @return integer[]
  9599. function vim.fn.synstack(lnum, col) end
  9600. --- Note: Prefer |vim.system()| in Lua.
  9601. ---
  9602. --- Gets the output of {cmd} as a |string| (|systemlist()| returns
  9603. --- a |List|) and sets |v:shell_error| to the error code.
  9604. --- {cmd} is treated as in |jobstart()|:
  9605. --- If {cmd} is a List it runs directly (no 'shell').
  9606. --- If {cmd} is a String it runs in the 'shell', like this: >vim
  9607. --- call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  9608. ---
  9609. --- <Not to be used for interactive commands.
  9610. ---
  9611. --- Result is a String, filtered to avoid platform-specific quirks:
  9612. --- - <CR><NL> is replaced with <NL>
  9613. --- - NUL characters are replaced with SOH (0x01)
  9614. ---
  9615. --- Example: >vim
  9616. --- echo system(['ls', expand('%:h')])
  9617. ---
  9618. --- <If {input} is a string it is written to a pipe and passed as
  9619. --- stdin to the command. The string is written as-is, line
  9620. --- separators are not changed.
  9621. --- If {input} is a |List| it is written to the pipe as
  9622. --- |writefile()| does with {binary} set to "b" (i.e. with
  9623. --- a newline between each list item, and newlines inside list
  9624. --- items converted to NULs).
  9625. --- When {input} is given and is a valid buffer id, the content of
  9626. --- the buffer is written to the file line by line, each line
  9627. --- terminated by NL (and NUL where the text has NL).
  9628. --- *E5677*
  9629. --- Note: system() cannot write to or read from backgrounded ("&")
  9630. --- shell commands, e.g.: >vim
  9631. --- echo system("cat - &", "foo")
  9632. --- <which is equivalent to: >
  9633. --- $ echo foo | bash -c 'cat - &'
  9634. --- <The pipes are disconnected (unless overridden by shell
  9635. --- redirection syntax) before input can reach it. Use
  9636. --- |jobstart()| instead.
  9637. ---
  9638. --- Note: Use |shellescape()| or |::S| with |expand()| or
  9639. --- |fnamemodify()| to escape special characters in a command
  9640. --- argument. 'shellquote' and 'shellxquote' must be properly
  9641. --- configured. Example: >vim
  9642. --- echo system('ls '..shellescape(expand('%:h')))
  9643. --- echo system('ls '..expand('%:h:S'))
  9644. ---
  9645. --- <Unlike ":!cmd" there is no automatic check for changed files.
  9646. --- Use |:checktime| to force a check.
  9647. ---
  9648. --- @param cmd string|string[]
  9649. --- @param input? string|string[]|integer
  9650. --- @return string
  9651. function vim.fn.system(cmd, input) end
  9652. --- Same as |system()|, but returns a |List| with lines (parts of
  9653. --- output separated by NL) with NULs transformed into NLs. Output
  9654. --- is the same as |readfile()| will output with {binary} argument
  9655. --- set to "b", except that a final newline is not preserved,
  9656. --- unless {keepempty} is non-zero.
  9657. --- Note that on MS-Windows you may get trailing CR characters.
  9658. ---
  9659. --- To see the difference between "echo hello" and "echo -n hello"
  9660. --- use |system()| and |split()|: >vim
  9661. --- echo split(system('echo hello'), '\n', 1)
  9662. --- <
  9663. --- Returns an empty string on error.
  9664. ---
  9665. --- @param cmd string|string[]
  9666. --- @param input? string|string[]|integer
  9667. --- @param keepempty? integer
  9668. --- @return string[]
  9669. function vim.fn.systemlist(cmd, input, keepempty) end
  9670. --- The result is a |List|, where each item is the number of the
  9671. --- buffer associated with each window in the current tab page.
  9672. --- {arg} specifies the number of the tab page to be used. When
  9673. --- omitted the current tab page is used.
  9674. --- When {arg} is invalid the number zero is returned.
  9675. --- To get a list of all buffers in all tabs use this: >vim
  9676. --- let buflist = []
  9677. --- for i in range(tabpagenr('$'))
  9678. --- call extend(buflist, tabpagebuflist(i + 1))
  9679. --- endfor
  9680. --- <Note that a buffer may appear in more than one window.
  9681. ---
  9682. --- @param arg? integer
  9683. --- @return any
  9684. function vim.fn.tabpagebuflist(arg) end
  9685. --- The result is a Number, which is the number of the current
  9686. --- tab page. The first tab page has number 1.
  9687. ---
  9688. --- The optional argument {arg} supports the following values:
  9689. --- $ the number of the last tab page (the tab page
  9690. --- count).
  9691. --- # the number of the last accessed tab page
  9692. --- (where |g<Tab>| goes to). If there is no
  9693. --- previous tab page, 0 is returned.
  9694. --- The number can be used with the |:tab| command.
  9695. ---
  9696. --- Returns zero on error.
  9697. ---
  9698. --- @param arg? '$'|'#'
  9699. --- @return integer
  9700. function vim.fn.tabpagenr(arg) end
  9701. --- Like |winnr()| but for tab page {tabarg}.
  9702. --- {tabarg} specifies the number of tab page to be used.
  9703. --- {arg} is used like with |winnr()|:
  9704. --- - When omitted the current window number is returned. This is
  9705. --- the window which will be used when going to this tab page.
  9706. --- - When "$" the number of windows is returned.
  9707. --- - When "#" the previous window nr is returned.
  9708. --- Useful examples: >vim
  9709. --- tabpagewinnr(1) " current window of tab page 1
  9710. --- tabpagewinnr(4, '$') " number of windows in tab page 4
  9711. --- <When {tabarg} is invalid zero is returned.
  9712. ---
  9713. --- @param tabarg integer
  9714. --- @param arg? '$'|'#'
  9715. --- @return integer
  9716. function vim.fn.tabpagewinnr(tabarg, arg) end
  9717. --- Returns a |List| with the file names used to search for tags
  9718. --- for the current buffer. This is the 'tags' option expanded.
  9719. ---
  9720. --- @return string[]
  9721. function vim.fn.tagfiles() end
  9722. --- Returns a |List| of tags matching the regular expression {expr}.
  9723. ---
  9724. --- If {filename} is passed it is used to prioritize the results
  9725. --- in the same way that |:tselect| does. See |tag-priority|.
  9726. --- {filename} should be the full path of the file.
  9727. ---
  9728. --- Each list item is a dictionary with at least the following
  9729. --- entries:
  9730. --- name Name of the tag.
  9731. --- filename Name of the file where the tag is
  9732. --- defined. It is either relative to the
  9733. --- current directory or a full path.
  9734. --- cmd Ex command used to locate the tag in
  9735. --- the file.
  9736. --- kind Type of the tag. The value for this
  9737. --- entry depends on the language specific
  9738. --- kind values. Only available when
  9739. --- using a tags file generated by
  9740. --- Universal/Exuberant ctags or hdrtag.
  9741. --- static A file specific tag. Refer to
  9742. --- |static-tag| for more information.
  9743. --- More entries may be present, depending on the content of the
  9744. --- tags file: access, implementation, inherits and signature.
  9745. --- Refer to the ctags documentation for information about these
  9746. --- fields. For C code the fields "struct", "class" and "enum"
  9747. --- may appear, they give the name of the entity the tag is
  9748. --- contained in.
  9749. ---
  9750. --- The ex-command "cmd" can be either an ex search pattern, a
  9751. --- line number or a line number followed by a byte number.
  9752. ---
  9753. --- If there are no matching tags, then an empty list is returned.
  9754. ---
  9755. --- To get an exact tag match, the anchors '^' and '$' should be
  9756. --- used in {expr}. This also make the function work faster.
  9757. --- Refer to |tag-regexp| for more information about the tag
  9758. --- search regular expression pattern.
  9759. ---
  9760. --- Refer to |'tags'| for information about how the tags file is
  9761. --- located by Vim. Refer to |tags-file-format| for the format of
  9762. --- the tags file generated by the different ctags tools.
  9763. ---
  9764. --- @param expr any
  9765. --- @param filename? string
  9766. --- @return any
  9767. function vim.fn.taglist(expr, filename) end
  9768. --- Return the tangent of {expr}, measured in radians, as a |Float|
  9769. --- in the range [-inf, inf].
  9770. --- {expr} must evaluate to a |Float| or a |Number|.
  9771. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9772. --- Examples: >vim
  9773. --- echo tan(10)
  9774. --- < 0.648361 >vim
  9775. --- echo tan(-4.01)
  9776. --- < -1.181502
  9777. ---
  9778. --- @param expr number
  9779. --- @return number
  9780. function vim.fn.tan(expr) end
  9781. --- Return the hyperbolic tangent of {expr} as a |Float| in the
  9782. --- range [-1, 1].
  9783. --- {expr} must evaluate to a |Float| or a |Number|.
  9784. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9785. --- Examples: >vim
  9786. --- echo tanh(0.5)
  9787. --- < 0.462117 >vim
  9788. --- echo tanh(-1)
  9789. --- < -0.761594
  9790. ---
  9791. --- @param expr number
  9792. --- @return number
  9793. function vim.fn.tanh(expr) end
  9794. --- Generates a (non-existent) filename located in the Nvim root
  9795. --- |tempdir|. Scripts can use the filename as a temporary file.
  9796. --- Example: >vim
  9797. --- let tmpfile = tempname()
  9798. --- exe "redir > " .. tmpfile
  9799. --- <
  9800. ---
  9801. --- @return string
  9802. function vim.fn.tempname() end
  9803. --- @deprecated
  9804. --- Use |jobstart()| with `{term: v:true}` instead.
  9805. ---
  9806. --- @param cmd string|string[]
  9807. --- @param opts? table
  9808. --- @return integer
  9809. function vim.fn.termopen(cmd, opts) end
  9810. --- Return a list with information about timers.
  9811. --- When {id} is given only information about this timer is
  9812. --- returned. When timer {id} does not exist an empty list is
  9813. --- returned.
  9814. --- When {id} is omitted information about all timers is returned.
  9815. ---
  9816. --- For each timer the information is stored in a |Dictionary| with
  9817. --- these items:
  9818. --- "id" the timer ID
  9819. --- "time" time the timer was started with
  9820. --- "repeat" number of times the timer will still fire;
  9821. --- -1 means forever
  9822. --- "callback" the callback
  9823. ---
  9824. --- @param id? integer
  9825. --- @return any
  9826. function vim.fn.timer_info(id) end
  9827. --- Pause or unpause a timer. A paused timer does not invoke its
  9828. --- callback when its time expires. Unpausing a timer may cause
  9829. --- the callback to be invoked almost immediately if enough time
  9830. --- has passed.
  9831. ---
  9832. --- Pausing a timer is useful to avoid the callback to be called
  9833. --- for a short time.
  9834. ---
  9835. --- If {paused} evaluates to a non-zero Number or a non-empty
  9836. --- String, then the timer is paused, otherwise it is unpaused.
  9837. --- See |non-zero-arg|.
  9838. ---
  9839. --- @param timer integer
  9840. --- @param paused boolean
  9841. --- @return any
  9842. function vim.fn.timer_pause(timer, paused) end
  9843. --- Create a timer and return the timer ID.
  9844. ---
  9845. --- {time} is the waiting time in milliseconds. This is the
  9846. --- minimum time before invoking the callback. When the system is
  9847. --- busy or Vim is not waiting for input the time will be longer.
  9848. --- Zero can be used to execute the callback when Vim is back in
  9849. --- the main loop.
  9850. ---
  9851. --- {callback} is the function to call. It can be the name of a
  9852. --- function or a |Funcref|. It is called with one argument, which
  9853. --- is the timer ID. The callback is only invoked when Vim is
  9854. --- waiting for input.
  9855. ---
  9856. --- {options} is a dictionary. Supported entries:
  9857. --- "repeat" Number of times to repeat the callback.
  9858. --- -1 means forever. Default is 1.
  9859. --- If the timer causes an error three times in a
  9860. --- row the repeat is cancelled.
  9861. ---
  9862. --- Returns -1 on error.
  9863. ---
  9864. --- Example: >vim
  9865. --- func MyHandler(timer)
  9866. --- echo 'Handler called'
  9867. --- endfunc
  9868. --- let timer = timer_start(500, 'MyHandler',
  9869. --- \ {'repeat': 3})
  9870. --- <This invokes MyHandler() three times at 500 msec intervals.
  9871. ---
  9872. --- @param time number
  9873. --- @param callback string|function
  9874. --- @param options? table
  9875. --- @return any
  9876. function vim.fn.timer_start(time, callback, options) end
  9877. --- Stop a timer. The timer callback will no longer be invoked.
  9878. --- {timer} is an ID returned by timer_start(), thus it must be a
  9879. --- Number. If {timer} does not exist there is no error.
  9880. ---
  9881. --- @param timer integer
  9882. --- @return any
  9883. function vim.fn.timer_stop(timer) end
  9884. --- Stop all timers. The timer callbacks will no longer be
  9885. --- invoked. Useful if some timers is misbehaving. If there are
  9886. --- no timers there is no error.
  9887. ---
  9888. --- @return any
  9889. function vim.fn.timer_stopall() end
  9890. --- The result is a copy of the String given, with all uppercase
  9891. --- characters turned into lowercase (just like applying |gu| to
  9892. --- the string). Returns an empty string on error.
  9893. ---
  9894. --- @param expr string
  9895. --- @return string
  9896. function vim.fn.tolower(expr) end
  9897. --- The result is a copy of the String given, with all lowercase
  9898. --- characters turned into uppercase (just like applying |gU| to
  9899. --- the string). Returns an empty string on error.
  9900. ---
  9901. --- @param expr string
  9902. --- @return string
  9903. function vim.fn.toupper(expr) end
  9904. --- The result is a copy of the {src} string with all characters
  9905. --- which appear in {fromstr} replaced by the character in that
  9906. --- position in the {tostr} string. Thus the first character in
  9907. --- {fromstr} is translated into the first character in {tostr}
  9908. --- and so on. Exactly like the unix "tr" command.
  9909. --- This code also deals with multibyte characters properly.
  9910. ---
  9911. --- Returns an empty string on error.
  9912. ---
  9913. --- Examples: >vim
  9914. --- echo tr("hello there", "ht", "HT")
  9915. --- <returns "Hello THere" >vim
  9916. --- echo tr("<blob>", "<>", "{}")
  9917. --- <returns "{blob}"
  9918. ---
  9919. --- @param src string
  9920. --- @param fromstr string
  9921. --- @param tostr string
  9922. --- @return string
  9923. function vim.fn.tr(src, fromstr, tostr) end
  9924. --- Return {text} as a String where any character in {mask} is
  9925. --- removed from the beginning and/or end of {text}.
  9926. ---
  9927. --- If {mask} is not given, or is an empty string, {mask} is all
  9928. --- characters up to 0x20, which includes Tab, space, NL and CR,
  9929. --- plus the non-breaking space character 0xa0.
  9930. ---
  9931. --- The optional {dir} argument specifies where to remove the
  9932. --- characters:
  9933. --- 0 remove from the beginning and end of {text}
  9934. --- 1 remove only at the beginning of {text}
  9935. --- 2 remove only at the end of {text}
  9936. --- When omitted both ends are trimmed.
  9937. ---
  9938. --- This function deals with multibyte characters properly.
  9939. --- Returns an empty string on error.
  9940. ---
  9941. --- Examples: >vim
  9942. --- echo trim(" some text ")
  9943. --- <returns "some text" >vim
  9944. --- echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  9945. --- <returns "RESERVE_TAIL" >vim
  9946. --- echo trim("rm<Xrm<>X>rrm", "rm<>")
  9947. --- <returns "Xrm<>X" (characters in the middle are not removed) >vim
  9948. --- echo trim(" vim ", " ", 2)
  9949. --- <returns " vim"
  9950. ---
  9951. --- @param text string
  9952. --- @param mask? string
  9953. --- @param dir? 0|1|2
  9954. --- @return string
  9955. function vim.fn.trim(text, mask, dir) end
  9956. --- Return the largest integral value with magnitude less than or
  9957. --- equal to {expr} as a |Float| (truncate towards zero).
  9958. --- {expr} must evaluate to a |Float| or a |Number|.
  9959. --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9960. --- Examples: >vim
  9961. --- echo trunc(1.456)
  9962. --- < 1.0 >vim
  9963. --- echo trunc(-5.456)
  9964. --- < -5.0 >vim
  9965. --- echo trunc(4.0)
  9966. --- < 4.0
  9967. ---
  9968. --- @param expr number
  9969. --- @return integer
  9970. function vim.fn.trunc(expr) end
  9971. --- The result is a Number representing the type of {expr}.
  9972. --- Instead of using the number directly, it is better to use the
  9973. --- v:t_ variable that has the value:
  9974. --- Number: 0 |v:t_number|
  9975. --- String: 1 |v:t_string|
  9976. --- Funcref: 2 |v:t_func|
  9977. --- List: 3 |v:t_list|
  9978. --- Dictionary: 4 |v:t_dict|
  9979. --- Float: 5 |v:t_float|
  9980. --- Boolean: 6 |v:t_bool| (|v:false| and |v:true|)
  9981. --- Null: 7 (|v:null|)
  9982. --- Blob: 10 |v:t_blob|
  9983. --- For backward compatibility, this method can be used: >vim
  9984. --- if type(myvar) == type(0) | endif
  9985. --- if type(myvar) == type("") | endif
  9986. --- if type(myvar) == type(function("tr")) | endif
  9987. --- if type(myvar) == type([]) | endif
  9988. --- if type(myvar) == type({}) | endif
  9989. --- if type(myvar) == type(0.0) | endif
  9990. --- if type(myvar) == type(v:true) | endif
  9991. --- <In place of checking for |v:null| type it is better to check
  9992. --- for |v:null| directly as it is the only value of this type: >vim
  9993. --- if myvar is v:null | endif
  9994. --- <To check if the v:t_ variables exist use this: >vim
  9995. --- if exists('v:t_number') | endif
  9996. --- <
  9997. ---
  9998. --- @param expr any
  9999. --- @return integer
  10000. function vim.fn.type(expr) end
  10001. --- Return the name of the undo file that would be used for a file
  10002. --- with name {name} when writing. This uses the 'undodir'
  10003. --- option, finding directories that exist. It does not check if
  10004. --- the undo file exists.
  10005. --- {name} is always expanded to the full path, since that is what
  10006. --- is used internally.
  10007. --- If {name} is empty undofile() returns an empty string, since a
  10008. --- buffer without a file name will not write an undo file.
  10009. --- Useful in combination with |:wundo| and |:rundo|.
  10010. ---
  10011. --- @param name string
  10012. --- @return string
  10013. function vim.fn.undofile(name) end
  10014. --- Return the current state of the undo tree for the current
  10015. --- buffer, or for a specific buffer if {buf} is given. The
  10016. --- result is a dictionary with the following items:
  10017. --- "seq_last" The highest undo sequence number used.
  10018. --- "seq_cur" The sequence number of the current position in
  10019. --- the undo tree. This differs from "seq_last"
  10020. --- when some changes were undone.
  10021. --- "time_cur" Time last used for |:earlier| and related
  10022. --- commands. Use |strftime()| to convert to
  10023. --- something readable.
  10024. --- "save_last" Number of the last file write. Zero when no
  10025. --- write yet.
  10026. --- "save_cur" Number of the current position in the undo
  10027. --- tree.
  10028. --- "synced" Non-zero when the last undo block was synced.
  10029. --- This happens when waiting from input from the
  10030. --- user. See |undo-blocks|.
  10031. --- "entries" A list of dictionaries with information about
  10032. --- undo blocks.
  10033. ---
  10034. --- The first item in the "entries" list is the oldest undo item.
  10035. --- Each List item is a |Dictionary| with these items:
  10036. --- "seq" Undo sequence number. Same as what appears in
  10037. --- |:undolist|.
  10038. --- "time" Timestamp when the change happened. Use
  10039. --- |strftime()| to convert to something readable.
  10040. --- "newhead" Only appears in the item that is the last one
  10041. --- that was added. This marks the last change
  10042. --- and where further changes will be added.
  10043. --- "curhead" Only appears in the item that is the last one
  10044. --- that was undone. This marks the current
  10045. --- position in the undo tree, the block that will
  10046. --- be used by a redo command. When nothing was
  10047. --- undone after the last change this item will
  10048. --- not appear anywhere.
  10049. --- "save" Only appears on the last block before a file
  10050. --- write. The number is the write count. The
  10051. --- first write has number 1, the last one the
  10052. --- "save_last" mentioned above.
  10053. --- "alt" Alternate entry. This is again a List of undo
  10054. --- blocks. Each item may again have an "alt"
  10055. --- item.
  10056. ---
  10057. --- @param buf? integer|string
  10058. --- @return vim.fn.undotree.ret
  10059. function vim.fn.undotree(buf) end
  10060. --- Remove second and succeeding copies of repeated adjacent
  10061. --- {list} items in-place. Returns {list}. If you want a list
  10062. --- to remain unmodified make a copy first: >vim
  10063. --- let newlist = uniq(copy(mylist))
  10064. --- <The default compare function uses the string representation of
  10065. --- each item. For the use of {func} and {dict} see |sort()|.
  10066. ---
  10067. --- Returns zero if {list} is not a |List|.
  10068. ---
  10069. --- @param list any
  10070. --- @param func? any
  10071. --- @param dict? any
  10072. --- @return any[]|0
  10073. function vim.fn.uniq(list, func, dict) end
  10074. --- Same as |charidx()| but returns the UTF-16 code unit index of
  10075. --- the byte at {idx} in {string} (after converting it to UTF-16).
  10076. ---
  10077. --- When {charidx} is present and TRUE, {idx} is used as the
  10078. --- character index in the String {string} instead of as the byte
  10079. --- index.
  10080. --- An {idx} in the middle of a UTF-8 sequence is rounded
  10081. --- downwards to the beginning of that sequence.
  10082. ---
  10083. --- Returns -1 if the arguments are invalid or if there are less
  10084. --- than {idx} bytes in {string}. If there are exactly {idx} bytes
  10085. --- the length of the string in UTF-16 code units is returned.
  10086. ---
  10087. --- See |byteidx()| and |byteidxcomp()| for getting the byte index
  10088. --- from the UTF-16 index and |charidx()| for getting the
  10089. --- character index from the UTF-16 index.
  10090. --- Refer to |string-offset-encoding| for more information.
  10091. --- Examples: >vim
  10092. --- echo utf16idx('a😊😊', 3) " returns 2
  10093. --- echo utf16idx('a😊😊', 7) " returns 4
  10094. --- echo utf16idx('a😊😊', 1, 0, 1) " returns 2
  10095. --- echo utf16idx('a😊😊', 2, 0, 1) " returns 4
  10096. --- echo utf16idx('aą́c', 6) " returns 2
  10097. --- echo utf16idx('aą́c', 6, 1) " returns 4
  10098. --- echo utf16idx('a😊😊', 9) " returns -1
  10099. --- <
  10100. ---
  10101. --- @param string string
  10102. --- @param idx integer
  10103. --- @param countcc? boolean
  10104. --- @param charidx? boolean
  10105. --- @return integer
  10106. function vim.fn.utf16idx(string, idx, countcc, charidx) end
  10107. --- Return a |List| with all the values of {dict}. The |List| is
  10108. --- in arbitrary order. Also see |items()| and |keys()|.
  10109. --- Returns zero if {dict} is not a |Dict|.
  10110. ---
  10111. --- @param dict any
  10112. --- @return any
  10113. function vim.fn.values(dict) end
  10114. --- The result is a Number, which is the screen column of the file
  10115. --- position given with {expr}. That is, the last screen position
  10116. --- occupied by the character at that position, when the screen
  10117. --- would be of unlimited width. When there is a <Tab> at the
  10118. --- position, the returned Number will be the column at the end of
  10119. --- the <Tab>. For example, for a <Tab> in column 1, with 'ts'
  10120. --- set to 8, it returns 8. |conceal| is ignored.
  10121. --- For the byte position use |col()|.
  10122. ---
  10123. --- For the use of {expr} see |getpos()| and |col()|.
  10124. --- When {expr} is "$", it means the end of the cursor line, so
  10125. --- the result is the number of cells in the cursor line plus one.
  10126. ---
  10127. --- When 'virtualedit' is used {expr} can be [lnum, col, off],
  10128. --- where "off" is the offset in screen columns from the start of
  10129. --- the character. E.g., a position within a <Tab> or after the
  10130. --- last character. When "off" is omitted zero is used. When
  10131. --- Virtual editing is active in the current mode, a position
  10132. --- beyond the end of the line can be returned. Also see
  10133. --- |'virtualedit'|
  10134. ---
  10135. --- If {list} is present and non-zero then virtcol() returns a
  10136. --- List with the first and last screen position occupied by the
  10137. --- character.
  10138. ---
  10139. --- With the optional {winid} argument the values are obtained for
  10140. --- that window instead of the current window.
  10141. ---
  10142. --- Note that only marks in the current file can be used.
  10143. --- Examples: >vim
  10144. --- " With text "foo^Lbar" and cursor on the "^L":
  10145. ---
  10146. --- echo virtcol(".") " returns 5
  10147. --- echo virtcol(".", 1) " returns [4, 5]
  10148. --- echo virtcol("$") " returns 9
  10149. ---
  10150. --- " With text " there", with 't at 'h':
  10151. ---
  10152. --- echo virtcol("'t") " returns 6
  10153. --- <
  10154. --- The first column is 1. 0 or [0, 0] is returned for an error.
  10155. ---
  10156. --- A more advanced example that echoes the maximum length of
  10157. --- all lines: >vim
  10158. --- echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  10159. --- <
  10160. ---
  10161. --- @param expr string|any[]
  10162. --- @param list? boolean
  10163. --- @param winid? integer
  10164. --- @return any
  10165. function vim.fn.virtcol(expr, list, winid) end
  10166. --- The result is a Number, which is the byte index of the
  10167. --- character in window {winid} at buffer line {lnum} and virtual
  10168. --- column {col}.
  10169. ---
  10170. --- If buffer line {lnum} is an empty line, 0 is returned.
  10171. ---
  10172. --- If {col} is greater than the last virtual column in line
  10173. --- {lnum}, then the byte index of the character at the last
  10174. --- virtual column is returned.
  10175. ---
  10176. --- For a multi-byte character, the column number of the first
  10177. --- byte in the character is returned.
  10178. ---
  10179. --- The {winid} argument can be the window number or the
  10180. --- |window-ID|. If this is zero, then the current window is used.
  10181. ---
  10182. --- Returns -1 if the window {winid} doesn't exist or the buffer
  10183. --- line {lnum} or virtual column {col} is invalid.
  10184. ---
  10185. --- See also |screenpos()|, |virtcol()| and |col()|.
  10186. ---
  10187. --- @param winid integer
  10188. --- @param lnum integer
  10189. --- @param col integer
  10190. --- @return integer
  10191. function vim.fn.virtcol2col(winid, lnum, col) end
  10192. --- The result is a String, which describes the last Visual mode
  10193. --- used in the current buffer. Initially it returns an empty
  10194. --- string, but once Visual mode has been used, it returns "v",
  10195. --- "V", or "<CTRL-V>" (a single CTRL-V character) for
  10196. --- character-wise, line-wise, or block-wise Visual mode
  10197. --- respectively.
  10198. --- Example: >vim
  10199. --- exe "normal " .. visualmode()
  10200. --- <This enters the same Visual mode as before. It is also useful
  10201. --- in scripts if you wish to act differently depending on the
  10202. --- Visual mode that was used.
  10203. --- If Visual mode is active, use |mode()| to get the Visual mode
  10204. --- (e.g., in a |:vmap|).
  10205. --- If {expr} is supplied and it evaluates to a non-zero Number or
  10206. --- a non-empty String, then the Visual mode will be cleared and
  10207. --- the old value is returned. See |non-zero-arg|.
  10208. ---
  10209. --- @param expr? boolean
  10210. --- @return string
  10211. function vim.fn.visualmode(expr) end
  10212. --- Waits until {condition} evaluates to |TRUE|, where {condition}
  10213. --- is a |Funcref| or |string| containing an expression.
  10214. ---
  10215. --- {timeout} is the maximum waiting time in milliseconds, -1
  10216. --- means forever.
  10217. ---
  10218. --- Condition is evaluated on user events, internal events, and
  10219. --- every {interval} milliseconds (default: 200).
  10220. ---
  10221. --- Returns a status integer:
  10222. --- 0 if the condition was satisfied before timeout
  10223. --- -1 if the timeout was exceeded
  10224. --- -2 if the function was interrupted (by |CTRL-C|)
  10225. --- -3 if an error occurred
  10226. ---
  10227. --- @param timeout integer
  10228. --- @param condition any
  10229. --- @param interval? number
  10230. --- @return any
  10231. function vim.fn.wait(timeout, condition, interval) end
  10232. --- Returns |TRUE| when the wildmenu is active and |FALSE|
  10233. --- otherwise. See 'wildmenu' and 'wildmode'.
  10234. --- This can be used in mappings to handle the 'wildcharm' option
  10235. --- gracefully. (Makes only sense with |mapmode-c| mappings).
  10236. ---
  10237. --- For example to make <c-j> work like <down> in wildmode, use: >vim
  10238. --- cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  10239. --- <
  10240. --- (Note: this needs the 'wildcharm' option set appropriately).
  10241. ---
  10242. --- @return any
  10243. function vim.fn.wildmenumode() end
  10244. --- Like `execute()` but in the context of window {id}.
  10245. --- The window will temporarily be made the current window,
  10246. --- without triggering autocommands or changing directory. When
  10247. --- executing {command} autocommands will be triggered, this may
  10248. --- have unexpected side effects. Use `:noautocmd` if needed.
  10249. --- Example: >vim
  10250. --- call win_execute(winid, 'syntax enable')
  10251. --- <Doing the same with `setwinvar()` would not trigger
  10252. --- autocommands and not actually show syntax highlighting.
  10253. ---
  10254. --- When window {id} does not exist then no error is given and
  10255. --- an empty string is returned.
  10256. ---
  10257. --- @param id integer
  10258. --- @param command string
  10259. --- @param silent? boolean
  10260. --- @return any
  10261. function vim.fn.win_execute(id, command, silent) end
  10262. --- Returns a |List| with |window-ID|s for windows that contain
  10263. --- buffer {bufnr}. When there is none the list is empty.
  10264. ---
  10265. --- @param bufnr integer
  10266. --- @return integer[]
  10267. function vim.fn.win_findbuf(bufnr) end
  10268. --- Get the |window-ID| for the specified window.
  10269. --- When {win} is missing use the current window.
  10270. --- With {win} this is the window number. The top window has
  10271. --- number 1.
  10272. --- Without {tab} use the current tab, otherwise the tab with
  10273. --- number {tab}. The first tab has number one.
  10274. --- Return zero if the window cannot be found.
  10275. ---
  10276. --- @param win? integer
  10277. --- @param tab? integer
  10278. --- @return integer
  10279. function vim.fn.win_getid(win, tab) end
  10280. --- Return the type of the window:
  10281. --- "autocmd" autocommand window. Temporary window
  10282. --- used to execute autocommands.
  10283. --- "command" command-line window |cmdwin|
  10284. --- (empty) normal window
  10285. --- "loclist" |location-list-window|
  10286. --- "popup" floating window |api-floatwin|
  10287. --- "preview" preview window |preview-window|
  10288. --- "quickfix" |quickfix-window|
  10289. --- "unknown" window {nr} not found
  10290. ---
  10291. --- When {nr} is omitted return the type of the current window.
  10292. --- When {nr} is given return the type of this window by number or
  10293. --- |window-ID|.
  10294. ---
  10295. --- Also see the 'buftype' option.
  10296. ---
  10297. --- @param nr? integer
  10298. --- @return 'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'
  10299. function vim.fn.win_gettype(nr) end
  10300. --- Go to window with ID {expr}. This may also change the current
  10301. --- tabpage.
  10302. --- Return TRUE if successful, FALSE if the window cannot be found.
  10303. ---
  10304. --- @param expr integer
  10305. --- @return 0|1
  10306. function vim.fn.win_gotoid(expr) end
  10307. --- Return a list with the tab number and window number of window
  10308. --- with ID {expr}: [tabnr, winnr].
  10309. --- Return [0, 0] if the window cannot be found.
  10310. ---
  10311. --- @param expr integer
  10312. --- @return any
  10313. function vim.fn.win_id2tabwin(expr) end
  10314. --- Return the window number of window with ID {expr}.
  10315. --- Return 0 if the window cannot be found in the current tabpage.
  10316. ---
  10317. --- @param expr integer
  10318. --- @return integer
  10319. function vim.fn.win_id2win(expr) end
  10320. --- Move window {nr}'s vertical separator (i.e., the right border)
  10321. --- by {offset} columns, as if being dragged by the mouse. {nr}
  10322. --- can be a window number or |window-ID|. A positive {offset}
  10323. --- moves right and a negative {offset} moves left. Moving a
  10324. --- window's vertical separator will change the width of the
  10325. --- window and the width of other windows adjacent to the vertical
  10326. --- separator. The magnitude of movement may be smaller than
  10327. --- specified (e.g., as a consequence of maintaining
  10328. --- 'winminwidth'). Returns TRUE if the window can be found and
  10329. --- FALSE otherwise.
  10330. --- This will fail for the rightmost window and a full-width
  10331. --- window, since it has no separator on the right.
  10332. --- Only works for the current tab page. *E1308*
  10333. ---
  10334. --- @param nr integer
  10335. --- @param offset integer
  10336. --- @return any
  10337. function vim.fn.win_move_separator(nr, offset) end
  10338. --- Move window {nr}'s status line (i.e., the bottom border) by
  10339. --- {offset} rows, as if being dragged by the mouse. {nr} can be a
  10340. --- window number or |window-ID|. A positive {offset} moves down
  10341. --- and a negative {offset} moves up. Moving a window's status
  10342. --- line will change the height of the window and the height of
  10343. --- other windows adjacent to the status line. The magnitude of
  10344. --- movement may be smaller than specified (e.g., as a consequence
  10345. --- of maintaining 'winminheight'). Returns TRUE if the window can
  10346. --- be found and FALSE otherwise.
  10347. --- Only works for the current tab page.
  10348. ---
  10349. --- @param nr integer
  10350. --- @param offset integer
  10351. --- @return any
  10352. function vim.fn.win_move_statusline(nr, offset) end
  10353. --- Return the screen position of window {nr} as a list with two
  10354. --- numbers: [row, col]. The first window always has position
  10355. --- [1, 1], unless there is a tabline, then it is [2, 1].
  10356. --- {nr} can be the window number or the |window-ID|. Use zero
  10357. --- for the current window.
  10358. --- Returns [0, 0] if the window cannot be found.
  10359. ---
  10360. --- @param nr integer
  10361. --- @return any
  10362. function vim.fn.win_screenpos(nr) end
  10363. --- Temporarily switch to window {target}, then move window {nr}
  10364. --- to a new split adjacent to {target}.
  10365. --- Unlike commands such as |:split|, no new windows are created
  10366. --- (the |window-ID| of window {nr} is unchanged after the move).
  10367. ---
  10368. --- Both {nr} and {target} can be window numbers or |window-ID|s.
  10369. --- Both must be in the current tab page.
  10370. ---
  10371. --- Returns zero for success, non-zero for failure.
  10372. ---
  10373. --- {options} is a |Dictionary| with the following optional entries:
  10374. --- "vertical" When TRUE, the split is created vertically,
  10375. --- like with |:vsplit|.
  10376. --- "rightbelow" When TRUE, the split is made below or to the
  10377. --- right (if vertical). When FALSE, it is done
  10378. --- above or to the left (if vertical). When not
  10379. --- present, the values of 'splitbelow' and
  10380. --- 'splitright' are used.
  10381. ---
  10382. --- @param nr integer
  10383. --- @param target integer
  10384. --- @param options? table
  10385. --- @return any
  10386. function vim.fn.win_splitmove(nr, target, options) end
  10387. --- The result is a Number, which is the number of the buffer
  10388. --- associated with window {nr}. {nr} can be the window number or
  10389. --- the |window-ID|.
  10390. --- When {nr} is zero, the number of the buffer in the current
  10391. --- window is returned.
  10392. --- When window {nr} doesn't exist, -1 is returned.
  10393. --- Example: >vim
  10394. --- echo "The file in the current window is " .. bufname(winbufnr(0))
  10395. --- <
  10396. ---
  10397. --- @param nr integer
  10398. --- @return integer
  10399. function vim.fn.winbufnr(nr) end
  10400. --- The result is a Number, which is the virtual column of the
  10401. --- cursor in the window. This is counting screen cells from the
  10402. --- left side of the window. The leftmost column is one.
  10403. ---
  10404. --- @return integer
  10405. function vim.fn.wincol() end
  10406. --- The result is a String. For MS-Windows it indicates the OS
  10407. --- version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  10408. --- Windows XP is "5.1". For non-MS-Windows systems the result is
  10409. --- an empty string.
  10410. ---
  10411. --- @return string
  10412. function vim.fn.windowsversion() end
  10413. --- The result is a Number, which is the height of window {nr}.
  10414. --- {nr} can be the window number or the |window-ID|.
  10415. --- When {nr} is zero, the height of the current window is
  10416. --- returned. When window {nr} doesn't exist, -1 is returned.
  10417. --- An existing window always has a height of zero or more.
  10418. --- This excludes any window toolbar line.
  10419. --- Examples: >vim
  10420. --- echo "The current window has " .. winheight(0) .. " lines."
  10421. --- <
  10422. ---
  10423. --- @param nr integer
  10424. --- @return integer
  10425. function vim.fn.winheight(nr) end
  10426. --- The result is a nested List containing the layout of windows
  10427. --- in a tabpage.
  10428. ---
  10429. --- Without {tabnr} use the current tabpage, otherwise the tabpage
  10430. --- with number {tabnr}. If the tabpage {tabnr} is not found,
  10431. --- returns an empty list.
  10432. ---
  10433. --- For a leaf window, it returns: >
  10434. --- ["leaf", {winid}]
  10435. --- <
  10436. --- For horizontally split windows, which form a column, it
  10437. --- returns: >
  10438. --- ["col", [{nested list of windows}]]
  10439. --- <For vertically split windows, which form a row, it returns: >
  10440. --- ["row", [{nested list of windows}]]
  10441. --- <
  10442. --- Example: >vim
  10443. --- " Only one window in the tab page
  10444. --- echo winlayout()
  10445. --- < >
  10446. --- ['leaf', 1000]
  10447. --- < >vim
  10448. --- " Two horizontally split windows
  10449. --- echo winlayout()
  10450. --- < >
  10451. --- ['col', [['leaf', 1000], ['leaf', 1001]]]
  10452. --- < >vim
  10453. --- " The second tab page, with three horizontally split
  10454. --- " windows, with two vertically split windows in the
  10455. --- " middle window
  10456. --- echo winlayout(2)
  10457. --- < >
  10458. --- ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  10459. --- ['leaf', 1001]]], ['leaf', 1000]]]
  10460. --- <
  10461. ---
  10462. --- @param tabnr? integer
  10463. --- @return any[]
  10464. function vim.fn.winlayout(tabnr) end
  10465. --- The result is a Number, which is the screen line of the cursor
  10466. --- in the window. This is counting screen lines from the top of
  10467. --- the window. The first line is one.
  10468. --- If the cursor was moved the view on the file will be updated
  10469. --- first, this may cause a scroll.
  10470. ---
  10471. --- @return integer
  10472. function vim.fn.winline() end
  10473. --- The result is a Number, which is the number of the current
  10474. --- window. The top window has number 1.
  10475. --- Returns zero for a popup window.
  10476. ---
  10477. --- The optional argument {arg} supports the following values:
  10478. --- $ the number of the last window (the window
  10479. --- count).
  10480. --- # the number of the last accessed window (where
  10481. --- |CTRL-W_p| goes to). If there is no previous
  10482. --- window or it is in another tab page 0 is
  10483. --- returned. May refer to the current window in
  10484. --- some cases (e.g. when evaluating 'statusline'
  10485. --- expressions).
  10486. --- {N}j the number of the Nth window below the
  10487. --- current window (where |CTRL-W_j| goes to).
  10488. --- {N}k the number of the Nth window above the current
  10489. --- window (where |CTRL-W_k| goes to).
  10490. --- {N}h the number of the Nth window left of the
  10491. --- current window (where |CTRL-W_h| goes to).
  10492. --- {N}l the number of the Nth window right of the
  10493. --- current window (where |CTRL-W_l| goes to).
  10494. --- The number can be used with |CTRL-W_w| and ":wincmd w"
  10495. --- |:wincmd|.
  10496. --- When {arg} is invalid an error is given and zero is returned.
  10497. --- Also see |tabpagewinnr()| and |win_getid()|.
  10498. --- Examples: >vim
  10499. --- let window_count = winnr('$')
  10500. --- let prev_window = winnr('#')
  10501. --- let wnum = winnr('3k')
  10502. --- <
  10503. ---
  10504. --- @param arg? string|integer
  10505. --- @return integer
  10506. function vim.fn.winnr(arg) end
  10507. --- Returns a sequence of |:resize| commands that should restore
  10508. --- the current window sizes. Only works properly when no windows
  10509. --- are opened or closed and the current window and tab page is
  10510. --- unchanged.
  10511. --- Example: >vim
  10512. --- let cmd = winrestcmd()
  10513. --- call MessWithWindowSizes()
  10514. --- exe cmd
  10515. --- <
  10516. ---
  10517. --- @return string
  10518. function vim.fn.winrestcmd() end
  10519. --- Uses the |Dictionary| returned by |winsaveview()| to restore
  10520. --- the view of the current window.
  10521. --- Note: The {dict} does not have to contain all values, that are
  10522. --- returned by |winsaveview()|. If values are missing, those
  10523. --- settings won't be restored. So you can use: >vim
  10524. --- call winrestview({'curswant': 4})
  10525. --- <
  10526. --- This will only set the curswant value (the column the cursor
  10527. --- wants to move on vertical movements) of the cursor to column 5
  10528. --- (yes, that is 5), while all other settings will remain the
  10529. --- same. This is useful, if you set the cursor position manually.
  10530. ---
  10531. --- If you have changed the values the result is unpredictable.
  10532. --- If the window size changed the result won't be the same.
  10533. ---
  10534. --- @param dict vim.fn.winrestview.dict
  10535. --- @return any
  10536. function vim.fn.winrestview(dict) end
  10537. --- Returns a |Dictionary| that contains information to restore
  10538. --- the view of the current window. Use |winrestview()| to
  10539. --- restore the view.
  10540. --- This is useful if you have a mapping that jumps around in the
  10541. --- buffer and you want to go back to the original view.
  10542. --- This does not save fold information. Use the 'foldenable'
  10543. --- option to temporarily switch off folding, so that folds are
  10544. --- not opened when moving around. This may have side effects.
  10545. --- The return value includes:
  10546. --- lnum cursor line number
  10547. --- col cursor column (Note: the first column
  10548. --- zero, as opposed to what |getcurpos()|
  10549. --- returns)
  10550. --- coladd cursor column offset for 'virtualedit'
  10551. --- curswant column for vertical movement (Note:
  10552. --- the first column is zero, as opposed
  10553. --- to what |getcurpos()| returns). After
  10554. --- |$| command it will be a very large
  10555. --- number equal to |v:maxcol|.
  10556. --- topline first line in the window
  10557. --- topfill filler lines, only in diff mode
  10558. --- leftcol first column displayed; only used when
  10559. --- 'wrap' is off
  10560. --- skipcol columns skipped
  10561. --- Note that no option values are saved.
  10562. ---
  10563. --- @return vim.fn.winsaveview.ret
  10564. function vim.fn.winsaveview() end
  10565. --- The result is a Number, which is the width of window {nr}.
  10566. --- {nr} can be the window number or the |window-ID|.
  10567. --- When {nr} is zero, the width of the current window is
  10568. --- returned. When window {nr} doesn't exist, -1 is returned.
  10569. --- An existing window always has a width of zero or more.
  10570. --- Examples: >vim
  10571. --- echo "The current window has " .. winwidth(0) .. " columns."
  10572. --- if winwidth(0) <= 50
  10573. --- 50 wincmd |
  10574. --- endif
  10575. --- <For getting the terminal or screen size, see the 'columns'
  10576. --- option.
  10577. ---
  10578. --- @param nr integer
  10579. --- @return integer
  10580. function vim.fn.winwidth(nr) end
  10581. --- The result is a dictionary of byte/chars/word statistics for
  10582. --- the current buffer. This is the same info as provided by
  10583. --- |g_CTRL-G|
  10584. --- The return value includes:
  10585. --- bytes Number of bytes in the buffer
  10586. --- chars Number of chars in the buffer
  10587. --- words Number of words in the buffer
  10588. --- cursor_bytes Number of bytes before cursor position
  10589. --- (not in Visual mode)
  10590. --- cursor_chars Number of chars before cursor position
  10591. --- (not in Visual mode)
  10592. --- cursor_words Number of words before cursor position
  10593. --- (not in Visual mode)
  10594. --- visual_bytes Number of bytes visually selected
  10595. --- (only in Visual mode)
  10596. --- visual_chars Number of chars visually selected
  10597. --- (only in Visual mode)
  10598. --- visual_words Number of words visually selected
  10599. --- (only in Visual mode)
  10600. ---
  10601. --- @return any
  10602. function vim.fn.wordcount() end
  10603. --- When {object} is a |List| write it to file {fname}. Each list
  10604. --- item is separated with a NL. Each list item must be a String
  10605. --- or Number.
  10606. --- All NL characters are replaced with a NUL character.
  10607. --- Inserting CR characters needs to be done before passing {list}
  10608. --- to writefile().
  10609. ---
  10610. --- When {object} is a |Blob| write the bytes to file {fname}
  10611. --- unmodified, also when binary mode is not specified.
  10612. ---
  10613. --- {flags} must be a String. These characters are recognized:
  10614. ---
  10615. --- 'b' Binary mode is used: There will not be a NL after the
  10616. --- last list item. An empty item at the end does cause the
  10617. --- last line in the file to end in a NL.
  10618. ---
  10619. --- 'a' Append mode is used, lines are appended to the file: >vim
  10620. --- call writefile(["foo"], "event.log", "a")
  10621. --- call writefile(["bar"], "event.log", "a")
  10622. --- <
  10623. --- 'D' Delete the file when the current function ends. This
  10624. --- works like: >vim
  10625. --- defer delete({fname})
  10626. --- < Fails when not in a function. Also see |:defer|.
  10627. ---
  10628. --- 's' fsync() is called after writing the file. This flushes
  10629. --- the file to disk, if possible. This takes more time but
  10630. --- avoids losing the file if the system crashes.
  10631. ---
  10632. --- 'S' fsync() is not called, even when 'fsync' is set.
  10633. ---
  10634. --- When {flags} does not contain "S" or "s" then fsync() is
  10635. --- called if the 'fsync' option is set.
  10636. ---
  10637. --- An existing file is overwritten, if possible.
  10638. ---
  10639. --- When the write fails -1 is returned, otherwise 0. There is an
  10640. --- error message if the file can't be created or when writing
  10641. --- fails.
  10642. ---
  10643. --- Also see |readfile()|.
  10644. --- To copy a file byte for byte: >vim
  10645. --- let fl = readfile("foo", "b")
  10646. --- call writefile(fl, "foocopy", "b")
  10647. --- <
  10648. ---
  10649. --- @param object any
  10650. --- @param fname string
  10651. --- @param flags? string
  10652. --- @return any
  10653. function vim.fn.writefile(object, fname, flags) end
  10654. --- Bitwise XOR on the two arguments. The arguments are converted
  10655. --- to a number. A List, Dict or Float argument causes an error.
  10656. --- Also see `and()` and `or()`.
  10657. --- Example: >vim
  10658. --- let bits = xor(bits, 0x80)
  10659. --- <
  10660. ---
  10661. --- @param expr integer
  10662. --- @param expr1 integer
  10663. --- @return integer
  10664. function vim.fn.xor(expr, expr1) end