From 6bd65b9636cb479c0c3f79a6e408382d7648b9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Harnes?= Date: Tue, 2 Apr 2024 14:44:56 +0200 Subject: [PATCH] chore: add docstrings to config --- lua/img-clip/config.lua | 69 +++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/lua/img-clip/config.lua b/lua/img-clip/config.lua index c1d801e..a1330ff 100644 --- a/lua/img-clip/config.lua +++ b/lua/img-clip/config.lua @@ -10,55 +10,50 @@ M.opts = {} local defaults = { default = { - dir_path = "assets", -- directory path to save images to, can be relative (cwd or current file) or absolute - file_name = "%Y-%m-%d-%H-%M-%S", -- file name format (see lua.org/pil/22.1.html) - process_cmd = "", -- shell command to process the image before saving or embedding as base64 - url_encode_path = false, -- encode spaces and special characters in file path - use_absolute_path = false, -- expands dir_path to an absolute path - relative_to_current_file = false, -- make dir_path relative to current file rather than the cwd - relative_template_path = true, -- make file path in the template relative to current file rather than the cwd - prompt_for_file_name = true, -- ask user for file name before saving, leave empty to use default - show_dir_path_in_prompt = false, -- show dir_path in prompt when prompting for file name - use_cursor_in_template = true, -- jump to cursor position in template after pasting - insert_mode_after_paste = true, -- enter insert mode after pasting the markup code - embed_image_as_base64 = false, -- paste image as base64 string instead of saving to file - max_base64_size = 10, -- max size of base64 string in KB - template = "$FILE_PATH", -- default template - copy_images = false, -- copy images instead of using the original file - download_images = true, -- download images and save them to dir_path instead of using the URL + dir_path = "assets", ---@type string + file_name = "%Y-%m-%d-%H-%M-%S", ---@type string + process_cmd = "", ---@type string + url_encode_path = false, ---@type boolean + use_absolute_path = false, ---@type boolean + relative_to_current_file = false, ---@type boolean + relative_template_path = true, ---@type boolean + prompt_for_file_name = true, ---@type boolean + show_dir_path_in_prompt = false, ---@type boolean + use_cursor_in_template = true, ---@type boolean + insert_mode_after_paste = true, ---@type boolean + embed_image_as_base64 = false, ---@type boolean + max_base64_size = 10, ---@type number + template = "$FILE_PATH", ---@type string + copy_images = false, ---@type boolean + download_images = true, ---@type boolean drag_and_drop = { - enabled = true, -- enable drag and drop mode - insert_mode = false, -- enable drag and drop in insert mode + enabled = true, ---@type boolean + insert_mode = false, ---@type boolean }, }, - -- filetype specific options - -- any options that are passed here will override the default config - -- for instance, setting use_absolute_path = true for markdown will - -- only enable that for this particular filetype - -- the key (e.g. "markdown") is the filetype (output of "set filetype?") filetypes = { markdown = { - url_encode_path = true, - template = "![$CURSOR]($FILE_PATH)", - download_images = false, + url_encode_path = true, ---@type boolean + template = "![$CURSOR]($FILE_PATH)", ---@type string + download_images = false, ---@type boolean }, html = { - template = '$CURSOR', + template = '$CURSOR', ---@type string }, tex = { - relative_template_path = false, - template = [[ + relative_template_path = false, ---@type boolean + template = [[ \begin{figure}[h] \centering \includegraphics[width=0.8\textwidth]{$FILE_PATH} \caption{$CURSOR} \label{fig:$LABEL} \end{figure} - ]], + ]], ---@type string }, typst = { @@ -67,7 +62,7 @@ local defaults = { image("$FILE_PATH", width: 80%), caption: [$CURSOR], ) - ]], + ]], ---@type string }, rst = { @@ -75,11 +70,11 @@ local defaults = { .. image:: $FILE_PATH :alt: $CURSOR :width: 80% - ]], + ]], ---@type string }, asciidoc = { - template = 'image::$FILE_PATH[width=80%, alt="$CURSOR"]', + template = 'image::$FILE_PATH[width=80%, alt="$CURSOR"]', ---@type string }, org = { @@ -89,13 +84,13 @@ local defaults = { #+CAPTION: $CURSOR #+NAME: fig:$LABEL #+END_FIGURE - ]=], + ]=], ---@type string }, }, - files = {}, -- file specific options (e.g. "main.md" or "/path/to/main.md") - dirs = {}, -- dir specific options (e.g. "project" or "/home/hakon/project") - custom = {}, -- custom options enabled with the trigger option + files = {}, ---@type table + dirs = {}, ---@type table + custom = {}, ---@type table } defaults.filetypes.plaintex = defaults.filetypes.tex