refactor: rename variable rootilities to utils
This commit is contained in:
+53
-19
@@ -3,7 +3,7 @@
|
|||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local rootilities = require("utils.rootiest")
|
local utils = require("utils.rootiest")
|
||||||
|
|
||||||
local precog_first_time = true
|
local precog_first_time = true
|
||||||
|
|
||||||
@@ -21,7 +21,9 @@ end
|
|||||||
-- Toggle the precognition plugin
|
-- Toggle the precognition plugin
|
||||||
function M.toggle_precognition()
|
function M.toggle_precognition()
|
||||||
if pcall(require, "precognition") then
|
if pcall(require, "precognition") then
|
||||||
|
-- Initialize precognition plugin
|
||||||
local precognition = require("precognition")
|
local precognition = require("precognition")
|
||||||
|
-- Toggle the plugin
|
||||||
if precog_first_time then
|
if precog_first_time then
|
||||||
precognition.toggle()
|
precognition.toggle()
|
||||||
precognition.toggle() -- Call toggle twice
|
precognition.toggle() -- Call toggle twice
|
||||||
@@ -34,7 +36,7 @@ function M.toggle_precognition()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Toggle Hardtime and Precognition
|
-- Toggle Hardtime and Precognition together
|
||||||
function M.toggle_hardmode()
|
function M.toggle_hardmode()
|
||||||
if pcall(require, "hardtime") then
|
if pcall(require, "hardtime") then
|
||||||
local hardtime = require("hardtime")
|
local hardtime = require("hardtime")
|
||||||
@@ -75,35 +77,60 @@ end
|
|||||||
-- Set cursor icons
|
-- Set cursor icons
|
||||||
function M.set_cursor_icons()
|
function M.set_cursor_icons()
|
||||||
local current_mode = vim.fn.mode()
|
local current_mode = vim.fn.mode()
|
||||||
local bg_color
|
local bg_color -- Define bg_color variable
|
||||||
|
if current_mode == "n" then -- Normal
|
||||||
if current_mode == "n" then
|
bg_color = utils.get_bg_color("MiniStatuslineModeNormal")
|
||||||
bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal")
|
|
||||||
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "v" then
|
elseif current_mode == "v" then -- Visual
|
||||||
bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual")
|
bg_color = utils.get_bg_color("MiniStatuslineModeVisual")
|
||||||
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "V" then
|
elseif current_mode == "V" then -- Visual line
|
||||||
bg_color = rootilities.get_bg_color("MiniStatuslineModeVisual")
|
bg_color = utils.get_bg_color("MiniStatuslineModeVisual")
|
||||||
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "R" or current_mode == "r" then
|
elseif current_mode == "R" or current_mode == "r" then -- Replace
|
||||||
bg_color = rootilities.get_bg_color("MiniStatuslineModeReplace")
|
bg_color = utils.get_bg_color("MiniStatuslineModeReplace")
|
||||||
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
elseif current_mode == "i" then
|
elseif current_mode == "i" then -- Insert
|
||||||
bg_color = rootilities.get_bg_color("MiniStatuslineModeInsert")
|
bg_color = utils.get_bg_color("MiniStatuslineModeInsert")
|
||||||
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
else
|
else -- Other\Unknown
|
||||||
bg_color = rootilities.get_bg_color("MiniStatuslineModeNormal")
|
bg_color = utils.get_bg_color("MiniStatuslineModeNormal")
|
||||||
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = bg_color })
|
||||||
vim.fn.sign_define("smoothcursor", { text = "" })
|
vim.fn.sign_define("smoothcursor", { text = "" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.YankAndPasteInQuotes()
|
||||||
|
-- Yank text inside quotes on the current line
|
||||||
|
vim.cmd("normal! yiq")
|
||||||
|
|
||||||
|
-- Get the yanked text from the "0 register (the unnamed register)
|
||||||
|
local yanked_text = vim.fn.getreg('"')
|
||||||
|
|
||||||
|
-- List of marks to check ('a' to 'z')
|
||||||
|
local marks = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
|
-- Loop through each mark
|
||||||
|
for mark in marks:gmatch(".") do
|
||||||
|
-- Check if the mark exists (returns the line number or nil)
|
||||||
|
local position = vim.fn.getpos("'" .. mark)
|
||||||
|
|
||||||
|
if position[1] ~= 0 then
|
||||||
|
-- Go to the mark
|
||||||
|
vim.cmd("normal! '" .. mark)
|
||||||
|
|
||||||
|
-- Select text inside quotes and paste the yanked text
|
||||||
|
vim.cmd("normal! viq")
|
||||||
|
vim.cmd('normal! "' .. yanked_text .. "P")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Evaluate Neovide settings
|
-- Evaluate Neovide settings
|
||||||
function M.eval_neovide()
|
function M.eval_neovide()
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
@@ -113,18 +140,25 @@ end
|
|||||||
|
|
||||||
-- Define user commands
|
-- Define user commands
|
||||||
function M.define_commands()
|
function M.define_commands()
|
||||||
vim.api.nvim_create_user_command("Q", function()
|
-- Define Q abbreviation
|
||||||
vim.cmd.qall()
|
vim.cmd.cnoreabbrev("Q", "qall")
|
||||||
end, { force = true, desc = "Close all buffers" })
|
|
||||||
|
|
||||||
|
-- Define yank line command
|
||||||
vim.api.nvim_create_user_command("YankLine", function()
|
vim.api.nvim_create_user_command("YankLine", function()
|
||||||
M.yank_line()
|
M.yank_line()
|
||||||
end, { force = true, desc = "Yank line without leading whitespace" })
|
end, { force = true, desc = "Yank line without leading whitespace" })
|
||||||
|
vim.api.nvim_create_user_command(
|
||||||
|
"YankAndPasteQuotes",
|
||||||
|
M.YankAndPasteInQuotes,
|
||||||
|
{}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set up module
|
||||||
function M.setup()
|
function M.setup()
|
||||||
M.eval_neovide()
|
M.eval_neovide()
|
||||||
M.define_commands()
|
M.define_commands()
|
||||||
|
require("data.types").setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user