about summary refs log tree commit diff stats
path: root/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-02 18:51:14 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-02 18:53:06 +0100
commit5d95ae4d2c4a47589412fafd1572eaaaff15622d (patch)
tree6e95a463c0830602933aee3dee61370150c176b0 /modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets
parentfeat(flake/treefmt.nix): Specify lua formatter settings (diff)
downloadnixos-config-5d95ae4d2c4a47589412fafd1572eaaaff15622d.tar.gz
nixos-config-5d95ae4d2c4a47589412fafd1572eaaaff15622d.zip
style(modules/legacy/conf/nvim): Format
Diffstat (limited to 'modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets')
-rw-r--r--modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/all.lua73
-rw-r--r--modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua12
-rw-r--r--modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua12
3 files changed, 34 insertions, 63 deletions
diff --git a/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/all.lua b/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/all.lua
index f6cb09b0..2b923f20 100644
--- a/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/all.lua
+++ b/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/all.lua
@@ -34,9 +34,7 @@ local function pair(pair_begin, pair_end, file_types, condition_function)
     {
       condition = function()
         local filetype_check = true
-        if file_types ~= nil then
-          filetype_check = file_types[vim.bo.filetype] or false
-        end
+        if file_types ~= nil then filetype_check = file_types[vim.bo.filetype] or false end
         return (not condition_function(pair_begin, pair_end)) and filetype_check
       end,
     }
@@ -49,7 +47,7 @@ local auto_pairs = {
   pair("[", "]", nil, char_count_same),
   pair("<", ">", { ["rust"] = true, ["tex"] = true }, char_count_same),
   pair("'", "'", nil, even_count),
-  pair('"', '"', nil, even_count),
+  pair("\"", "\"", nil, even_count),
   pair("`", "`", nil, even_count),
 }
 
@@ -61,15 +59,13 @@ local calculate_comment_string = require("Comment.ft").calculate
 local utils = require("Comment.utils")
 
 local read_git_config = function(config_value)
-  local command = string.format('git config "%s"', config_value)
+  local command = string.format("git config \"%s\"", config_value)
   local handle = io.popen(command)
-  if handle == nil then
-    return error(string.format("Failed to call `%s`.", command))
-  end
+  if handle == nil then return error(string.format("Failed to call `%s`.", command)) end
   local result = handle:read("*a")
   handle:close()
   -- stripped = string.gsub(str, '%s+', '')
-  return string.gsub(result, '\n', '')
+  return string.gsub(result, "\n", "")
 end
 
 local name_to_handle = function(name)
@@ -121,18 +117,10 @@ end
 --- Options for marks to be used in a TODO comment
 ---@return table,table: The first table contains a node for the date, the second for the signature
 local marks = {
-  signature = function()
-    return t("(" .. _G.luasnip.vars:username() .. ")"), t("")
-  end,
-  date_signature = function()
-    return t("<" .. os.date("%Y-%m-%d") .. ">"), t("(" .. _G.luasnip.vars:username() .. ")")
-  end,
-  date = function()
-    return t("<" .. os.date("%Y-%m-%d") .. ">"), t("")
-  end,
-  empty = function()
-    return t(""), t("")
-  end,
+  signature = function() return t("(" .. _G.luasnip.vars:username() .. ")"), t("") end,
+  date_signature = function() return t("<" .. os.date("%Y-%m-%d") .. ">"), t("(" .. _G.luasnip.vars:username() .. ")") end,
+  date = function() return t("<" .. os.date("%Y-%m-%d") .. ">"), t("") end,
+  empty = function() return t(""), t("") end,
 }
 
 ---@param alias string
@@ -146,9 +134,9 @@ local todo_snippet_nodes = function(alias, opts, mark_function)
     f(function()
       return get_cstring(opts.ctype)[1] -- get <comment-string[1]>
     end),
-    t(alias),                           -- [name-of-comment]
+    t(alias), -- [name-of-comment]
     signature_node,
-    i(0),                               -- {comment-text}
+    i(0), -- {comment-text}
     date_node,
     f(function()
       return get_cstring(opts.ctype)[2] -- get <comment-string[2]>
@@ -168,18 +156,13 @@ local todo_snippet = function(context, alias, opts, mark_function)
   if not context.trig then
     return error("context doesn't include a `trig` key which is mandatory", 2) -- all we need from the context is the trigger
   end
-  opts.ctype = opts.ctype or
-      1                                                   -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined
-  local alias_string =
-      alias                                               -- `choice_node` documentation
-  context.name = context.name or
-      (alias_string .. " comment")                        -- generate the `name` of the snippet if not defined
-  context.dscr = context.dscr or
-      (alias_string .. " comment with a signature-mark")  -- generate the `dscr` if not defined
-  context.docstring = context.docstring or
-      (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined
+  opts.ctype = opts.ctype or 1 -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined
+  local alias_string = alias -- `choice_node` documentation
+  context.name = context.name or (alias_string .. " comment") -- generate the `name` of the snippet if not defined
+  context.dscr = context.dscr or (alias_string .. " comment with a signature-mark") -- generate the `dscr` if not defined
+  context.docstring = context.docstring or (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined
   local comment_node = todo_snippet_nodes(alias, opts, mark_function)
-  return s(context, comment_node, opts)                   -- the final todo-snippet constructed from our parameters
+  return s(context, comment_node, opts) -- the final todo-snippet constructed from our parameters
 end
 
 ---@param context table: The luasnip context
@@ -199,20 +182,20 @@ local process_marks = function(context, aliases, opts, marks)
 end
 
 local todo_snippet_specs = {
-  { { trig = "todo" },  { "TODO" },                                     { ctype = 1 } },
-  { { trig = "fix" },   { "FIXME", "ISSUE" },                           { ctype = 1 } },
-  { { trig = "hack" },  { "HACK" },                                     { ctype = 1 } },
-  { { trig = "warn" },  { "WARNING" },                                  { ctype = 1 } },
-  { { trig = "perf" },  { "PERFORMANCE", "OPTIMIZE" },                  { ctype = 1 } },
-  { { trig = "note" },  { "NOTE", "INFO" },                             { ctype = 1 } },
+  { { trig = "todo" }, { "TODO" }, { ctype = 1 } },
+  { { trig = "fix" }, { "FIXME", "ISSUE" }, { ctype = 1 } },
+  { { trig = "hack" }, { "HACK" }, { ctype = 1 } },
+  { { trig = "warn" }, { "WARNING" }, { ctype = 1 } },
+  { { trig = "perf" }, { "PERFORMANCE", "OPTIMIZE" }, { ctype = 1 } },
+  { { trig = "note" }, { "NOTE", "INFO" }, { ctype = 1 } },
 
   -- NOTE: Block commented todo-comments
-  { { trig = "todob" }, { "TODO" },                                     { ctype = 2 } },
-  { { trig = "fixb" },  { "FIXME", "ISSUE" },                           { ctype = 2 } },
-  { { trig = "hackb" }, { "HACK" },                                     { ctype = 2 } },
-  { { trig = "warnb" }, { "WARNING" },                                  { ctype = 2 } },
+  { { trig = "todob" }, { "TODO" }, { ctype = 2 } },
+  { { trig = "fixb" }, { "FIXME", "ISSUE" }, { ctype = 2 } },
+  { { trig = "hackb" }, { "HACK" }, { ctype = 2 } },
+  { { trig = "warnb" }, { "WARNING" }, { ctype = 2 } },
   { { trig = "perfb" }, { "PERF", "PERFORMANCE", "OPTIM", "OPTIMIZE" }, { ctype = 2 } },
-  { { trig = "noteb" }, { "NOTE", "INFO" },                             { ctype = 2 } },
+  { { trig = "noteb" }, { "NOTE", "INFO" }, { ctype = 2 } },
 }
 
 local todo_comment_snippets = {}
diff --git a/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua b/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua
index 17e1e7fb..568c97ec 100644
--- a/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua
+++ b/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua
@@ -22,13 +22,9 @@ return {
           <h{}>{}</h{}>
         ]],
       {
-        f(function(_, snip)
-          return snip.captures[1]
-        end),
+        f(function(_, snip) return snip.captures[1] end),
         d(1, get_visual),
-        f(function(_, snip)
-          return snip.captures[1]
-        end),
+        f(function(_, snip) return snip.captures[1] end),
       }
     ),
     { condition = line_begin }
@@ -97,9 +93,7 @@ return {
           {}<a href="{}">{}</a>
         ]],
       {
-        f(function(_, snip)
-          return snip.captures[1]
-        end),
+        f(function(_, snip) return snip.captures[1] end),
         i(1),
         d(2, get_visual),
       }
diff --git a/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua b/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua
index 22434aa3..ef453973 100644
--- a/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua
+++ b/modules/home.legacy/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua
@@ -19,16 +19,10 @@ return {
       snippetType = "autosnippet",
     },
     fmta("<>\\left<><>\\right<>", {
-      f(function(_, snip)
-        return snip.captures[1]
-      end),
-      f(function(_, snip)
-        return snip.captures[2]
-      end),
+      f(function(_, snip) return snip.captures[1] end),
+      f(function(_, snip) return snip.captures[2] end),
       d(1, get_visual),
-      f(function(_, snip)
-        return translation_table[snip.captures[2]]
-      end),
+      f(function(_, snip) return translation_table[snip.captures[2]] end),
     })
   ),
 }