From 517cef14eae7ef8d1de7f740058adcda3bc26488 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Wed, 8 Oct 2025 19:54:46 +0300 Subject: [PATCH] Update 2025-10-08 update 2025-10-08 --- .editorconfig | 170 +++++++++++++ after/plugin/snips/c.lua | 61 ----- after/plugin/snips/cmake.lua | 53 ---- after/plugin/snips/cpp.lua | 61 ----- after/plugin/snips/rust.lua | 145 ----------- after/plugin/snips/typst.lua | 10 - lazy-lock.json | 4 +- lua/config/keymaps.lua | 9 +- lua/config/lazy.lua | 5 +- lua/config/options.lua | 60 ++--- lua/config/snips.lua | 78 ------ lua/plugins/conform.lua | 8 +- lua/plugins/crates.lua | 1 - lua/plugins/http-codes.lua | 11 +- lua/plugins/image.lua | 108 +++++--- lua/plugins/lsp.lua | 72 +++--- lua/plugins/luasnip.lua | 45 +--- lua/plugins/obsidian.lua | 1 - lua/plugins/snacks.lua | 131 ++++++++-- lua/plugins/todo-comments.lua | 66 +---- lua/plugins/typescript-tools.lua | 9 +- lua/plugins/typst.lua | 40 +-- selene.toml | 1 + snippets/all.lua | 1 + snippets/c.lua | 3 + snippets/cmake.lua | 3 + snippets/cpp.lua | 3 + {after/plugin/snips => snippets}/lua.lua | 26 +- {after/plugin/snips => snippets}/markdown.lua | 13 +- {after/plugin/snips => snippets}/python.lua | 28 ++- snippets/rust.lua | 233 ++++++++++++++++++ snippets/typst.lua | 33 +++ spell/lv.utf-8.add | 2 + spell/lv.utf-8.add.spl | Bin 6688 -> 6699 bytes stylua.toml | 10 - 35 files changed, 756 insertions(+), 748 deletions(-) create mode 100644 .editorconfig delete mode 100644 after/plugin/snips/c.lua delete mode 100644 after/plugin/snips/cmake.lua delete mode 100644 after/plugin/snips/cpp.lua delete mode 100644 after/plugin/snips/rust.lua delete mode 100644 after/plugin/snips/typst.lua delete mode 100644 lua/config/snips.lua create mode 100644 snippets/all.lua create mode 100644 snippets/c.lua create mode 100644 snippets/cmake.lua create mode 100644 snippets/cpp.lua rename {after/plugin/snips => snippets}/lua.lua (59%) rename {after/plugin/snips => snippets}/markdown.lua (57%) rename {after/plugin/snips => snippets}/python.lua (73%) create mode 100644 snippets/rust.lua create mode 100644 snippets/typst.lua delete mode 100644 stylua.toml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a1de149 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,170 @@ +# see https://github.com/CppCXY/EmmyLuaCodeStyle +[*.lua] +# [basic] + +# optional space/tab +indent_style = tab +# if indent_style is space, this is valid +indent_size = 4 +# if indent_style is tab, this is valid +tab_width = 4 +# none/single/double +quote_style = double + +continuation_indent = 4 +## extend option +# continuation_indent.before_block = 4 +# continuation_indent.in_expr = 4 +# continuation_indent.in_table = 4 + +# this mean utf8 length , if this is 'unset' then the line width is no longer checked +# this option decides when to chopdown the code +max_line_length = 120 + +# optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf +# in neovim the value 'auto' is not a valid option, please use 'unset' +end_of_line = lf + +# none/ comma / semicolon / only_kv_colon +table_separator_style = comma + +#optional keep/never/always/smart +trailing_table_separator = smart + +# keep/remove/remove_table_only/remove_string_only +call_arg_parentheses = keep + +detect_end_of_line = false + +# this will check text end with new line +insert_final_newline = true + +# [space] +space_around_table_field_list = true + +space_before_attribute = true + +space_before_function_open_parenthesis = false + +space_before_function_call_open_parenthesis = false + +space_before_closure_open_parenthesis = false + +# optional always/only_string/only_table/none +# or true/false +space_before_function_call_single_arg = always +## extend option +## always/keep/none +# space_before_function_call_single_arg.table = always +## always/keep/none +# space_before_function_call_single_arg.string = always + +space_before_open_square_bracket = false + +space_inside_function_call_parentheses = false + +space_inside_function_param_list_parentheses = false + +space_inside_square_brackets = false + +# like t[#t+1] = 1 +space_around_table_append_operator = false + +ignore_spaces_inside_function_call = false + +# detail number or 'keep' +space_before_inline_comment = 1 + +# convert '---' to '--- ' or '--' to '-- ' +space_after_comment_dash = false + +# [operator space] +space_around_math_operator = true +# space_around_math_operator.exponent = false + +space_after_comma = true + +space_after_comma_in_for_statement = true + +# true/false or none/always/no_space_asym +space_around_concat_operator = true + +space_around_logical_operator = true + +# true/false or none/always/no_space_asym +space_around_assign_operator = true + +# [align] + +align_call_args = false + +align_function_params = true + +# true/false or always +align_continuous_assign_statement = true + +align_continuous_rect_table_field = true + +align_continuous_line_space = 2 + +align_if_branch = false + +# option none / always / contain_curly/ +align_array_table = always + +align_continuous_similar_call_args = false + +align_continuous_inline_comment = true +# option none / always / only_call_stmt +align_chain_expr = none + +# [indent] + +never_indent_before_if_condition = false + +never_indent_comment_on_if_branch = false + +keep_indents_on_empty_lines = false + +allow_non_indented_comments = false +# [line space] + +# The following configuration supports four expressions +# keep +# fixed(n) +# min(n) +# max(n) +# for eg. min(2) + +line_space_after_if_statement = keep + +line_space_after_do_statement = keep + +line_space_after_while_statement = keep + +line_space_after_repeat_statement = keep + +line_space_after_for_statement = keep + +line_space_after_local_or_assign_statement = keep + +line_space_after_function_statement = fixed(2) + +line_space_after_expression_statement = keep + +line_space_after_comment = keep + +line_space_around_block = fixed(1) +# [line break] +break_all_list_when_line_exceed = true + +auto_collapse_lines = false + +break_before_braces = false + +# [preference] +ignore_space_after_colon = false + +remove_call_expression_list_finish_comma = false +# keep / always / same_line / replace_with_newline / never +end_statement_with_semicolon = keep diff --git a/after/plugin/snips/c.lua b/after/plugin/snips/c.lua deleted file mode 100644 index 20c55b6..0000000 --- a/after/plugin/snips/c.lua +++ /dev/null @@ -1,61 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local f = ls.function_node -local fmt = require("luasnip.extras.fmt").fmt - -local shared = require("config.snips") -local same = shared.same -local year = shared.year -local date = shared.date - -ls.add_snippets("c", { - s( - "auth", - fmt( - [[ - // Copyright {} - // Author - Kristiāns Francis Cagulis, kc22015 - // {} - // Created: {} - ]], - { - year(), - i(1), - date(), - } - ) - ), - s( - "fn", - fmt( - [[ - // {}; - // Funkcija {}({}) - - // {} - {} {{ - }} - ]], - { - same(1), - f(function(function_name) - if not function_name[1][1] then - function_name[1][1] = "" - end - local words = {} - for word in function_name[1][1]:gmatch("%w+") do - table.insert(words, word) - end - return words[2] or "" - end, { 1 }), - i(2), - i(0), - i(1), - } - ) - ), -}) diff --git a/after/plugin/snips/cmake.lua b/after/plugin/snips/cmake.lua deleted file mode 100644 index 29a8930..0000000 --- a/after/plugin/snips/cmake.lua +++ /dev/null @@ -1,53 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local fmt = require("luasnip.extras.fmt").fmt - -local shared = require("config.snips") -local same = shared.same - -local cmake_version = function() - local version = "3.27.4" - -- vim.fn.jobstart("cmake --version | head -n 1 | rg -o '\\d+\\.\\d+\\.\\d+'", {}) - return version -end - -ls.add_snippets("cmake", { - s( - "lib", - fmt( - [[ - cmake_minimum_required(VERSION {}) - project({}) - add_library(${{PROJECT_NAME}} src/{}.cc) - ]], - { - cmake_version(), - i(1), - same(1), - } - ) - ), - s( - "bin", - fmt( - [[ - cmake_minimum_required(VERSION {}) - project({}) - add_executable(${{PROJECT_NAME}} src/main.cc) - target_link_directories(${{PROJECT_NAME}} PRIVATE ${{CMAKE_SOURCE_DIR}}/include/{}/target/build/) - target_link_libraries(${{PROJECT_NAME}} {}) - ]], - { - cmake_version(), - i(1), - i(2), - same(2), - } - ) - ), -}) diff --git a/after/plugin/snips/cpp.lua b/after/plugin/snips/cpp.lua deleted file mode 100644 index 95016f0..0000000 --- a/after/plugin/snips/cpp.lua +++ /dev/null @@ -1,61 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local f = ls.function_node -local fmt = require("luasnip.extras.fmt").fmt - -local shared = require("config.snips") -local same = shared.same -local year = shared.year -local date = shared.date - -ls.add_snippets("cpp", { - s( - "auth", - fmt( - [[ - // Copyright {} - // Author - Kristiāns Francis Cagulis, kc22015 - // {} - // Created: {} - ]], - { - year(), - i(1), - date(), - } - ) - ), - s( - "fn", - fmt( - [[ - // {}; - // Funkcija {}({}) - - // {} - {} {{ - }} - ]], - { - same(1), - f(function(function_name) - if not function_name[1][1] then - function_name[1][1] = "" - end - local words = {} - for word in function_name[1][1]:gmatch("%w+") do - table.insert(words, word) - end - return words[2] or "" - end, { 1 }), - i(2), - i(0), - i(1), - } - ) - ), -}) diff --git a/after/plugin/snips/rust.lua b/after/plugin/snips/rust.lua deleted file mode 100644 index 51204f1..0000000 --- a/after/plugin/snips/rust.lua +++ /dev/null @@ -1,145 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local fmt = require("luasnip.extras.fmt").fmt -local shared = require("config.snips") -local same = shared.same - -ls.add_snippets("rust", { - s( - "modtest", - fmt( - [[ - #[cfg(test)] - mod tests {{ - use super::*; - {} - }} - ]], - { - i(1), - } - ) - ), - s( - "tmain", - fmt( - [[ - #[tokio::main] - async fn main() -> Result<()> {{ - Ok(()) - }} - ]], - {} - ) - ), - s( - "dead", - fmt( - [[ - #[allow(dead_code)] - ]], - {} - ) - ), - s( - "component", - fmt( - [[ - #[derive(Debug, Reflect, Component)] - #[reflect(Component)] - struct {} - ]], - { - i(1), - } - ) - ), - s( - "event", - fmt( - [[ - #[derive(Debug, Event)] - struct {} - ]], - { - i(1), - } - ) - ), - s( - "resource", - fmt( - [[ - #[derive(Debug, Default, Reflect, Resource)] - #[reflect(Resource)] - struct {} - ]], - { - i(1), - } - ) - ), - s( - "schedule", - fmt( - [[ - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ScheduleLabel)] - struct {} - ]], - { - i(1), - } - ) - ), - s( - "states", - fmt( - [[ - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, States)] - enum {} {{ - #[default] - {} - }} - ]], - { - i(1), - i(2), - } - ) - ), - s( - "systemset", - fmt( - [[ - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)] - enum {} {{ - {} - }} - ]], - { - i(1), - i(2), - } - ) - ), - s( - "plugin", - fmt( - [[ - use bevy::prelude::*; - - pub(super) fn plugin(app: &mut App) {{ - {} - }} - ]], - { - i(1), - } - ) - ), -}) diff --git a/after/plugin/snips/typst.lua b/after/plugin/snips/typst.lua deleted file mode 100644 index c3ff18f..0000000 --- a/after/plugin/snips/typst.lua +++ /dev/null @@ -1,10 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local fmt = require("luasnip.extras.fmt").fmt - -ls.add_snippets("typst", {}) diff --git a/lazy-lock.json b/lazy-lock.json index ba20612..8cd7995 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -30,7 +30,9 @@ "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, - "http-codes.nvim": { "branch": "main", "commit": "77aea3a73d5f3134089941ebf6d4172af34a4a8d" }, + "hererocks": { "branch": "master", "commit": "160228946bed9998f5e3b168bd0b66ba2690f8f3" }, + "http-codes.nvim": { "branch": "feature/snacks", "commit": "4b4886c5091a125900a6e319bddd10bc34747bf1" }, + "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, "img-clip.nvim": { "branch": "main", "commit": "f33f3af9ba50f99d70f8fcb1a8575750ada4ea4a" }, "inlay-hint.nvim": { "branch": "main", "commit": "ee8aa9806d1e160a2bc08b78ae60568fb6d9dbce" }, "inlay-hints.nvim": { "branch": "master", "commit": "990e1f96699b8293b6665b9e73b16128c66684e6" }, diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 1c72443..e8d1d56 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -46,12 +46,13 @@ nmap("Q", "@qj", "Run macro") nmap("oo", "updatesource", "Source current file") --- vim.keymap.set({ "n", "v", "x" }, "y", '"+y', { desc = "Yank to system clipboard" }) --- vim.keymap.set("n", "Y", '"+yy', { desc = "Yank line to system clipboard" }) +vim.keymap.set({ "n", "v", "x" }, "y", '"+y', { desc = "Yank to system clipboard" }) +vim.keymap.set("n", "Y", '"+yy', { desc = "Yank line to system clipboard" }) --- vim.keymap.set({ "n", "v", "x" }, "p", '"+p', { desc = "Paste from system clipboard" }) --- vim.keymap.set("n", "P", '"+P', { desc = "Paste before cursor from system clipboard" }) +vim.keymap.set({ "n", "v", "x" }, "d", '"+d', { desc = "Cut to system clipboard" }) +vim.keymap.set({ "n", "v", "x" }, "p", '"+p', { desc = "Paste from system clipboard" }) +vim.keymap.set("n", "P", '"+P', { desc = "Paste before cursor from system clipboard" }) vim.keymap.set("n", "cf", function() local file_path = vim.fn.expand("%:p") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index a2860b3..d3d6bce 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -28,9 +28,6 @@ require("lazy").setup({ ui = { border = "rounded" }, change_detection = { enabled = false }, rocks = { - hererocks = nil, - }, - dev = { - path = "~/repos/nvim/plugins", + hererocks = true, }, }) diff --git a/lua/config/options.lua b/lua/config/options.lua index 81aa125..ec8081c 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -1,57 +1,57 @@ -vim.opt.backup = false -- creates a backup file -vim.opt.breakindent = true -- Enable break indent -vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard -vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages +vim.opt.backup = false -- creates a backup file +vim.opt.breakindent = true -- Enable break indent +vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard +vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages vim.opt.colorcolumn = "120" vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp -vim.opt.conceallevel = 2 -- so that `` is visible in markdown files -vim.opt.cursorcolumn = true -- highlight the current column -vim.opt.cursorline = true -- highlight the current line -vim.opt.expandtab = true -- convert tabs to spaces -vim.opt.fileencoding = "utf-8" -- the encoding written to a file +vim.opt.conceallevel = 2 -- so that `` is visible in markdown files +vim.opt.cursorcolumn = true -- highlight the current column +vim.opt.cursorline = true -- highlight the current line +vim.opt.expandtab = true -- convert tabs to spaces +vim.opt.fileencoding = "utf-8" -- the encoding written to a file vim.opt.fillchars.eob = " " vim.opt.foldmethod = "manual" vim.opt.foldenable = true vim.opt.foldlevelstart = 99 -vim.opt.foldcolumn = "1" -- '0' is not bad +vim.opt.foldcolumn = "1" -- '0' is not bad vim.opt.guifont = "JetBrainsMono NF:h11" -- the font used in graphical neovim applications -vim.opt.hlsearch = false -- highlight all matches on previous search pattern -vim.opt.ignorecase = true -- ignore case in search patterns +vim.opt.hlsearch = false -- highlight all matches on previous search pattern +vim.opt.ignorecase = true -- ignore case in search patterns vim.opt.incsearch = true vim.opt.isfname:append("@-@") vim.opt.iskeyword:append("-") vim.opt.laststatus = 3 -vim.opt.mouse = "a" -- allow the mouse to be used in neovim -vim.opt.number = true -- set numbered lines -vim.opt.numberwidth = 4 -- set number column width to 4 {default 4} -vim.opt.pumheight = 10 -- pop up menu height +vim.opt.mouse = "a" -- allow the mouse to be used in neovim +vim.opt.number = true -- set numbered lines +vim.opt.numberwidth = 4 -- set number column width to 4 {default 4} +vim.opt.pumheight = 10 -- pop up menu height vim.opt.relativenumber = true -- set relative numbered lines vim.opt.ruler = false -vim.opt.scrolloff = 8 -- is one of my fav -vim.opt.shiftwidth = 4 -- the number of spaces inserted for each indentation +vim.opt.scrolloff = 8 -- is one of my fav +vim.opt.shiftwidth = 4 -- the number of spaces inserted for each indentation vim.opt.shortmess:append("c") vim.opt.showcmd = false -vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore -vim.opt.showtabline = 0 -- disable tabs +vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore +vim.opt.showtabline = 0 -- disable tabs vim.opt.sidescrolloff = 8 vim.opt.signcolumn = "yes" -- always show the sign column otherwise it would shift the text each time -vim.opt.smartcase = true -- smart case +vim.opt.smartcase = true -- smart case vim.opt.smartindent = true -- make indenting smarter again vim.opt.softtabstop = 4 vim.opt.spell = false vim.opt.spelloptions:append("camel") -vim.opt.splitbelow = true -- force all horizontal splits to go below current window -vim.opt.splitright = true -- force all vertical splits to go to the right of current window -vim.opt.swapfile = false -- creates a swapfile -vim.opt.tabstop = 4 -- insert 4 spaces for a tab +vim.opt.splitbelow = true -- force all horizontal splits to go below current window +vim.opt.splitright = true -- force all vertical splits to go to the right of current window +vim.opt.swapfile = false -- creates a swapfile +vim.opt.tabstop = 4 -- insert 4 spaces for a tab vim.opt.termguicolors = true -- set term gui colors (most terminals support this) -vim.opt.timeoutlen = 250 -- time to wait for a mapped sequence to complete (in milliseconds) +vim.opt.timeoutlen = 250 -- time to wait for a mapped sequence to complete (in milliseconds) vim.opt.undodir = vim.fn.stdpath("data") .. "/nvim/undodir" -vim.opt.undofile = true -- enable persistent undo -vim.opt.updatetime = 50 -- faster completion (4000ms default) +vim.opt.undofile = true -- enable persistent undo +vim.opt.updatetime = 50 -- faster completion (4000ms default) vim.opt.whichwrap:append("<,>,[,],h,l") -vim.opt.wrap = false -- display lines as one long line -vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program) it is not allowed to be edit +vim.opt.wrap = false -- display lines as one long line +vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program) it is not allowed to be edit vim.opt_local.path:prepend(vim.fn.stdpath("config") .. "/lua") vim.opt_local.suffixesadd:prepend(".lua") vim.opt_local.suffixesadd:prepend("init.lua") diff --git a/lua/config/snips.lua b/lua/config/snips.lua deleted file mode 100644 index 2e47b42..0000000 --- a/lua/config/snips.lua +++ /dev/null @@ -1,78 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") -local f = ls.function_node -local s = ls.snippet -local t = ls.text_node -local i = ls.insert_node - ---[[ -local ls = require("luasnip") -local s = ls.snippet -local sn = ls.snippet_node -local isn = ls.indent_snippet_node -local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local c = ls.choice_node -local d = ls.dynamic_node -local r = ls.restore_node -local events = require("luasnip.util.events") -local ai = require("luasnip.nodes.absolute_indexer") -local extras = require("luasnip.extras") -local l = extras.lambda -local rep = extras.rep -local p = extras.partial -local m = extras.match -local n = extras.nonempty -local dl = extras.dynamic_lambda -local fmt = require("luasnip.extras.fmt").fmt -local fmta = require("luasnip.extras.fmt").fmta -local conds = require("luasnip.extras.expand_conditions") -local postfix = require("luasnip.extras.postfix").postfix -local types = require("luasnip.util.types") -local parse = require("luasnip.util.parser").parse_snippet -local ms = ls.multi_snippet -]] - -local shortcut = function(val) - if type(val) == "string" then - return { t({ val }), i(0) } - end - if type(val) == "table" then - for k, v in ipairs(val) do - if type(v) == "string" then - val[k] = t({ v }) - end - end - end - return val -end - -local M = {} - -M.same = function(index) - return f(function(args) - return args[1] - end, { index }) -end - -M.year = function() - return os.date("%Y") -end - -M.date = function() - return os.date("%d.%m.%Y") -end - -M.make = function(tbl) - local result = {} - for k, v in pairs(tbl) do - table.insert(result, (s({ trig = k, desc = v.desc }, shortcut(v)))) - end - return result -end - -return M diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index 7bcfd85..fff7840 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -33,7 +33,13 @@ return { javascript = js, javascriptreact = js, json = { "jq" }, - lua = { "stylua" }, + lua = function() + local config_file = vim.fn.getcwd() .. "/*stylua.toml" + if vim.fn.exists(config_file) then + return { "stylua" } + end + return {} + end, markdown = makrdown, python = { "ruff_format", "ruff_fix", "ruff_organize_imports", "docformatter" }, rest = { "kulala" }, diff --git a/lua/plugins/crates.lua b/lua/plugins/crates.lua index 8f6c6cb..41debd3 100644 --- a/lua/plugins/crates.lua +++ b/lua/plugins/crates.lua @@ -1,6 +1,5 @@ return { { - "Saecki/crates.nvim", tag = "stable", event = { "BufRead Cargo.toml" }, diff --git a/lua/plugins/http-codes.lua b/lua/plugins/http-codes.lua index bbce8e0..84213bf 100644 --- a/lua/plugins/http-codes.lua +++ b/lua/plugins/http-codes.lua @@ -1,7 +1,10 @@ return { - "barrett-ruth/http-codes.nvim", - dependencies = { "folke/snacks.nvim" }, + "kristoferssolo/http-codes.nvim", + branch = "feature/snacks", + dependencies = "folke/snacks.nvim", cmd = "HTTPCodes", - keys = { { "pdh", vim.cmd.HTTPCodes, desc = "HTTP" } }, - config = true, + keys = { { "pH", vim.cmd.HTTPCodes, desc = "HTTP" } }, + opts = { + use = "snacks", + }, } diff --git a/lua/plugins/image.lua b/lua/plugins/image.lua index 7629f1a..710aded 100644 --- a/lua/plugins/image.lua +++ b/lua/plugins/image.lua @@ -2,52 +2,84 @@ local function is_typst() return vim.bo.filetype == "typst" end return { - "HakonHarnes/img-clip.nvim", - event = "VeryLazy", - keys = { - { "v", vim.cmd.PasteImage, desc = "Paste image from system clipboard" }, - }, - opts = { - default = { - dir_path = "assets/img", - extension = function() - if is_typst() then - return "png" - else - return "webp" - end - end, - process_cmd = function() - if is_typst() then - return "" - else - return "convert - -quality 75 webp:-" - end - end, - file_name = "%Y-%m-%d_%H-%M-%S", - relative_to_current_file = false, - prompt_for_file_name = function() - return is_typst() - end, - embed_image_as_base64 = false, - drag_and_drop = { - insert_mode = true, + { + "3rd/image.nvim", + opts = { + backend = "ueberzug", + processor = "magick_rock", + scale_factor = 0.5, + integrations = { + neorg = { + clear_in_insert_mode = true, + only_render_image_at_cursor = true, + only_render_image_at_cursor_mode = "popup", + }, + typst = { + clear_in_insert_mode = true, + only_render_image_at_cursor = true, + only_render_image_at_cursor_mode = "popup", + }, + markdown = { + clear_in_insert_mode = true, + only_render_image_at_cursor = true, + only_render_image_at_cursor_mode = "popup", + resolve_image_path = function(document_path, image_path, fallback) + local working_dir = vim.fn.getcwd() + if working_dir:find("Obsidian") then + return working_dir .. "/assets/img/" .. image_path + end + return fallback(document_path, image_path) + end, + }, }, }, - filetypes = { - markdown = { - template = "![[$FILE_PATH]]", + }, + { + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + keys = { + { "v", vim.cmd.PasteImage, desc = "Paste image from system clipboard" }, + }, + opts = { + default = { + dir_path = "assets/img", + extension = function() + if is_typst() then + return "png" + else + return "webp" + end + end, + process_cmd = function() + if is_typst() then + return "" + else + return "convert - -quality 75 webp:-" + end + end, + file_name = "%Y-%m-%d_%H-%M-%S", + relative_to_current_file = false, + prompt_for_file_name = is_typst, + embed_image_as_base64 = false, + drag_and_drop = { + insert_mode = true, + }, }, - vimwiki = { - template = "![[$FILE_PATH]]", - }, - typst = { - template = [[ + filetypes = { + markdown = { + template = "![[$FILE_PATH]]", + }, + vimwiki = { + template = "![[$FILE_PATH]]", + }, + typst = { + template = [[ #figure( image("$FILE_PATH", width: 80%), caption: [$CURSOR], ) <$LABEL> ]], + }, }, }, }, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 295b805..8e22f03 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -66,7 +66,7 @@ return { vim.lsp.buf.hover({ border = "rounded" }) end, "Hover Documentation") nmap("gi", vim.lsp.buf.implementation, "[G]oto [I]mplementation") - vim.keymap.set("i", "", function() + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help({ border = "rounded" }) end, { buffer = event.buf, desc = "LSP: Signature Documentation" }) nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") @@ -85,7 +85,7 @@ return { vim.diagnostic.jump({ count = -1, float = true }) end, "Diagnostic Prev") nmap("]d", function() - trouble:next({ mode = "diagnostics", skip_groups = true, jump = true }) + trouble.next({ mode = "diagnostics", skip_groups = true, jump = true }) end, "LSP: Trouble Next") nmap("[d", function() trouble.prev({ mode = "diagnostics", skip_groups = true, jump = true }) @@ -99,7 +99,9 @@ return { nmap("gr", function() trouble.toggle("lsp_references") end, "[G]oto [R]eferences") - nmap("gR", function() Snacks.picker.lsp_references() end, "[G]oto [R]eferences") + nmap("gR", function() + Snacks.picker.lsp_references() + end, "[G]oto [R]eferences") end, }) @@ -194,38 +196,42 @@ return { lua_ls = { settings = { Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - }, diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim", "awesome", "client", "ya" }, - }, - -- workspace = { - -- Make the server aware of Neovim runtime files - -- library = vim.api.nvim_get_runtime_file("", true), - -- }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - root_pattern = { - ".stylua.toml", - ".luarc.json", - ".luarc.jsonc", - ".luacheckrc", - "stylua.toml", - "selene.toml", - "selene.yml", - ".git", - }, - format = { - enable = false, - }, - hint = { - enable = true, + globals = { + "vim", + "awesome", + "client", + "s", + "sn", + "isn", + "t", + "i", + "f", + "c", + "d", + "r", + "events", + "k", + "ai", + "extras", + "l", + "rep", + "p", + "m", + "n", + "dl", + "fmt", + "fmta", + "conds", + "postfix", + "types", + "parse", + "ms", + }, }, + telemetry = { enable = false }, + format = { enable = true }, + hint = { enable = true }, }, }, }, diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua index 85e6efc..2ac167a 100644 --- a/lua/plugins/luasnip.lua +++ b/lua/plugins/luasnip.lua @@ -3,20 +3,13 @@ return { "L3MON4D3/LuaSnip", build = "make install_jsregexp", version = "v2.*", - dependencies = { - "rafamadriz/friendly-snippets", -- a bunch of snippets to use - }, + dependencies = { "rafamadriz/friendly-snippets" }, opts = function() local types = require("luasnip.util.types") return { - -- This tells LuaSnip to remember to keep around the last snippet. - -- You can jump back into it even if you move outside of the selection history = true, - -- This one is cool cause if you have dynamic snippets, it updates as you type! updateevents = "TextChanged,TextChangedI", - -- Autosnippets: enable_autosnippets = true, - -- Crazy highlights!! ext_opts = { [types.choiceNode] = { active = { @@ -29,32 +22,6 @@ return { config = function(_, opts) local ls = require("luasnip") - local s = ls.snippet - local sn = ls.snippet_node - local isn = ls.indent_snippet_node - local t = ls.text_node - local i = ls.insert_node - local f = ls.function_node - local c = ls.choice_node - local d = ls.dynamic_node - local r = ls.restore_node - local events = require("luasnip.util.events") - local ai = require("luasnip.nodes.absolute_indexer") - local extras = require("luasnip.extras") - local l = extras.lambda - local rep = extras.rep - local p = extras.partial - local m = extras.match - local n = extras.nonempty - local dl = extras.dynamic_lambda - local fmt = require("luasnip.extras.fmt").fmt - local fmta = require("luasnip.extras.fmt").fmta - local conds = require("luasnip.extras.expand_conditions") - local postfix = require("luasnip.extras.postfix").postfix - local types = require("luasnip.util.types") - local parse = require("luasnip.util.parser").parse_snippet - local ms = ls.multi_snippet - vim.keymap.set({ "i", "s" }, "", function() if ls.expand_or_jumpable() then ls.expand_or_jump() @@ -83,15 +50,11 @@ return { require("luasnip.loaders.from_vscode").load({ exclude = { - "rust", - rust = { - "modtest", - }, + rust = { "modtest" }, }, }) - vim.tbl_map(function(type) - require("luasnip.loaders.from_" .. type).lazy_load() - end, { "vscode", "snipmate", "lua" }) + + require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath("config") .. "/snippets/" }) ls.filetype_extend("typescript", { "tsdoc" }) ls.filetype_extend("javascript", { "jsdoc" }) diff --git a/lua/plugins/obsidian.lua b/lua/plugins/obsidian.lua index 729a606..a926bb6 100644 --- a/lua/plugins/obsidian.lua +++ b/lua/plugins/obsidian.lua @@ -31,7 +31,6 @@ return { desc = "Extract the visually selected text into a new note and link to it.", }, { "Ow", vim.cmd.ObsidianWorkspace, desc = "Switch to another workspace." }, - -- { "Op", vim.cmd.ObsidianPasteImg, desc = "Paste an image from the clipboard into the note." }, { "Or", vim.cmd.ObsidianRename, diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua index 984e83b..0af2474 100644 --- a/lua/plugins/snacks.lua +++ b/lua/plugins/snacks.lua @@ -18,7 +18,7 @@ return { bufdelete = { enabled = true }, dashboard = { enabled = false }, debug = { enabled = true }, - dim = { enabled = true }, + dim = { enabled = false }, explorer = { enabled = false }, git = { enabled = true }, gitbrowse = { enabled = true }, @@ -44,7 +44,7 @@ return { enabled = true, format = "file", layout = { - preset = "telescope" + preset = "telescope", }, matcher = { frecency = true, @@ -57,10 +57,10 @@ return { keys = { [""] = { "trouble_open", - mode = { "n", "i" } - } - } - } + mode = { "n", "i" }, + }, + }, + }, }, }, profiler = { enabled = false }, @@ -116,20 +116,111 @@ return { desc = "Git Blame", }, { - "", function() Snacks.picker.files() end, desc = "Find Files" }, - { "pf", function() Snacks.picker.files() end, desc = "Find Files" }, - { "ps", function() Snacks.picker.grep() end, desc = "Grep" }, - { "pb", function() Snacks.picker.buffers() end, desc = "Buffers" }, - { "pw", function() Snacks.picker.grep_word() end, desc = "Visual selection of word", mode = { "n", "x" } }, - { "pi", function() Snacks.picker.icons() end, desc = "Icons", }, - { "ph", function() Snacks.picker.help() end, desc = "Help Pages", }, - { "pr", function() Snacks.picker.recent() end, desc = "Recent", }, - { "pR", function() Snacks.picker.registers() end, desc = "Registers", }, - { "pg", function() Snacks.picker.git_files() end, desc = "Find Git Fiels", }, - { "pk", function() Snacks.picker.keymaps() end, desc = "Keymaps" }, - { "pt", function() Snacks.picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } }) end, desc = "Todo/Fix/Fixme" }, - { "pc", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" }, - { "pl", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" }, + "", + function() + Snacks.picker.files() + end, + desc = "Find Files", + }, + { + "pf", + function() + Snacks.picker.files() + end, + desc = "Find Files", + }, + { + "ps", + function() + Snacks.picker.grep() + end, + desc = "Grep", + }, + { + "pb", + function() + Snacks.picker.buffers() + end, + desc = "Buffers", + }, + { + "pw", + function() + Snacks.picker.grep_word() + end, + desc = "Visual selection of word", + mode = { "n", "x" }, + }, + { + "pi", + function() + Snacks.picker.icons() + end, + desc = "Icons", + }, + { + "ph", + function() + Snacks.picker.help() + end, + desc = "Help Pages", + }, + { + "pr", + function() + Snacks.picker.recent() + end, + desc = "Recent", + }, + { + "pR", + function() + Snacks.picker.registers() + end, + desc = "Registers", + }, + { + "pg", + function() + Snacks.picker.git_files() + end, + desc = "Find Git Fiels", + }, + { + "pk", + function() + Snacks.picker.keymaps() + end, + desc = "Keymaps", + }, + { + "pt", + function() + Snacks.picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } }) + end, + desc = "Todo/Fix/Fixme", + }, + { + "pc", + function() + Snacks.picker.colorschemes() + end, + desc = "Colorschemes", + }, + { + "pl", + function() + Snacks.picker.lazy() + end, + desc = "Search for Plugin Spec", + }, + { + "pD", + function() + Snacks.picker.diagnostics() + end, + desc = "Diagnostics", + }, }, init = function() vim.api.nvim_create_autocmd("User", { diff --git a/lua/plugins/todo-comments.lua b/lua/plugins/todo-comments.lua index 2a87e0b..0009823 100644 --- a/lua/plugins/todo-comments.lua +++ b/lua/plugins/todo-comments.lua @@ -1,69 +1,5 @@ return { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" }, - opts = { - signs = true, -- show icons in the signs column - sign_priority = 8, -- sign priority - -- keywords recognized as todo comments - keywords = { - FIX = { - icon = " ", -- icon used for the sign, and in search results - color = "error", -- can be a hex color, or a named color (see below) - alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords - -- signs = false, -- configure signs for some keywords individually - }, - TODO = { icon = " ", color = "info" }, - HACK = { icon = " ", color = "warning" }, - WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, - PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, - NOTE = { icon = " ", color = "hint", alt = { "INFO", "HINT" } }, - TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, - }, - gui_style = { - fg = "NONE", -- The gui style to use for the fg highlight group. - bg = "BOLD", -- The gui style to use for the bg highlight group. - }, - - merge_keywords = true, -- when true, custom keywords will be merged with the defaults - -- highlighting of the line containing the todo comment - -- * before: highlights before the keyword (typically comment characters) - -- * keyword: highlights of the keyword - -- * after: highlights after the keyword (todo text) - highlight = { - multiline = true, -- enable multine todo comments - multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword - multiline_context = 10, -- extra lines that will be re-evaluated when changing a line - before = "", -- "fg" or "bg" or empty - keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg) - after = "fg", -- "fg" or "bg" or empty - pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex) - comments_only = true, -- uses treesitter to match keywords in comments only - max_line_len = 400, -- ignore lines longer than this - exclude = {}, -- list of file types to exclude highlighting - }, - -- list of named colors where we try to extract the guifg from the - -- list of highlight groups or use the hex color if hl not found as a fallback - colors = { - error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, - warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, - info = { "DiagnosticInfo", "#2563EB" }, - hint = { "DiagnosticHint", "#10B981" }, - default = { "Identifier", "#7C3AED" }, - test = { "Identifier", "#FF00FF" }, - }, - search = { - command = "rg", - args = { - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - }, - -- regex that will be used to match keywords. - -- don't replace the (KEYWORDS) placeholder - pattern = [[\b(KEYWORDS):]], -- ripgrep regex - -- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives - }, - }, + opts = {}, } diff --git a/lua/plugins/typescript-tools.lua b/lua/plugins/typescript-tools.lua index 789cb71..ab4e556 100644 --- a/lua/plugins/typescript-tools.lua +++ b/lua/plugins/typescript-tools.lua @@ -1,3 +1,4 @@ +local ft = { "javascriptreact", "typescriptreact", "javascript", "typescript" } return { { "pmizio/typescript-tools.nvim", @@ -5,7 +6,7 @@ return { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig", }, - ft = { "javascriptreact", "typescriptreact", "javascript", "typescript" }, + ft = ft, opts = { on_attach = function(client) client.server_capabilities.documentFormattingProvider = false @@ -33,7 +34,7 @@ return { -- memory limit in megabytes or "auto"(basically no limit) tsserver_max_memory = "auto", -- described below - tsserver_format_options = function(ft) + tsserver_format_options = function(_) -- Return empty table to disable formatting return {} end, @@ -72,13 +73,13 @@ return { }, { "dmmulroy/ts-error-translator.nvim", - ft = { "javascriptreact", "typescriptreact", "javascript", "typescript" }, + ft = ft, }, { "folke/ts-comments.nvim", opts = {}, event = "VeryLazy", enabled = vim.fn.has("nvim-0.10.0") == 1, - ft = { "javascriptreact", "typescriptreact", "javascript", "typescript" }, + ft = ft, }, } diff --git a/lua/plugins/typst.lua b/lua/plugins/typst.lua index fad3941..045c4b4 100644 --- a/lua/plugins/typst.lua +++ b/lua/plugins/typst.lua @@ -18,43 +18,5 @@ return { build = function() require("typst-preview").update() end, - opts = { - -- Setting this true will enable printing debug information with print() - debug = false, - - -- Custom format string to open the output link provided with %s - -- Example: open_cmd = 'firefox %s -P typst-preview --class typst-preview' - open_cmd = "xdg-open %s", - -- open_cmd = "floorp %s -P typst-preview --class typst-preview", - - -- Setting this to 'always' will invert black and white in the preview - -- Setting this to 'auto' will invert depending if the browser has enable - -- dark mode - invert_colors = nil, - -- Whether the preview will follow the cursor in the source file - follow_cursor = true, - - -- Provide the path to binaries for dependencies. - -- Setting this will skip the download of the binary by the plugin. - -- Warning: Be aware that your version might be older than the one - -- required. - dependencies_bin = { - -- if you are using tinymist, just set ['typst-preview'] = "tinymist". - ["typst-preview"] = nil, - ["websocat"] = nil, - }, - -- A list of extra arguments (or nil) to be passed to previewer. - -- For example, extra_args = { "--input=ver=draft", "--ignore-system-fonts" } - extra_args = nil, - -- This function will be called to determine the root of the typst project - get_root = function(path_of_main_file) - return vim.fn.fnamemodify(path_of_main_file, ":p:h") - end, - - -- This function will be called to determine the main file of the typst - -- project. - get_main_file = function(path_of_buffer) - return path_of_buffer - end, - }, + opts = {}, } diff --git a/selene.toml b/selene.toml index 0882953..9a02a6a 100644 --- a/selene.toml +++ b/selene.toml @@ -2,6 +2,7 @@ std = "neovim" [rules] global_usage = "allow" +undefined_variable = "allow" multiple_statements = "allow" incorrect_standard_library_use = "allow" mixed_table = "allow" diff --git a/snippets/all.lua b/snippets/all.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/snippets/all.lua @@ -0,0 +1 @@ +return {} diff --git a/snippets/c.lua b/snippets/c.lua new file mode 100644 index 0000000..659c9a1 --- /dev/null +++ b/snippets/c.lua @@ -0,0 +1,3 @@ +---@diagnostic disable: undefined-global + +return {} diff --git a/snippets/cmake.lua b/snippets/cmake.lua new file mode 100644 index 0000000..659c9a1 --- /dev/null +++ b/snippets/cmake.lua @@ -0,0 +1,3 @@ +---@diagnostic disable: undefined-global + +return {} diff --git a/snippets/cpp.lua b/snippets/cpp.lua new file mode 100644 index 0000000..659c9a1 --- /dev/null +++ b/snippets/cpp.lua @@ -0,0 +1,3 @@ +---@diagnostic disable: undefined-global + +return {} diff --git a/after/plugin/snips/lua.lua b/snippets/lua.lua similarity index 59% rename from after/plugin/snips/lua.lua rename to snippets/lua.lua index 2b903c1..b5f51c7 100644 --- a/after/plugin/snips/lua.lua +++ b/snippets/lua.lua @@ -1,22 +1,4 @@ -if not pcall(require, "luasnip") then - return -end - -local ls = require("luasnip") - -local s = ls.snippet -local sn = ls.sn -local i = ls.insert_node -local t = ls.text_node -local d = ls.dynamic_node -local c = ls.choice_node -local fmt = require("luasnip.extras.fmt").fmt - -local shared = require("config.snips") - -local newline = function(text) - return t({ "", text }) -end +---@diagnostic disable: undefined-global local require_var = function(args, _) local text = args[1][1] or "" @@ -32,12 +14,12 @@ local require_var = function(args, _) }) end -ls.add_snippets("lua", { +return { s( "lf", fmt( [[ - local {} = function({}) + local function {}({}) {} end{} ]], @@ -70,4 +52,4 @@ ls.add_snippets("lua", { i(1), }) ), -}) +} diff --git a/after/plugin/snips/markdown.lua b/snippets/markdown.lua similarity index 57% rename from after/plugin/snips/markdown.lua rename to snippets/markdown.lua index 0d6dba9..659ffed 100644 --- a/after/plugin/snips/markdown.lua +++ b/snippets/markdown.lua @@ -1,13 +1,6 @@ -if not pcall(require, "luasnip") then - return -end +---@diagnostic disable: undefined-global -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local fmt = require("luasnip.extras.fmt").fmt - -ls.add_snippets("markdown", { +return { s( "ket", fmt( @@ -47,4 +40,4 @@ ls.add_snippets("markdown", { {} ) ), -}) +} diff --git a/after/plugin/snips/python.lua b/snippets/python.lua similarity index 73% rename from after/plugin/snips/python.lua rename to snippets/python.lua index fb55dc3..a318d3b 100644 --- a/after/plugin/snips/python.lua +++ b/snippets/python.lua @@ -1,15 +1,6 @@ -if not pcall(require, "luasnip") then - return -end +---@diagnostic disable: undefined-global -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local t = ls.text_node -local fmt = require("luasnip.extras.fmt").fmt -local c = ls.choice_node - -ls.add_snippets("python", { +return { s( "logger", fmt( @@ -97,4 +88,17 @@ ls.add_snippets("python", { } ) ), -}) +}, { + s( + "__", + fmta( + [[ + ____<> + ]], + { + init = i(1), + i(0), + } + ) + ), +} diff --git a/snippets/rust.lua b/snippets/rust.lua new file mode 100644 index 0000000..19862ac --- /dev/null +++ b/snippets/rust.lua @@ -0,0 +1,233 @@ +---@diagnostic disable: undefined-global + +local snippets = { + s("p", fmta([[println!("{}", <>)]], { i(0) })), + s( + "modtest", + fmta( + [[ + #[cfg(test)] + mod tests { + use super::*; + + <> + } + ]], + { i(0) } + ) + ), + s( + "test", + fmta( + [[ + #[test] + fn () { + + } + ]], + { + name = i(1), + body = i(0), + } + ) + ), + s( + "rstest", + fmta( + [[ + #[rstest] + #[case()] + fn () { + + } + ]], + { + name = i(1), + args = i(2), + case = i(3), + body = i(0), + } + ) + ), + s( + "tmain", + fmt( + [[ + #[tokio::main] + async fn main() -> Result<()> {{ + {} + }} + ]], + { + i(1, "todo!();"), + } + ) + ), + s( + "dead", + fmt( + [[ + #[allow(dead_code)] + ]], + {} + ) + ), +} + +local function has_bevy() + local cwd = vim.fn.getcwd() + local cargo_toml = cwd .. "/Cargo.toml" + + if vim.fn.filereadable(cargo_toml) == 1 then + local contents = vim.fn.readfile(cargo_toml) + for _, line in ipairs(contents) do + if line:match("^%s*bevy%s*=") or line:find("bevy") and not line:find("bevy%.") then + return true + end + end + end + + return false +end + +local bevy_snippets = { + s( + "component", + fmta( + [[ + #[derive(Debug, Reflect, Component)] + #[reflect(Component)] + pub struct + ]], + { + name = i(1, "Component"), + params = c(2, { + t(";"), + t("( );"), + t(" { }"), + }), + } + ) + ), + s( + "event", + fmta( + [[ + #[derive(Debug, Event)] + pub struct + ]], + { + name = i(1, "Event"), + params = c(2, { + t(";"), + t("( );"), + t(" { }"), + }), + } + ) + ), + s( + "resource", + fmta( + [[ + #[derive(Debug, Default, Reflect, Resource)] + #[reflect(Resource)] + pub struct + ]], + { + name = i(1, "Resource"), + params = c(2, { + t(";"), + t("( );"), + t(" { }"), + }), + } + ) + ), + s( + "schedule", + fmta( + [[ + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ScheduleLabel)] + pub struct + ]], + { + name = i(1, "Resource"), + params = c(2, { + t(";"), + t("( );"), + t(" { }"), + }), + } + ) + ), + s( + "state", + fmta( + [[ + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, States)] + pub enum { + #[default] + , + + } + ]], + { + name = i(1, "State"), + default = i(2, "Default"), + variants = i(0), + } + ) + ), + s( + "systemset", + fmta( + [[ + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)] + pub enum { + + } + ]], + { + name = i(1), + body = i(2), + } + ) + ), + s( + "plugin", + fmta( + [[ + use bevy::prelude::*; + + pub(super) fn plugin(app: &mut App) { + + } + ]], + { + body = i(0), + } + ) + ), + s( + "query", + fmta( + [[ + fn () { + + } + ]], + { + name = i(1, "sytem"), + args = i(2, "args"), + body = i(0), + } + ) + ), +} + +if has_bevy() then + vim.tbl_extend("force", snippets, bevy_snippets) +end + +return snippets diff --git a/snippets/typst.lua b/snippets/typst.lua new file mode 100644 index 0000000..077422d --- /dev/null +++ b/snippets/typst.lua @@ -0,0 +1,33 @@ +---@diagnostic disable: undefined-global + +return { + s( + { trig = "([^%s]+)t", name = "Superscript", regTrig = true }, + fmta("(<>)^(<>)", { + f(function(_, snip) + return snip.captures[1] + end), + i(0), + }) + ), + s( + { trig = "([^%s]+)b", name = "Subscript", regTrig = true }, + fmta("(<>)_(<>)", { + f(function(_, snip) + return snip.captures[1] + end), + i(0), + }) + ), + s( + { trig = "([^%s]+)r", name = "Root", regTrig = true }, + fmta("sqrt(<>)", { + f(function(_, snip) + return snip.captures[1] + end), + }) + ), +}, { -- autosnippets + s({ trig = "mt", name = "Math Block" }, fmta("$<>$", { i(1) })), + s({ trig = "mmt", name = "Multiline Math Block" }, fmta("$ <> $", { i(1) })), +} diff --git a/spell/lv.utf-8.add b/spell/lv.utf-8.add index dc8ecbd..60de8e2 100644 --- a/spell/lv.utf-8.add +++ b/spell/lv.utf-8.add @@ -627,3 +627,5 @@ saprotami iekavās iekavām viennozīmīgu +iekavas +atbilsoši diff --git a/spell/lv.utf-8.add.spl b/spell/lv.utf-8.add.spl index 1fbd4fccecef5a8846c4ab65c45186c33ca3437a..b2102f519e58ed3fe6fe1d6e3511b9abe4e7f083 100644 GIT binary patch delta 3414 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 diff --git a/stylua.toml b/stylua.toml deleted file mode 100644 index 9984e42..0000000 --- a/stylua.toml +++ /dev/null @@ -1,10 +0,0 @@ -column_width = 120 -line_endings = "Unix" -indent_type = "Tabs" -indent_width = 4 -quote_style = "AutoPreferDouble" -call_parentheses = "Always" -collapse_simple_statement = "Never" - -[sort_requires] -enabled = false