refactor(config): use local.lua for machine-specific paths

- Load local.lua at startup and expose via vim.g.cargdev_local
- Update avante.lua to use local config for paths and settings
- Update ideaMap.lua to use IDEA_DIR from local config
- Remove all hardcoded user paths from plugin configs
- Plugins gracefully skip if required local config is missing
This commit is contained in:
2026-01-10 23:14:04 -05:00
parent 537c0c4a41
commit ebb7ed7793
6 changed files with 69 additions and 19 deletions

View File

@@ -11,6 +11,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- **Avante.nvim AI Assistant**: Added Avante.nvim with local LLM support to README documentation
- **Bash Treesitter Parser**: Installed bash parser for noice.nvim cmdline highlighting
- **Local Configuration Support**: `local.lua` is now loaded at startup and exposed via `vim.g.cargdev_local`
- Enables machine-specific paths without hardcoding
- Safe loading with `pcall` (won't error if file doesn't exist)
- Plugins gracefully skip if required config is missing
### Changed
- **Avante Plugin**: Now uses `local.lua` for all paths and settings
- `avante_dev_path` for plugin directory
- `avante_endpoint`, `avante_api_key_name`, `avante_model` for provider config
- **IdeaDrop Plugin**: Now uses `IDEA_DIR` from `local.lua` instead of environment variable
### Removed
- **Hardcoded Paths**: Removed all hardcoded user paths from plugin configs
- `avante.lua` - uses `local.lua` values
- `ideaMap.lua` - uses `local.lua` values
- `leetcode.lua` - removed commented hardcoded path
- `lazygit.lua` - removed commented hardcoded path
### Fixed
- **Auto-session Lazy Loading**: Changed from `event = "VeryLazy"` to `lazy = false` to enable session auto-restore on startup
@@ -150,7 +167,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
| `lua/cargdev/core/keymaps/plugins.lua` | Fixed session/substitute keymap conflicts |
| `lua/cargdev/core/keymaps/general.lua` | Added vault_path validation, removed commented code |
| `lua/cargdev/core/keymaps/window.lua` | Centralized window management keymaps |
| `lua/cargdev/core/init.lua` | Fixed double loading, added diagnostic hover, config validation |
| `lua/cargdev/core/init.lua` | Fixed double loading, added diagnostic hover, config validation, loads `local.lua` |
| `lua/cargdev/plugins/avante.lua` | Uses `local.lua` for paths and settings, removed hardcoded values |
| `lua/cargdev/plugins/ideaMap.lua` | Uses `local.lua` for `IDEA_DIR`, removed env var fallback |
| `lua/cargdev/plugins/leetcode.lua` | Removed commented hardcoded path |
| `lua/cargdev/plugins/lazygit.lua` | Removed commented hardcoded path |
| `lua/cargdev/core/options.lua` | Removed duplicate settings (synmaxcol, foldmethod, foldlevel) |
| `lua/cargdev/plugins/which-key.lua` | Added group names configuration |
| `lua/cargdev/plugins/formatting.lua` | Enabled auto-format on save with smart filtering |
@@ -195,4 +216,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
---
*Last Updated: January 2026*
*Last Updated: January 10, 2026*

View File

@@ -4,7 +4,22 @@
-- Main core initialization for cargdev Neovim config
-- =============================================================================
-- 0. Setup LuaRocks path for rest.nvim dependencies (Lua 5.1 - Neovim uses LuaJIT)
-- 0. Load local configuration (gitignored, contains personal paths)
local function load_local_config()
local ok, local_config = pcall(require, "cargdev.core.local")
if ok then
-- Make local config available globally
vim.g.cargdev_local = local_config
return local_config
else
-- Provide empty defaults if local.lua doesn't exist
vim.g.cargdev_local = {}
return {}
end
end
load_local_config()
-- 1. Setup LuaRocks path for rest.nvim dependencies (Lua 5.1 - Neovim uses LuaJIT)
local function setup_luarocks_path()
local luarocks_path = vim.fn.system("luarocks path --lr-path --lua-version=5.1 --local 2>/dev/null"):gsub("\n", "")
if luarocks_path and luarocks_path ~= "" then
@@ -13,14 +28,14 @@ local function setup_luarocks_path()
end
setup_luarocks_path()
-- 1. Compatibility Layer
-- 2. Compatibility Layer
require("cargdev.core.compatibility").setup()
-- 2. Core Options and Keymaps
-- 3. Core Options and Keymaps
require("cargdev.core.options")
require("cargdev.core.keymaps")
-- 3. Utility: Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded
-- 4. 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)
@@ -33,7 +48,7 @@ local function load_functions()
end
end
-- 4. Fix: Force filetype detection on BufRead (fix for nvim-tree/plain text issue)
-- 5. Fix: Force filetype detection on BufRead (fix for nvim-tree/plain text issue)
-- Only run if filetype is not already detected to avoid redundant calls
vim.api.nvim_create_autocmd("BufRead", {
pattern = "*",
@@ -44,7 +59,7 @@ vim.api.nvim_create_autocmd("BufRead", {
end,
})
-- 5. Load functions on VimEnter to ensure plugins are loaded first
-- 6. Load functions on VimEnter to ensure plugins are loaded first
-- Using a flag to prevent double-loading
local functions_loaded = false
vim.api.nvim_create_autocmd("VimEnter", {
@@ -59,7 +74,7 @@ vim.api.nvim_create_autocmd("VimEnter", {
once = true,
})
-- 6. Diagnostic float on hover (show diagnostics when cursor holds)
-- 7. Diagnostic float on hover (show diagnostics when cursor holds)
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
local opts = {
@@ -74,7 +89,7 @@ vim.api.nvim_create_autocmd("CursorHold", {
end,
})
-- 7. Configuration validation on startup
-- 8. Configuration validation on startup
local function validate_config()
local warnings = {}
@@ -107,7 +122,7 @@ vim.api.nvim_create_autocmd("VimEnter", {
once = true,
})
-- 8. Custom health check command
-- 9. Custom health check command
vim.api.nvim_create_user_command("CheckConfig", function()
vim.cmd("checkhealth")
end, { desc = "Run Neovim health check" })

View File

@@ -1,6 +1,14 @@
-- Get local config (loaded in core/init.lua)
local local_cfg = vim.g.cargdev_local or {}
-- Skip plugin if local config is missing required values
if not local_cfg.avante_dev_path then
return {}
end
return {
{
dir = "/Users/carlos/Documents/projects/avante.nvim",
dir = local_cfg.avante_dev_path,
-- "yetone/avante.nvim",
event = "VeryLazy",
lazy = false,
@@ -13,9 +21,9 @@ return {
providers = {
cargdev = {
name = "cargdev", -- Optional
endpoint = "http://localhost:5001", -- endpoint = "https://api-ai.cargdev.io", -- API endpoint
api_key_name = "CARGDEV_API_KEY", -- reference the ENV VAR below
model = "qwen2.5-coder:7b",
endpoint = local_cfg.avante_endpoint,
api_key_name = local_cfg.avante_api_key_name,
model = local_cfg.avante_model,
__inherited_from = "ollama", -- ensures compatibility
max_tokens = 8192,
-- Explicitly ensure tools are enabled
@@ -27,7 +35,7 @@ return {
},
-- Build from source for development
-- Run `make BUILD_FROM_SOURCE=true` to build Rust components
-- You can also build manually: cd /Users/carlos/Documents/projects/avante.nvim && make
-- You can also build manually: cd <avante_dev_path> && make
build = "make BUILD_FROM_SOURCE=true",
dependencies = {
"nvim-treesitter/nvim-treesitter",

View File

@@ -1,3 +1,11 @@
-- Get local config (loaded in core/init.lua)
local local_cfg = vim.g.cargdev_local or {}
-- Skip plugin if IDEA_DIR is not configured
if not local_cfg.IDEA_DIR then
return {}
end
return {
"CarGDev/ideadrop.nvim",
name = "ideaDrop",
@@ -7,7 +15,7 @@ return {
},
config = function()
require("ideaDrop").setup({
idea_dir = vim.env.IDEA_DIR,
idea_dir = vim.g.cargdev_local.IDEA_DIR,
})
-- Set up convenient keymaps for ideaDrop

View File

@@ -1,5 +1,4 @@
return {
--[[ dir = "/Users/carlos/Documents/SSD_Documents/projects/lazygit.nvim", ]]
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",

View File

@@ -1,5 +1,4 @@
return {
--[[ dir = '/Users/carlos/Documents/SSD_Documents/personals/leetcode.nvim', ]]
"kawre/leetcode.nvim",
dependencies = {
"nvim-telescope/telescope.nvim",