You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you ever wish to easily insert a markdown table feel free to use the following function:
insert_markdown_table=function()
localget_size=function()
localINPUT_CANCELLED="~~~INPUT-CANCELLED~~~"localinput=vim.fn.input { prompt="Size of the table - columns by rows (e.g. 2x3)", cancelreturn=INPUT_CANCELLED }
ifinput==INPUT_CANCELLEDthen-- early return if the user cancels the inputreturnnil, nilendlocalstring_column, string_row=input:match("([^x]+)x([^x]+)")
returntonumber(string_column), tonumber(string_row)
endlocalcolumns, rows=get_size();
ifcolumns==nilorrows==nilorcolumns<1orrows<1thenvim.api.nvim_err_writeln("Invalid input. Please provide a valid size (e.g. 2x3)")
returnend-- Create a row-- @param row number-- @param header booleanlocalcreate_row=function(length, header)
localrow="|"for_=1, lengthdorow=row.. (headerand" ---" or"") .." |"endreturnrowendlocalrows_table= {}
-- First row with header rowtable.insert(rows_table, create_row(columns, false))
table.insert(rows_table, create_row(columns, true))
for_=2, rowsdotable.insert(rows_table, create_row(columns, false))
endvim.api.nvim_put(rows_table, "l", true, false)
end
When called, it will prompt you for a size which should be in the form of nb_columnsxnb_rows meaning that if you wish to create a table of 4 columns by 2 rows you should input 4x2
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
If you ever wish to easily insert a markdown table feel free to use the following function:
When called, it will prompt you for a size which should be in the form of
nb_columnsxnb_rows
meaning that if you wish to create a table of 4 columns by 2 rows you should input4x2
Beta Was this translation helpful? Give feedback.
All reactions