🐛 fix(multiplatform): adjustments to support multiple platforms
This commit is contained in:
+19
-5
@@ -16,33 +16,47 @@ local data = require("data")
|
||||
local add_keymap = data.func.add_keymap
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━ General Keybinds ━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
-- Add keymaps for miscellaneous keybinds
|
||||
for _, item in ipairs(data.keys.misc) do
|
||||
add_keymap(item)
|
||||
end
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Group Keybinds ━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
-- Add keymaps for menu groups
|
||||
for _, item in ipairs(data.keys.groups) do
|
||||
add_keymap(item)
|
||||
end
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Resizing splits ━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
-- Add keymaps for resizing splits
|
||||
for _, map in ipairs(data.keys.splits.resize) do
|
||||
add_keymap(map[1], map[2], map[3], data.types.all_modes)
|
||||
end
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━ Moving between splits ━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
-- Add keymaps for moving between splits
|
||||
for _, map in ipairs(data.keys.splits.move) do
|
||||
add_keymap(map[1], map[2], map[3], data.types.all_modes)
|
||||
end
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━ Swapping buffers between windows ━━━━━━━━━━━━━━━
|
||||
|
||||
-- Add keymaps for swapping buffers
|
||||
for _, map in ipairs(data.keys.splits.swap) do
|
||||
add_keymap(map[1], map[2], map[3], data.types.all_modes)
|
||||
end
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Overrides ━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- Add keymaps for overrides
|
||||
add_keymap(data.keys.overrides)
|
||||
|
||||
add_keymap("<leader>qP", function()
|
||||
data.func.InputPrompt("Enter your name: ", function(input)
|
||||
if input then
|
||||
-- trim whitespace from end of input
|
||||
input = input:gsub("%s+$", "")
|
||||
print("👋😎 Hello " .. input .. "!")
|
||||
else
|
||||
print("Input was canceled")
|
||||
end
|
||||
end)
|
||||
end, "Test Prompt")
|
||||
|
||||
+53
-30
@@ -7,30 +7,42 @@
|
||||
-- ╰─────────────────────────────────────────────────────────╯
|
||||
-- stylua: ignore start
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Leader Key ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.mapleader = " " ---@type string Options: <leader>
|
||||
vim.g.maplocalleader = " " ---@type string Options: <localleader>
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Key Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.mapleader = " " ---@type string Options: <leader>
|
||||
vim.g.maplocalleader = " " ---@type string Options: <localleader>
|
||||
-- vim.g.timeoutlen = 1000 ---@type integer Options: <ms>
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LSP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- We don't need perl
|
||||
vim.g.loaded_perl_provider = 0 ---@type integer Options: <0|1>
|
||||
vim.g.loaded_ruby_provider = 0 ---@type integer Options: <0|1>
|
||||
-- Prefer basedpyright
|
||||
vim.g.lazyvim_python_lsp = "basedpyright" ---@type string Options: [python lsp]
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- Check if we are on windows
|
||||
vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
|
||||
vim.g.loaded_perl_provider = 0 ---@type integer Options: <0|1>
|
||||
-- or ruby
|
||||
vim.g.loaded_ruby_provider = 0 ---@type integer Options: <0|1>
|
||||
-- Prefer basedpyright for python
|
||||
vim.g.lazyvim_python_lsp = "basedpyright" ---@type string Options: [python lsp]
|
||||
-- Open all folds by default
|
||||
vim.opt.foldlevel = 99 ---@type integer Options: <0-99>
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- Use WakaTime for code stats
|
||||
vim.g.usewakatime = true ---@type boolean Options: <true|false>
|
||||
vim.g.usemusic = true ---@type boolean Options: <true|false>
|
||||
-- Allow music controls and stats
|
||||
vim.g.usemusic = false ---@type boolean Options: <true|false>
|
||||
-- Enable HardTime on startup
|
||||
vim.g.usehardtime = false ---@type boolean Options: <true|false>
|
||||
-- Enable Image plugin on compatible terminals
|
||||
vim.g.useimage = true ---@type boolean Options: <true|false>
|
||||
-- Ignore missing lazy.nvim plugin manager
|
||||
vim.g.ignore_no_lazy = false ---@type boolean Options: <true|false>
|
||||
-- Enable codesnap for code screenshots
|
||||
vim.g.codesnap = true ---@type boolean Options: <true|false>
|
||||
-- Enable Auto-hiding cursorline
|
||||
vim.g.auto_cursorline = true ---@type boolean Options: <true|false>
|
||||
-- Enable Auto-save
|
||||
vim.g.auto_save = true ---@type boolean Options: <true|false>
|
||||
-- Animate blinky cursor
|
||||
vim.g.blinky = true ---@type boolean Options: <true|false>
|
||||
-- Use Rootiest cmd window instead of cmdline
|
||||
vim.g.rootiest_cmd = false ---@type boolean Options: <true|false>
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ AI TOOL ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.aitool = "codeium" ---@type string Options: [ai tool]
|
||||
@@ -42,15 +54,6 @@ vim.g.aitool = "codeium" ---@type string Options: [ai tool]
|
||||
-- │ │ none
|
||||
-- ╰───────────────────────────╯
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.statusline = "lualine" ---@type string Options: [statusline]
|
||||
-- ╭───────────────────────────╮ lualine
|
||||
-- │ │ heirline
|
||||
-- │ Status Lines: │ basic
|
||||
-- │ Choose a plugin from │ none
|
||||
-- │ the list │
|
||||
-- │ │
|
||||
-- ╰───────────────────────────╯
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS COLUMN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn]
|
||||
-- ╭───────────────────────────╮ barsNlines
|
||||
@@ -60,8 +63,9 @@ vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn]
|
||||
-- │ the list │
|
||||
-- │ │
|
||||
-- ╰───────────────────────────╯
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BUFFER LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.tabline = "bufferline" ---@type string Options: [tabline]
|
||||
vim.g.tabline = "none" ---@type string Options: [tabline]
|
||||
-- ╭───────────────────────────╮ bufferline
|
||||
-- │ │ barsNlines
|
||||
-- │ Tab Lines: │ none
|
||||
@@ -69,17 +73,32 @@ vim.g.tabline = "bufferline" ---@type string Options: [tabline]
|
||||
-- │ the list │
|
||||
-- │ │
|
||||
-- ╰───────────────────────────╯
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
vim.g.statusline = "lualine" ---@type string Options: [statusline]
|
||||
-- ╭───────────────────────────╮ lualine
|
||||
-- │ │ heirline
|
||||
-- │ Status Lines: │ barsNlines
|
||||
-- │ Choose a plugin from │ basic
|
||||
-- │ the list │ none
|
||||
-- │ │
|
||||
-- ╰───────────────────────────╯
|
||||
--
|
||||
-- Click git components on statusline to open LazyGit
|
||||
vim.g.statusline_clickable_git = false ---@type boolean Options: <true|false>
|
||||
-- Show wakatime stats on statusline
|
||||
vim.g.stats_wakatime = true ---@type boolean Options: <true|false>
|
||||
-- Show music stats on statusline
|
||||
vim.g.stats_music = true ---@type boolean Options: <true|false>
|
||||
-- Ignored player sources for music stats
|
||||
vim.g.stats_ignored_players = { ---@type string[] Options: [ignored players]
|
||||
"chromium",
|
||||
"firefox",
|
||||
"kdeconnect",
|
||||
"haruna",
|
||||
"plasma-browser-integration",
|
||||
"plasma-browser-integration-76042",
|
||||
}
|
||||
"chromium",
|
||||
"firefox",
|
||||
"kdeconnect",
|
||||
"haruna",
|
||||
"plasma-browser-integration",
|
||||
"plasma-browser-integration-76042",
|
||||
}
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COLOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- Background color
|
||||
@@ -91,5 +110,9 @@ vim.g.disable_transparency = true ---@type boolean Options: <true|false>
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Completion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- Cmp Window Border
|
||||
vim.g.completion_round_borders_enabled = true ---Options: <true|false>
|
||||
vim.g.completion_round_borders_enabled = true ---@type boolean Options: <true|false>
|
||||
|
||||
-- stylua: ignore end
|
||||
|
||||
-- Post-Config Operations
|
||||
require("config.post-ops")
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---@module "config.post_ops"
|
||||
--- This module contains the functions that exectute after
|
||||
--- the options.lua file has been loaded.
|
||||
-- ╭─────────────────────────────────────────────────────────╮
|
||||
-- │ Post Ops │
|
||||
-- ╰─────────────────────────────────────────────────────────╯
|
||||
|
||||
local M = {}
|
||||
|
||||
M.apply_options = function()
|
||||
-- Setup blinky cursor
|
||||
require("utils.blinky").setup(vim.g.blinky)
|
||||
|
||||
-- Setup Rootiest cmd window
|
||||
require("utils.cmd_window").setup({
|
||||
override_cmdline = vim.g.rootiest_cmd and true or nil,
|
||||
})
|
||||
end
|
||||
|
||||
-- Setup post-ops module
|
||||
M.setup = function()
|
||||
M.apply_options()
|
||||
end
|
||||
|
||||
-- Call setup
|
||||
M.setup()
|
||||
|
||||
return M
|
||||
+100
-60
@@ -7,80 +7,118 @@
|
||||
local M = {}
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━ Bootstrap rocks.nvim ━━━━━━━━━━━━━━━━━━━━━
|
||||
do
|
||||
local rocks_config = {
|
||||
rocks_path = vim.env.HOME .. "/.local/share/nvim/rocks",
|
||||
}
|
||||
function M.bootstrap()
|
||||
do
|
||||
local rocks_config = {
|
||||
rocks_path = vim.env.HOME .. "/.local/share/nvim/rocks",
|
||||
}
|
||||
|
||||
vim.g.rocks_nvim = rocks_config
|
||||
vim.g.rocks_nvim = rocks_config
|
||||
|
||||
local luarocks_path = {
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"),
|
||||
vim.fs.joinpath(
|
||||
rocks_config.rocks_path,
|
||||
"share",
|
||||
"lua",
|
||||
"5.1",
|
||||
"?",
|
||||
"init.lua"
|
||||
),
|
||||
}
|
||||
package.path = package.path .. ";" .. table.concat(luarocks_path, ";")
|
||||
local luarocks_path = {
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"),
|
||||
vim.fs.joinpath(
|
||||
rocks_config.rocks_path,
|
||||
"share",
|
||||
"lua",
|
||||
"5.1",
|
||||
"?",
|
||||
"init.lua"
|
||||
),
|
||||
}
|
||||
package.path = package.path .. ";" .. table.concat(luarocks_path, ";")
|
||||
|
||||
local luarocks_cpath = {
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"),
|
||||
-- Remove the dylib and dll paths if you do not need macos or windows support
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dylib"),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dylib"),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dll"),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dll"),
|
||||
}
|
||||
package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";")
|
||||
local luarocks_cpath = {
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"),
|
||||
-- Remove the dylib and dll paths if you do not need macos or windows support
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dylib"),
|
||||
vim.fs.joinpath(
|
||||
rocks_config.rocks_path,
|
||||
"lib64",
|
||||
"lua",
|
||||
"5.1",
|
||||
"?.dylib"
|
||||
),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dll"),
|
||||
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dll"),
|
||||
}
|
||||
package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";")
|
||||
|
||||
vim.opt.runtimepath:append(
|
||||
vim.fs.joinpath(
|
||||
rocks_config.rocks_path,
|
||||
"lib",
|
||||
"luarocks",
|
||||
"rocks-5.1",
|
||||
"rocks.nvim",
|
||||
"*"
|
||||
vim.opt.runtimepath:append(
|
||||
vim.fs.joinpath(
|
||||
rocks_config.rocks_path,
|
||||
"lib",
|
||||
"luarocks",
|
||||
"rocks-5.1",
|
||||
"rocks.nvim",
|
||||
"*"
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
-- If rocks.nvim is not installed then install it!
|
||||
if not pcall(require, "rocks") then
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
local rocks_location = vim.fs.joinpath(vim.fn.stdpath("cache"), "rocks.nvim")
|
||||
|
||||
if not vim.uv.fs_stat(rocks_location) then
|
||||
-- Pull down rocks.nvim
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/nvim-neorocks/rocks.nvim",
|
||||
rocks_location,
|
||||
})
|
||||
end
|
||||
|
||||
-- If the clone was successful then source the bootstrapping script
|
||||
assert(
|
||||
vim.v.shell_error == 0,
|
||||
"rocks.nvim installation failed. Try exiting and re-entering Neovim!"
|
||||
)
|
||||
-- If rocks.nvim is not installed then install it!
|
||||
if not pcall(require, "rocks") then
|
||||
local rocks_location =
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
vim.fs.joinpath(vim.fn.stdpath("cache"), "rocks.nvim")
|
||||
|
||||
vim.cmd.source(vim.fs.joinpath(rocks_location, "bootstrap.lua"))
|
||||
if not vim.uv.fs_stat(rocks_location) then
|
||||
-- Pull down rocks.nvim
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/nvim-neorocks/rocks.nvim",
|
||||
rocks_location,
|
||||
})
|
||||
end
|
||||
|
||||
vim.fn.delete(rocks_location, "rf")
|
||||
-- If the clone was successful then source the bootstrapping script
|
||||
assert(
|
||||
vim.v.shell_error == 0,
|
||||
"rocks.nvim installation failed. Try exiting and re-entering Neovim!"
|
||||
)
|
||||
|
||||
vim.cmd.source(vim.fs.joinpath(rocks_location, "bootstrap.lua"))
|
||||
|
||||
vim.fn.delete(rocks_location, "rf")
|
||||
end
|
||||
end
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Ensure Luarocks ━━━━━━━━━━━━━━━━━━━━━━━
|
||||
function M.ensure_luarocks()
|
||||
-- Check if 'luarocks' command is available
|
||||
if os.execute("luarocks --version") ~= 0 then
|
||||
-- 'luarocks' is not installed, set up 'luarocks.nvim' plugin
|
||||
local status_ok, lazy = pcall(require, "lazy")
|
||||
if not status_ok then
|
||||
vim.notify(
|
||||
"Lazy.nvim not found. Please install it to manage plugins.",
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
lazy.setup({
|
||||
{
|
||||
"vhyrro/luarocks.nvim",
|
||||
priority = 1000, -- Ensure this plugin loads first
|
||||
opts = {
|
||||
rocks = { "magick" }, -- Example of a rock that you want to install
|
||||
},
|
||||
config = function()
|
||||
-- Restart Neovim to apply changes after 'luarocks.nvim' sets up
|
||||
vim.cmd("source $MYVIMRC | qa")
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━ Rocks plugin spec ━━━━━━━━━━━━━━━━━━━━━━
|
||||
M.plugin_spec = {
|
||||
"vhyrro/luarocks.nvim",
|
||||
priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
|
||||
priority = 1000, -- Very high priority is required
|
||||
opts = {
|
||||
rocks = { "magick" }, -- specifies a list of rocks to install
|
||||
},
|
||||
@@ -94,6 +132,8 @@ end
|
||||
|
||||
-- Perform setup
|
||||
M.setup = function()
|
||||
M.bootstrap()
|
||||
M.ensure_luarocks()
|
||||
M.load_rocks()
|
||||
end
|
||||
|
||||
|
||||
+6
-16
@@ -13,6 +13,11 @@ local function trigger_error(message)
|
||||
return require("data").func.notify(message, "ERROR")
|
||||
end
|
||||
|
||||
local function setup_os_vars()
|
||||
-- Check if we are on windows
|
||||
vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
|
||||
end
|
||||
|
||||
--- Yank line without leading/trailing whitespace
|
||||
---@return nil
|
||||
function M.yank_line()
|
||||
@@ -180,6 +185,7 @@ end
|
||||
|
||||
--- Set up rootiest module
|
||||
function M.setup()
|
||||
setup_os_vars()
|
||||
M.eval_neovide()
|
||||
M.define_commands()
|
||||
|
||||
@@ -187,22 +193,6 @@ function M.setup()
|
||||
require("data.types").setup()
|
||||
-- Setup indentor
|
||||
require("utils.indentor")
|
||||
|
||||
---━━━━━━━━━━━━━━━━━━━━━━━━━━ Rootiest cmd window ━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
--
|
||||
-- Setup Rootiest cmd window utility
|
||||
require("utils.cmd_window").setup()
|
||||
|
||||
-- Setup Rootiest cmd window (override default command-line behavior)
|
||||
-- require("utils.cmd_window").setup({ override_cmdline = true })
|
||||
|
||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ BLINKY CURSOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
-- Setup the blinky cursor if it is enabled
|
||||
if vim.g.blinky ~= false then
|
||||
require("utils").blinky.enable()
|
||||
else
|
||||
require("utils").blinky.disable()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -74,6 +74,10 @@ M.ripsub = {
|
||||
"RipSubstitute",
|
||||
}
|
||||
|
||||
M.spell_errors = {
|
||||
"Telescope spell_errors",
|
||||
}
|
||||
|
||||
--- Suda plugin cmds
|
||||
M.suda = {
|
||||
"SudaWrite",
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ M.alpha = {
|
||||
-- stylua: ignore start
|
||||
dashboard.section.buttons.val = {
|
||||
---@diagnostic disable: param-type-mismatch
|
||||
dashboard.button("f", " " .. " Find file", LazyVim.pick()),
|
||||
dashboard.button("f", " " .. " Find file", "<cmd>Telescope frecency workspace=CWD <cr>"),
|
||||
dashboard.button("n", " " .. " New file", [[<cmd> ene <BAR> startinsert <cr>]]),
|
||||
dashboard.button("r", " " .. " Recent files", LazyVim.pick("oldfiles")),
|
||||
dashboard.button("g", " " .. " Grep text", LazyVim.pick("live_grep")),
|
||||
|
||||
@@ -233,6 +233,218 @@ function M.notify(message, level, title)
|
||||
return true
|
||||
end
|
||||
|
||||
---@function Function to generate a y/n confirmation prompt
|
||||
---@param prompt string The prompt text to display
|
||||
---@param action function|string The action to execute if the user confirms the prompt, or a Vim command as a string
|
||||
---@return boolean condition true if the user confirms the prompt, false otherwise
|
||||
function M.ConfirmPrompt(prompt, action)
|
||||
-- Validate the action parameter
|
||||
local function perform_action()
|
||||
if type(action) == "function" then
|
||||
action() -- Call the function
|
||||
elseif type(action) == "string" then
|
||||
vim.cmd(action) -- Run the Vim command
|
||||
else
|
||||
M.notify(
|
||||
"Action must be a function or a string",
|
||||
"ERROR",
|
||||
"Configuration Error"
|
||||
)
|
||||
end
|
||||
end
|
||||
-- Create a new buffer
|
||||
local buf = vim.api.nvim_create_buf(false, true) -- Create a new empty buffer
|
||||
-- Set the prompt text in the buffer
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { prompt, "y/n: " })
|
||||
-- Create a floating window to display the buffer
|
||||
local win_height = 2 -- Height of floating window
|
||||
local win_width = math.floor(vim.o.columns * 0.25) -- Width of floating window
|
||||
local row = math.floor((vim.o.lines - win_height) / 2) -- Position row
|
||||
local col = math.floor((vim.o.columns - win_width) / 2) -- Position column
|
||||
local win_border = "rounded"
|
||||
local style = "minimal"
|
||||
-- Create a floating window
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = win_width,
|
||||
height = win_height,
|
||||
col = col,
|
||||
row = row,
|
||||
style = style,
|
||||
border = win_border,
|
||||
})
|
||||
-- Move the cursor to the end of the buffer
|
||||
vim.api.nvim_win_set_cursor(win, { 2, 5 })
|
||||
-- Define the yes function
|
||||
local yes = function()
|
||||
vim.api.nvim_win_close(win, true)
|
||||
perform_action() -- Perform the action
|
||||
return true
|
||||
end
|
||||
-- Define the no function
|
||||
local no = function()
|
||||
vim.api.nvim_win_close(win, true)
|
||||
M.notify("Action Canceled", "INFO", "Info")
|
||||
end
|
||||
-- Define buffer-specific key mappings
|
||||
local keymaps = {
|
||||
y = function()
|
||||
yes()
|
||||
end,
|
||||
n = function()
|
||||
no()
|
||||
end,
|
||||
q = function()
|
||||
no()
|
||||
end,
|
||||
["<Esc>"] = function()
|
||||
no()
|
||||
end,
|
||||
}
|
||||
-- Set the key mappings
|
||||
for key, callback in pairs(keymaps) do
|
||||
vim.api.nvim_buf_set_keymap(buf, "n", key, "", {
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
callback = callback,
|
||||
})
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---@function Function to generate an input prompt
|
||||
---@param prompt string The prompt text to display
|
||||
---@param callback function The function to call with the user input
|
||||
function M.InputPrompt(prompt, callback)
|
||||
-- Create a new buffer
|
||||
local buf = vim.api.nvim_create_buf(false, true) -- Create a new empty buffer
|
||||
|
||||
-- Set the buffer name
|
||||
vim.api.nvim_buf_set_name(buf, "Input")
|
||||
-- Set the buffer filetype (e.g., for custom behavior or syntax highlighting)
|
||||
vim.bo[buf].filetype = "input"
|
||||
-- Set the buffer type to "nofile" to avoid editing or saving the buffer
|
||||
vim.bo[buf].buftype = "nofile"
|
||||
-- Set the prompt text in the buffer
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { prompt, "Input: " })
|
||||
|
||||
-- Create a floating window to display the buffer
|
||||
local win_height = 2 -- Height of floating window
|
||||
local win_width = math.floor(vim.o.columns * 0.25) -- Width of floating window
|
||||
local row = math.floor((vim.o.lines - win_height) / 2) -- Position row
|
||||
local col = math.floor((vim.o.columns - win_width) / 2) -- Position column
|
||||
local win_border = "rounded"
|
||||
local style = "minimal"
|
||||
|
||||
-- Create a floating window
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = win_width,
|
||||
height = win_height,
|
||||
col = col,
|
||||
row = row,
|
||||
style = style,
|
||||
border = win_border,
|
||||
})
|
||||
|
||||
-- Move the cursor to the end of the buffer
|
||||
vim.api.nvim_win_set_cursor(win, { 2, 8 })
|
||||
-- Set input mode
|
||||
vim.api.nvim_command("startinsert")
|
||||
|
||||
-- Function to close the window
|
||||
local function exit_win()
|
||||
vim.api.nvim_command("stopinsert")
|
||||
vim.api.nvim_win_close(win, true)
|
||||
end
|
||||
|
||||
-- Function to handle input and close the window
|
||||
local function handle_input()
|
||||
-- Get the text after the "Input: " string
|
||||
local input = vim.api.nvim_buf_get_lines(buf, 1, 2, false)[1]:sub(7) -- Adjust to trim "Input: "
|
||||
return input
|
||||
end
|
||||
|
||||
---@function Function to return user input
|
||||
local function yes()
|
||||
local user_input = handle_input() -- Get the input from the buffer
|
||||
exit_win()
|
||||
if callback then
|
||||
callback(user_input) -- Call the callback with the user input
|
||||
end
|
||||
end
|
||||
|
||||
---@function Function to cancel user input
|
||||
local function no()
|
||||
exit_win()
|
||||
if callback then
|
||||
callback(nil) -- Call the callback with nil to indicate cancellation
|
||||
end
|
||||
end
|
||||
|
||||
-- Define buffer-specific key mappings
|
||||
local keymaps = {
|
||||
["<CR>"] = yes,
|
||||
["<Esc>"] = no,
|
||||
}
|
||||
|
||||
-- Set the key mappings
|
||||
for key, keyback in pairs(keymaps) do
|
||||
vim.api.nvim_buf_set_keymap(buf, "n", key, "", {
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
callback = keyback,
|
||||
})
|
||||
vim.api.nvim_buf_set_keymap(buf, "i", key, "", {
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
callback = keyback,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
---@function Function to reload the user's Neovim configuration
|
||||
---@return nil
|
||||
function M.reload_config()
|
||||
-- Notify the user about the reload process
|
||||
M.notify("Reloading configuration...", "WARN", "Reloading Config")
|
||||
-- 1. Save all buffers
|
||||
vim.cmd("silent! wa")
|
||||
-- 2. Record the list of open buffers to reopen later
|
||||
local buffer_list = vim.api.nvim_list_bufs()
|
||||
local buffers_to_reopen = {}
|
||||
for _, buf in ipairs(buffer_list) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) and vim.fn.bufname(buf) ~= "" then
|
||||
table.insert(
|
||||
buffers_to_reopen,
|
||||
{ buf = buf, file = vim.api.nvim_buf_get_name(buf) }
|
||||
)
|
||||
end
|
||||
end
|
||||
-- 3. Close all buffers
|
||||
vim.cmd("silent! bufdo! bwipeout")
|
||||
-- 4. Clear loaded lua modules related to your custom configuration
|
||||
for name, _ in pairs(package.loaded) do
|
||||
-- Replace 'userconfig' and 'plugin' with your actual config module names
|
||||
if name:match("^userconfig") or name:match("^plugins") then
|
||||
package.loaded[name] = nil
|
||||
end
|
||||
end
|
||||
-- 5. Reload the vim script (init.lua)
|
||||
vim.cmd("source $MYVIMRC")
|
||||
-- 6. Reopen the buffers
|
||||
for _, bufinfo in ipairs(buffers_to_reopen) do
|
||||
local buf = vim.fn.bufadd(bufinfo.file)
|
||||
vim.cmd("buffer " .. buf)
|
||||
vim.api.nvim_buf_call(buf, function()
|
||||
-- You could also restore the exact cursor position if desired
|
||||
vim.cmd('silent! normal! g`"')
|
||||
end)
|
||||
end -- Notify the user that the config has been reloaded
|
||||
M.notify("Configuration reloaded successfully!", "INFO", "Reloaded Config")
|
||||
end
|
||||
|
||||
---@function Function to reload all plugins.
|
||||
--- This is a messy operation. It's not recommended to use it.
|
||||
--- If you do, please define the exclusion list in your config.lua file.
|
||||
|
||||
+24
-3
@@ -357,6 +357,13 @@ M.misc = {
|
||||
end,
|
||||
desc = "Toggle Hardmode",
|
||||
},
|
||||
{ -- Reload config
|
||||
lhs = "<leader>qr",
|
||||
rhs = function()
|
||||
require("data.func").reload_config()
|
||||
end,
|
||||
desc = "Reload Config",
|
||||
},
|
||||
{ -- Yank buffer
|
||||
lhs = "<leader>Y",
|
||||
rhs = "<cmd>%y<cr>",
|
||||
@@ -372,6 +379,21 @@ M.misc = {
|
||||
rhs = "<cmd>Neotree reveal toggle<cr>",
|
||||
desc = "Neotree toggle",
|
||||
},
|
||||
{ -- Neotree
|
||||
lhs = "<leader>\\",
|
||||
rhs = "<cmd>Neotree reveal toggle<cr>",
|
||||
desc = "Neotree toggle",
|
||||
},
|
||||
{ -- Mini.files
|
||||
lhs = "<leader>.",
|
||||
rhs = "<cmd>lua require('mini.files').open()<cr>",
|
||||
desc = "Open mini.files",
|
||||
},
|
||||
{ -- Telescope Frecency
|
||||
lhs = "<leader><leader>",
|
||||
rhs = "<cmd>Telescope frecency workspace=CWD<cr>",
|
||||
desc = "Telescope frecency",
|
||||
},
|
||||
{ -- Exit Neovim
|
||||
lhs = "<leader>Q",
|
||||
rhs = "<cmd>lua require('data').func.exit()<cr>",
|
||||
@@ -603,13 +625,12 @@ M.substitute = {
|
||||
},
|
||||
}
|
||||
|
||||
M.surround = {
|
||||
M.overrides = {
|
||||
{ -- De-map 's' to avoid conflicts with mini.surround
|
||||
lhs = "s",
|
||||
rhs = "<Nop>",
|
||||
desc = "Prevent conflict with mini.surround",
|
||||
desc = "Surround",
|
||||
mode = { "n", "x" },
|
||||
hidden = true,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+168
-46
@@ -189,6 +189,23 @@ M.arrow = {
|
||||
|
||||
--- Bufferline configuration options
|
||||
M.bufferline = {
|
||||
enabled = function()
|
||||
if
|
||||
require("data.func").check_global_var(
|
||||
"tabline",
|
||||
"bufferline",
|
||||
"bufferline"
|
||||
)
|
||||
or require("data.func").check_global_var(
|
||||
"tabline",
|
||||
"barsNlines",
|
||||
"bufferline"
|
||||
)
|
||||
then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
opts = {
|
||||
options = {
|
||||
themable = true,
|
||||
@@ -440,6 +457,10 @@ M.whichkey = {
|
||||
winblend = 10,
|
||||
},
|
||||
},
|
||||
triggers = {
|
||||
{ "<leader>", mode = { "n", "v" } },
|
||||
{ "s", mode = { "n", "x" } },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -479,8 +500,10 @@ M.gitgraph = {
|
||||
else
|
||||
-- Fallback
|
||||
return {
|
||||
merge_commit = "M",
|
||||
commit = "*",
|
||||
merge_commit = "",
|
||||
commit = "",
|
||||
merge_commit_end = "",
|
||||
commit_end = "",
|
||||
}
|
||||
end
|
||||
end,
|
||||
@@ -518,6 +541,7 @@ M.ibl = {
|
||||
},
|
||||
scope_char = {
|
||||
light = { "" },
|
||||
hard = { "│" },
|
||||
none = { " " },
|
||||
fancy = { "‖" },
|
||||
strong = { "⦀" },
|
||||
@@ -650,56 +674,122 @@ M.trouble = {
|
||||
}
|
||||
|
||||
--- Function to set up bars-n-lines plugin options
|
||||
M.barsNlines = function()
|
||||
require("bars").setup({
|
||||
exclude_filetypes = M.minimap.ft,
|
||||
exclude_buftypes = M.minimap.buf,
|
||||
statuscolumn = {
|
||||
enable = true,
|
||||
parts = {
|
||||
{
|
||||
type = "fold",
|
||||
markers = {
|
||||
default = {
|
||||
content = { " " },
|
||||
},
|
||||
open = {
|
||||
{ " ", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
close = {
|
||||
{ "╴", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
scope = {
|
||||
{ "│ ", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
divider = {
|
||||
{ "├╴", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
foldend = {
|
||||
{ "╰╼", "BarsStatuscolumnFold1" },
|
||||
M.barsNlines = {
|
||||
enabled = function()
|
||||
if
|
||||
require("data.func").check_global_var(
|
||||
"statuscolumn",
|
||||
"barsNlines",
|
||||
"native"
|
||||
)
|
||||
or require("data.func").check_global_var(
|
||||
"tabline",
|
||||
"barsNlines",
|
||||
"bufferline"
|
||||
)
|
||||
or require("data.func").check_global_var(
|
||||
"statusline",
|
||||
"barsNlines",
|
||||
"lualine"
|
||||
)
|
||||
then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
config = function()
|
||||
require("bars").setup({
|
||||
exclude_filetypes = M.minimap.ft,
|
||||
exclude_buftypes = M.minimap.buf,
|
||||
statuscolumn = {
|
||||
enable = require("data.func").check_global_var(
|
||||
"statuscolumn",
|
||||
"barsNlines",
|
||||
"native"
|
||||
),
|
||||
parts = {
|
||||
{
|
||||
type = "fold",
|
||||
markers = {
|
||||
default = {
|
||||
content = { " " },
|
||||
},
|
||||
open = {
|
||||
{ " ", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
close = {
|
||||
{ "╴", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
scope = {
|
||||
{ "│ ", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
divider = {
|
||||
{ "├╴", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
foldend = {
|
||||
{ "╰╼", "BarsStatuscolumnFold1" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type = "number",
|
||||
mode = "hybrid",
|
||||
hl = "LineNr",
|
||||
lnum_hl = "BarsStatusColumnNum",
|
||||
relnum_hl = "LineNr",
|
||||
virtnum_hl = "TablineSel",
|
||||
wrap_hl = "TablineSel",
|
||||
{
|
||||
type = "number",
|
||||
mode = "hybrid",
|
||||
hl = "LineNr",
|
||||
lnum_hl = "BarsStatusColumnNum",
|
||||
relnum_hl = "LineNr",
|
||||
virtnum_hl = "TablineSel",
|
||||
wrap_hl = "TablineSel",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
tabline = false,
|
||||
statusline = false,
|
||||
})
|
||||
end
|
||||
tabline = {
|
||||
enable = require("data.func").check_global_var(
|
||||
"tabline",
|
||||
"barsNlines",
|
||||
"bufferline"
|
||||
),
|
||||
parts = {
|
||||
{
|
||||
-- Part name
|
||||
type = "bufs",
|
||||
|
||||
-- Active buffer configuration
|
||||
active = {
|
||||
corner_left = { "", "BarsTablineBufActiveSep" },
|
||||
corner_right = { "", "BarsTablineBufActiveSep" },
|
||||
|
||||
padding_left = { " ", "BarsTablineBufActive" },
|
||||
padding_right = { " " },
|
||||
},
|
||||
|
||||
-- Inactive buffer configuration
|
||||
inactive = {
|
||||
corner_left = { "", "BarsTablineBufInactiveSep" },
|
||||
corner_right = { "", "BarsTablineBufInactiveSep" },
|
||||
|
||||
padding_left = { " ", "BarsTablineBufInactive" },
|
||||
padding_right = { " " },
|
||||
},
|
||||
|
||||
-- List of patterns to ignore
|
||||
ignore = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
statusline = {
|
||||
enable = require("data.func").check_global_var(
|
||||
"statusline",
|
||||
"barsNlines",
|
||||
"lualine"
|
||||
),
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
--- Function to setup Pigeon plugin options
|
||||
M.pigeon = function()
|
||||
local data = require("data")
|
||||
local platform = data.func.get_os("platform")
|
||||
local platform = require("data.func").get_os("platform")
|
||||
local lazy_installed = pcall(require, "lazy")
|
||||
local packer_installed = pcall(require, "packer_plugins")
|
||||
local pigeon_enabled = true -- default
|
||||
@@ -711,7 +801,7 @@ M.pigeon = function()
|
||||
elseif vim.fn.exists("g:plugs") == 1 then
|
||||
plugman = "vim-plug"
|
||||
else
|
||||
data.func.notify(
|
||||
require("data.func").notify(
|
||||
"Failed to detect package manager.\nPigeon disabled.",
|
||||
"ERROR"
|
||||
)
|
||||
@@ -955,6 +1045,38 @@ M.toggleterm = {
|
||||
},
|
||||
}
|
||||
|
||||
M.treesitter = {
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"css",
|
||||
"diff",
|
||||
"html",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"printf",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"xml",
|
||||
"yaml",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
--- Function to extend minimap.buf with general exclusions
|
||||
---@private
|
||||
---@return nil
|
||||
|
||||
@@ -16,5 +16,5 @@ return { -- Astral
|
||||
"default",
|
||||
},
|
||||
},
|
||||
-- dev = true, -- Use local codebase
|
||||
dev = true, -- Use local codebase
|
||||
}
|
||||
|
||||
@@ -125,6 +125,11 @@ return { --
|
||||
},
|
||||
})
|
||||
|
||||
-- Input filetype
|
||||
cmp.setup.filetype("input", {
|
||||
sources = {},
|
||||
})
|
||||
|
||||
-- Custom filetype configuration
|
||||
cmp.setup.filetype("config", {
|
||||
sources = vim.tbl_filter(function(source)
|
||||
|
||||
@@ -12,6 +12,10 @@ return {
|
||||
automatic_installation = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = data.types.treesitter.opts,
|
||||
},
|
||||
{ --
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = data.types.lspconfig.opts,
|
||||
|
||||
@@ -14,6 +14,7 @@ return {
|
||||
},
|
||||
{ -- Bufferline
|
||||
"akinsho/bufferline.nvim",
|
||||
enabled = data.types.bufferline.enabled,
|
||||
opts = data.types.bufferline.opts,
|
||||
},
|
||||
{ -- Which-Key
|
||||
|
||||
@@ -113,6 +113,7 @@ return {
|
||||
},
|
||||
{ -- Colorful window separators
|
||||
"nvim-zh/colorful-winsep.nvim",
|
||||
lazy = true,
|
||||
opts = {
|
||||
only_line_seq = false,
|
||||
symbols = data.types.colorful_winsep.symbols,
|
||||
@@ -129,12 +130,14 @@ return {
|
||||
},
|
||||
{ -- Bars N Lines
|
||||
"OXY2DEV/bars-N-lines.nvim",
|
||||
enabled = data.func.check_global_var(
|
||||
"statuscolumn",
|
||||
"barsNlines",
|
||||
"native"
|
||||
),
|
||||
enabled = data.types.barsNlines.enabled,
|
||||
lazy = false,
|
||||
config = data.types.barsNlines,
|
||||
config = data.types.barsNlines.config,
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-frecency.nvim",
|
||||
config = function()
|
||||
require("telescope").load_extension("frecency")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -40,4 +40,7 @@ return {
|
||||
{ -- Sql
|
||||
import = "lazyvim.plugins.extras.lang.sql",
|
||||
},
|
||||
{ -- Jinja
|
||||
"armyers/Vim-Jinja2-Syntax",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -29,9 +29,6 @@ return {
|
||||
{ -- mini.surround
|
||||
"echasnovski/mini.surround",
|
||||
opts = {},
|
||||
keys = function()
|
||||
data.func.add_keymap(data.keys.surround)
|
||||
end,
|
||||
},
|
||||
{ -- mini.files
|
||||
"echasnovski/mini.files",
|
||||
|
||||
+17
-9
@@ -123,14 +123,14 @@ return {
|
||||
ft = "help",
|
||||
dependencies = data.deps.needs_treesitter,
|
||||
},
|
||||
{ -- Docker-compose logs
|
||||
"adelowo/dockercomposelogs.nvim",
|
||||
config = function()
|
||||
require("dockercomposelogs").setup({})
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
dependencies = data.deps.needs_telescope,
|
||||
},
|
||||
-- { -- Docker-compose logs
|
||||
-- "adelowo/dockercomposelogs.nvim",
|
||||
-- config = function()
|
||||
-- require("dockercomposelogs").setup({})
|
||||
-- end,
|
||||
-- event = "VeryLazy",
|
||||
-- dependencies = data.deps.needs_telescope,
|
||||
-- },
|
||||
{ -- Suda
|
||||
"lambdalisue/vim-suda",
|
||||
cmd = data.cmd.suda,
|
||||
@@ -141,13 +141,21 @@ return {
|
||||
},
|
||||
{ -- Spell checker
|
||||
"matkrin/telescope-spell-errors.nvim",
|
||||
lazy = true,
|
||||
cmd = data.cmd.spell_errors,
|
||||
config = function()
|
||||
require("telescope").load_extension("spell_errors")
|
||||
end,
|
||||
dependencies = data.deps.needs_telescope,
|
||||
},
|
||||
{ --
|
||||
{ -- Pigeon
|
||||
"Pheon-Dev/pigeon",
|
||||
config = data.types.pigeon,
|
||||
},
|
||||
{ -- Discord Presence
|
||||
"andweeb/presence.nvim",
|
||||
opts = {
|
||||
enable_line_number = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -24,4 +24,17 @@ function M.disable()
|
||||
return false
|
||||
end
|
||||
|
||||
---@function Function to setup blinky cursor option
|
||||
---@param enable boolean|nil enable blinky cursor option
|
||||
function M.setup(enable)
|
||||
if enable then
|
||||
vim.g.blinky = enable
|
||||
end
|
||||
if vim.g.blinky ~= false then
|
||||
M.enable()
|
||||
else
|
||||
M.disable()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -24,6 +24,10 @@ _G.cache_stats_dir = -- Cache directory
|
||||
-- Flag to check if the script has already been run
|
||||
local script_run_once = false
|
||||
|
||||
-- Variable to track the pid
|
||||
---@type number|boolean
|
||||
M.pid = false
|
||||
|
||||
-- Default list of players/sources to ignore when updating the status
|
||||
local ignored_players = {
|
||||
"chromium",
|
||||
@@ -84,7 +88,42 @@ function M.setup_script()
|
||||
return false
|
||||
end
|
||||
|
||||
---@function Function to force the script to reset
|
||||
--- This will kill the script if it's running and delete the lock file.
|
||||
--- Optionally the cache files will be deleted if wipe is true.
|
||||
--- By default, the cache files will not be deleted.
|
||||
--- If the script is not running, this function will start the script.
|
||||
---@param wipe boolean|nil Whether to wipe the cache files (default: false)
|
||||
--- If true, the cache files will be deleted.
|
||||
--- If false, the cache files will not be deleted.
|
||||
---
|
||||
--- The cache files are:
|
||||
--- - music_cache.txt
|
||||
--- - wakatime_cache.txt
|
||||
---@return boolean|number pid The pid of the script
|
||||
function M.reset_script(wipe)
|
||||
-- Try to kill the script if it's running
|
||||
if M.pid and vim.fn.jobstop(M.pid) == 0 then
|
||||
M.pid = false
|
||||
end
|
||||
-- Remove the lockfile
|
||||
vim.fn.delete(
|
||||
vim.fs.joinpath(_G.cache_stats_dir, "music_wakatime_update.lock")
|
||||
)
|
||||
-- Wipe the cache files
|
||||
if wipe then
|
||||
vim.fn.delete(vim.fs.joinpath(_G.cache_stats_dir, "music_cache.txt"))
|
||||
vim.fn.delete(vim.fs.joinpath(_G.cache_stats_dir, "wakatime_cache.txt"))
|
||||
end
|
||||
-- Reset the script_run_once flag
|
||||
script_run_once = false
|
||||
-- Re-run the script
|
||||
M.pid = M.setup_script()
|
||||
-- Return the pid
|
||||
return M.pid
|
||||
end
|
||||
|
||||
-- Run the setup script
|
||||
M.setup_script()
|
||||
M.pid = M.setup_script()
|
||||
|
||||
return M
|
||||
|
||||
@@ -84,7 +84,7 @@ function M.setup_indent_highlight()
|
||||
"IndentsScopeHighlight",
|
||||
"IndentsScopeHighlight",
|
||||
},
|
||||
char = vim.g.scope_char or data.types.ibl.scope_char.light,
|
||||
char = vim.g.scope_char or data.types.ibl.scope_char.hard,
|
||||
},
|
||||
whitespace = {
|
||||
remove_blankline_trail = true,
|
||||
|
||||
Reference in New Issue
Block a user