fixing some issues

This commit is contained in:
cg8936
2025-08-12 08:51:16 -04:00
parent b774da0743
commit 72d8698ecb
3 changed files with 58 additions and 24 deletions

View File

@@ -1,40 +1,45 @@
-- Load compatibility layer first
-- =============================================================================
-- cargdev/core/init.lua
-- Main core initialization for cargdev Neovim config
-- =============================================================================
-- 1. Compatibility Layer
require("cargdev.core.compatibility").setup() require("cargdev.core.compatibility").setup()
-- 2. Core Options and Keymaps
require("cargdev.core.options") require("cargdev.core.options")
require("cargdev.core.keymaps") require("cargdev.core.keymaps")
-- Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded -- 3. Utility: Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded
local function load_functions() local function load_functions()
local function_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function" local function_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function"
local scan = vim.fn.globpath(function_path, "*.lua", false, true) local scan = vim.fn.globpath(function_path, "*.lua", false, true)
for _, file in ipairs(scan) do for _, file in ipairs(scan) do
local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$") local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$")
local success, err = pcall(require, module_name) local success, err = pcall(require, module_name)
if not success then if not success then
vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR) vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR)
end end
end end
end end
-- Defer function loading until after plugins are loaded -- 4. Fix: Force filetype detection on BufRead (fix for nvim-tree/plain text issue)
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("BufRead", {
pattern = "LazyDone", pattern = "*",
callback = function() callback = function()
-- Load all functions vim.cmd("filetype detect")
load_functions()
end, end,
once = true,
}) })
-- Fallback: also try to load on VimEnter if LazyDone doesn't fire -- 5. Load functions immediately
load_functions()
-- 6. Fallback: also try to load on VimEnter if LazyDone doesn't fire
vim.api.nvim_create_autocmd("VimEnter", { vim.api.nvim_create_autocmd("VimEnter", {
callback = function() callback = function()
-- Wait a bit for plugins to load -- Wait a bit for plugins to load
vim.defer_fn(function() vim.defer_fn(function()
-- Load functions
load_functions() load_functions()
end, 200) end, 200)
end, end,

View File

@@ -19,19 +19,49 @@ keymap.set("n", "x", '"_x', opts) -- Delete character without copying into regis
keymap.set("n", "<leader>Q", ":qa!<CR>", { desc = "Quit all" }) keymap.set("n", "<leader>Q", ":qa!<CR>", { desc = "Quit all" })
-- Put this in your init.lua -- Put this in your init.lua
local vault_path = "/Users/carlos/Nextcloud/ObsidianVault" local vault_path = vim.env.IDEA_DIR
local function follow_obsidian_link() local function follow_obsidian_link()
-- grab the token under cursor, clean obsidian syntax -- Extract the full [[...]] link from the current line under/around the cursor
local raw = vim.fn.expand("<cWORD>") local line = vim.api.nvim_get_current_line()
raw = raw:gsub("^!%[%[", "[[") -- strip leading ! from embeds local col = vim.fn.col('.')
local link = raw:gsub("%[%[", ""):gsub("%]%]", "") local start_idx, end_idx, raw
-- Search for all [[...]] in the line, pick the one under/around the cursor
local i = 1
while true do
local s, e = line:find('%[%[.-%]%]', i)
if not s then break end
if col >= s and col <= e + 1 then
start_idx, end_idx = s, e
break
end
i = e + 1
end
if not start_idx then
vim.notify('No [[link]] under cursor', vim.log.levels.WARN)
return
end
raw = line:sub(start_idx, end_idx)
raw = raw:gsub('^!%[%[', '[[') -- strip leading ! from embeds
local link = raw:gsub('%[%[', ''):gsub('%]%]', '')
-- split off alias and heading -- split off alias (|) and heading (#) only after extracting the full link
local base, alias = link:match("^(.-)|(.+)$") local alias
link = base or link local heading
local fname, heading = link:match("^(.-)#(.+)$") -- first, split off alias if present
link = fname or link local pipe_idx = link:find("|", 1, true)
if pipe_idx then
alias = link:sub(pipe_idx + 1)
link = link:sub(1, pipe_idx - 1)
end
-- then, split off heading if present
local hash_idx = link:find("#", 1, true)
if hash_idx then
heading = link:sub(hash_idx + 1)
link = link:sub(1, hash_idx - 1)
end
-- normalize spaces -- normalize spaces
link = link:gsub("\\ ", " "):gsub("^%s+", ""):gsub("%s+$", "") link = link:gsub("\\ ", " "):gsub("^%s+", ""):gsub("%s+$", "")

View File

@@ -1,5 +1,4 @@
return { return {
--[[dir = "/Volumes/Carlos_SSD/Documents/projects/ideaDrop",]]
"CarGDev/ideadrop.nvim", "CarGDev/ideadrop.nvim",
name = "ideaDrop", name = "ideaDrop",
dependencies = { dependencies = {
@@ -8,7 +7,7 @@ return {
}, },
config = function() config = function()
require("ideaDrop").setup({ require("ideaDrop").setup({
idea_dir = "/Users/carlos/Nextcloud/ObsidianVault", idea_dir = vim.env.IDEA_DIR,
}) })
-- Set up convenient keymaps for ideaDrop -- Set up convenient keymaps for ideaDrop