diff --git a/custom_snippets/all_mine.snippets b/custom_snippets/all_mine.snippets deleted file mode 100644 index a17a6d5..0000000 --- a/custom_snippets/all_mine.snippets +++ /dev/null @@ -1,37 +0,0 @@ -priority -55 - -global !p -from vimsnippets import foldmarker, make_box, get_comment_format -endglobal - - -################ -# ANSI Color Codes # -################ - -# The table starts with the original 16 colors (0-15). - -# The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by -# 16, packed into a single value. - -# The final 24 colors (232-256) are grayscale -# starting from a shade slighly lighter than black, ranging up to shade slightly -# darker than white. - -# Some emulators interpret these steps as linear -# increments from (256 / 24) on all three channels, although some emulators may -# explicitly define these values. - -snippet ansi_fg "Foreground ANSI 256 Color Code" i -\033[38;5;${1:00}m -endsnippet - -snippet ansi_bg "Background ANSI 256 Color Code" i -\033[48;5;${1:00}m -endsnippet - -snippet ansi_reset "Reset ANSI 256 Color Code" i -\033[0m -endsnippet - - diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index a22bacd..d51f400 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -17,6 +17,9 @@ M.ui = { theme = "monekai", theme_toggle = { "monekai", "gruvbox_light" }, hl_override = { + Comment = { + fg = "light_grey" + }, CursorLine = { bg = "one_bg3" }, @@ -109,9 +112,16 @@ M.ui = { fg = "purple" }, LuaSnipChoice = { - fg = "sun", + fg = "yellow", bg = "one_bg3", }, + LuaSnipInsert = { + fg = "teal", + -- bg = "one_bg3", + }, + NvimDapVirtualText = { + fg = '#f99540' + } }, -- hl_override = { diff --git a/lua/custom/plugins/configs/luasnip.lua b/lua/custom/plugins/configs/luasnip.lua index d92150c..be6aa8a 100644 --- a/lua/custom/plugins/configs/luasnip.lua +++ b/lua/custom/plugins/configs/luasnip.lua @@ -9,10 +9,16 @@ local types = require("luasnip.util.types") local options = { history = true, updateevents = "TextChanged,TextChangedI", + enable_autosnippets = true, ext_opts = { [types.choiceNode] = { passive = { - virt_text = { { " ", "LuaSnipChoice" } }, + virt_text = { { " ", "LuaSnipChoice" } }, + } + }, + [types.insertNode] = { + passive = { + virt_text = { { " ", "LuaSnipInsert" } }, } } }, diff --git a/lua/custom/plugins/configs/todo-comments.lua b/lua/custom/plugins/configs/todo-comments.lua index 476a69f..1160d3e 100644 --- a/lua/custom/plugins/configs/todo-comments.lua +++ b/lua/custom/plugins/configs/todo-comments.lua @@ -10,6 +10,7 @@ local config = { keywords = { ["_TODO"] = { color = "warning"}, ["LEARN"] = { color = "hint" }, + ["WIP"] = { color = "default"}, }, colors = { info = {"#2563EB"}, diff --git a/lua/custom/plugins/nvchadui.lua b/lua/custom/plugins/nvchadui.lua index 60e7d04..54e2334 100644 --- a/lua/custom/plugins/nvchadui.lua +++ b/lua/custom/plugins/nvchadui.lua @@ -50,7 +50,7 @@ return { local mode_sep1 = "%#" .. modes[m][2] .. "Sep" .. "#" .. sep_r if is_dapmode() then - local dap_mode = "%#St_DapMode#DEBUG" .. "%#St_DapModeSep#" + local dap_mode = "%#St_DapMode#DAP" .. "%#St_DapModeSep#" return current_mode .. mode_sep1 .. "%#St_DapModeSep2#" .. sep_r .. dap_mode .. sep_r end diff --git a/lua/spike/dap/dapmode.lua b/lua/spike/dap/dapmode.lua index 01aa884..8dd131b 100644 --- a/lua/spike/dap/dapmode.lua +++ b/lua/spike/dap/dapmode.lua @@ -16,6 +16,12 @@ local config = { end, desc = '[dap] conditional breakpoint', }, + X = { + rhs = function() + require('dap').clear_breakpoints() + end, + desc = '[dap] clear all breakpoints' + }, c = { rhs = function() require('dap').continue() @@ -86,16 +92,43 @@ local config = { M.layer:exit() end, desc = '[dap] exit dap mode' - } + }, +-- WIP: use which-key for key mappings help + -- ["?"] = { + -- rhs = function() + -- local wk = require("which-key") + -- wk.show("?", "n") + -- end + -- } } } } +M.config = config + +-- WIP: use which-key for key mappings help +-- local function wk_reg_keys() +-- local wk = require("which-key") +-- local wk_dapmode = { +-- name = "dap", -- section name +-- } +-- local wk_opts = { +-- mode = "n", +-- prefix = "?", +-- -- noremap = true, +-- } +-- for key, data in pairs(config.mappings.n) do +-- wk_dapmode[key] = { data.desc } +-- end +-- wk.register(wk_dapmode, wk_opts) +-- end + function M.start() if M.layer == nil then M.layer = libmodal.layer.new(config.mappings) end + -- wk_reg_keys() M.layer:enter() end diff --git a/lua/spike/lsp/init.lua b/lua/spike/diagnostics.lua similarity index 88% rename from lua/spike/lsp/init.lua rename to lua/spike/diagnostics.lua index b7491f0..7338764 100644 --- a/lua/spike/lsp/init.lua +++ b/lua/spike/diagnostics.lua @@ -2,13 +2,13 @@ M = {} M.shown = true -- toggle diagnostics with show/hide -M.toggle_diagnostics = function () +M.toggle = function () if M.shown then M.shown = false return vim.diagnostic.hide() end - vim.diagnostic.show() M.shown = true + vim.diagnostic.show() end -- my customized attach diff --git a/lua/spike/luasnip/ft/lua.lua b/lua/spike/luasnip/ft/lua.lua new file mode 100644 index 0000000..b4ece20 --- /dev/null +++ b/lua/spike/luasnip/ft/lua.lua @@ -0,0 +1,33 @@ +---@diagnostic disable: unused-local + +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep +-- local isn = ls.indent_snippet_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 m = extras.m +-- local l = extras.l +-- local rep = extras.rep +-- local postfix = require("luasnip.extras.postfix").postfix +-- +-- add_snippet helper +local add_snippet = require("spike.snips").add_snippet + + +--HACK: remove after testing snippets or it resets all imported snippets +-- require("luasnip.session.snippet_collection").clear_snippets "lua" + +add_snippet { + lua = { + } +} diff --git a/lua/spike/luasnip/init.lua b/lua/spike/luasnip/init.lua new file mode 100644 index 0000000..622fe6c --- /dev/null +++ b/lua/spike/luasnip/init.lua @@ -0,0 +1,17 @@ +local ok, ls = pcall(require, "luasnip") +if not ok then return end + +-- luasnip helpers + +local M = {} + +---shortcut for ls.add_snippet(ft, {defs}) +---@param args table arguments in the form {ft, snippet_defs} +M.add_snippet = function(args) + for ft,sn_defs in pairs(args) do + ls.add_snippets(ft, sn_defs, {override_priority=2000}) + end +end + + +return M diff --git a/mysnippets/all.lua b/mysnippets/all.lua new file mode 100644 index 0000000..42bb3d7 --- /dev/null +++ b/mysnippets/all.lua @@ -0,0 +1,20 @@ +---@diagnostic disable: undefined-global + +return { + -- s("sniptest", { + -- t"hello snippet" + -- }) + -- + + -- choice nodes + s("choice", fmt("{} my {}",{ + c(2, {t("hello"), t("hi")}), + c(1, {t"bob", t"alice"}) + }) + ), + + -- function node + s("pwd", f(function() + return vim.fn.getcwd() + end)) +} diff --git a/mysnippets/go.lua b/mysnippets/go.lua new file mode 100644 index 0000000..35f995f --- /dev/null +++ b/mysnippets/go.lua @@ -0,0 +1,7 @@ +---@diagnostic disable: unused-local, undefined-global + +return { + -- s("testgo", { + -- t"Hello go snippet" + -- }) +} diff --git a/custom_snippets/go.snippets b/mysnippets/go.snippets similarity index 100% rename from custom_snippets/go.snippets rename to mysnippets/go.snippets diff --git a/mysnippets/lua.lua b/mysnippets/lua.lua new file mode 100644 index 0000000..3f51c0f --- /dev/null +++ b/mysnippets/lua.lua @@ -0,0 +1,34 @@ +---@diagnostic disable: undefined-global + +return { + + s("testluasnip", { + t"Hello lua snippet" + }), + + + -- repeat nodes + -- TODO: split dot and pull last name + s("req", fmt("local {} = require('{}')", { + i(1, "default"), + rep(1) + }) ), + + s("ifreq", fmt([[ + local ok, {} = pcall(require, "{}") + if not ok then + vim.notify("missing module {}", vim.log.levels.WARN) + return + end + {} + ]], { + i(1), + rep(1), + rep(1), + i(0) + }) + + ), + + +} diff --git a/custom_snippets/lua.snippets b/mysnippets/lua.snippets similarity index 100% rename from custom_snippets/lua.snippets rename to mysnippets/lua.snippets diff --git a/custom_snippets/markdown_btw.snippets b/mysnippets/markdown_btw.snippets similarity index 100% rename from custom_snippets/markdown_btw.snippets rename to mysnippets/markdown_btw.snippets diff --git a/custom_snippets/rust.snippets b/mysnippets/rust.snippets similarity index 100% rename from custom_snippets/rust.snippets rename to mysnippets/rust.snippets