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()
-- 2. Core Options and Keymaps
require("cargdev.core.options")
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_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function"
local scan = vim.fn.globpath(function_path, "*.lua", false, true)
for _, file in ipairs(scan) do
local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$")
local success, err = pcall(require, module_name)
if not success then
vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR)
end
end
end
-- Defer function loading until after plugins are loaded
vim.api.nvim_create_autocmd("User", {
pattern = "LazyDone",
-- 4. Fix: Force filetype detection on BufRead (fix for nvim-tree/plain text issue)
vim.api.nvim_create_autocmd("BufRead", {
pattern = "*",
callback = function()
-- Load all functions
load_functions()
vim.cmd("filetype detect")
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", {
callback = function()
-- Wait a bit for plugins to load
vim.defer_fn(function()
-- Load functions
load_functions()
end, 200)
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" })
-- 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()
-- grab the token under cursor, clean obsidian syntax
local raw = vim.fn.expand("<cWORD>")
raw = raw:gsub("^!%[%[", "[[") -- strip leading ! from embeds
local link = raw:gsub("%[%[", ""):gsub("%]%]", "")
-- Extract the full [[...]] link from the current line under/around the cursor
local line = vim.api.nvim_get_current_line()
local col = vim.fn.col('.')
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
local base, alias = link:match("^(.-)|(.+)$")
link = base or link
local fname, heading = link:match("^(.-)#(.+)$")
link = fname or link
-- split off alias (|) and heading (#) only after extracting the full link
local alias
local heading
-- first, split off alias if present
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
link = link:gsub("\\ ", " "):gsub("^%s+", ""):gsub("%s+$", "")

View File

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