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:
25
CHANGELOG.md
25
CHANGELOG.md
@@ -11,6 +11,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
### Added
|
### Added
|
||||||
- **Avante.nvim AI Assistant**: Added Avante.nvim with local LLM support to README documentation
|
- **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
|
- **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
|
### Fixed
|
||||||
- **Auto-session Lazy Loading**: Changed from `event = "VeryLazy"` to `lazy = false` to enable session auto-restore on startup
|
- **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/plugins.lua` | Fixed session/substitute keymap conflicts |
|
||||||
| `lua/cargdev/core/keymaps/general.lua` | Added vault_path validation, removed commented code |
|
| `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/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/core/options.lua` | Removed duplicate settings (synmaxcol, foldmethod, foldlevel) |
|
||||||
| `lua/cargdev/plugins/which-key.lua` | Added group names configuration |
|
| `lua/cargdev/plugins/which-key.lua` | Added group names configuration |
|
||||||
| `lua/cargdev/plugins/formatting.lua` | Enabled auto-format on save with smart filtering |
|
| `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*
|
||||||
|
|||||||
@@ -4,7 +4,22 @@
|
|||||||
-- Main core initialization for cargdev Neovim config
|
-- 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 function setup_luarocks_path()
|
||||||
local luarocks_path = vim.fn.system("luarocks path --lr-path --lua-version=5.1 --local 2>/dev/null"):gsub("\n", "")
|
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
|
if luarocks_path and luarocks_path ~= "" then
|
||||||
@@ -13,14 +28,14 @@ local function setup_luarocks_path()
|
|||||||
end
|
end
|
||||||
setup_luarocks_path()
|
setup_luarocks_path()
|
||||||
|
|
||||||
-- 1. Compatibility Layer
|
-- 2. Compatibility Layer
|
||||||
require("cargdev.core.compatibility").setup()
|
require("cargdev.core.compatibility").setup()
|
||||||
|
|
||||||
-- 2. Core Options and Keymaps
|
-- 3. Core Options and Keymaps
|
||||||
require("cargdev.core.options")
|
require("cargdev.core.options")
|
||||||
require("cargdev.core.keymaps")
|
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 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)
|
||||||
@@ -33,7 +48,7 @@ local function load_functions()
|
|||||||
end
|
end
|
||||||
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
|
-- Only run if filetype is not already detected to avoid redundant calls
|
||||||
vim.api.nvim_create_autocmd("BufRead", {
|
vim.api.nvim_create_autocmd("BufRead", {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
@@ -44,7 +59,7 @@ vim.api.nvim_create_autocmd("BufRead", {
|
|||||||
end,
|
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
|
-- Using a flag to prevent double-loading
|
||||||
local functions_loaded = false
|
local functions_loaded = false
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
@@ -59,7 +74,7 @@ vim.api.nvim_create_autocmd("VimEnter", {
|
|||||||
once = true,
|
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", {
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
callback = function()
|
callback = function()
|
||||||
local opts = {
|
local opts = {
|
||||||
@@ -74,7 +89,7 @@ vim.api.nvim_create_autocmd("CursorHold", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- 7. Configuration validation on startup
|
-- 8. Configuration validation on startup
|
||||||
local function validate_config()
|
local function validate_config()
|
||||||
local warnings = {}
|
local warnings = {}
|
||||||
|
|
||||||
@@ -107,7 +122,7 @@ vim.api.nvim_create_autocmd("VimEnter", {
|
|||||||
once = true,
|
once = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- 8. Custom health check command
|
-- 9. Custom health check command
|
||||||
vim.api.nvim_create_user_command("CheckConfig", function()
|
vim.api.nvim_create_user_command("CheckConfig", function()
|
||||||
vim.cmd("checkhealth")
|
vim.cmd("checkhealth")
|
||||||
end, { desc = "Run Neovim health check" })
|
end, { desc = "Run Neovim health check" })
|
||||||
|
|||||||
@@ -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 {
|
return {
|
||||||
{
|
{
|
||||||
dir = "/Users/carlos/Documents/projects/avante.nvim",
|
dir = local_cfg.avante_dev_path,
|
||||||
-- "yetone/avante.nvim",
|
-- "yetone/avante.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
@@ -13,9 +21,9 @@ return {
|
|||||||
providers = {
|
providers = {
|
||||||
cargdev = {
|
cargdev = {
|
||||||
name = "cargdev", -- Optional
|
name = "cargdev", -- Optional
|
||||||
endpoint = "http://localhost:5001", -- endpoint = "https://api-ai.cargdev.io", -- API endpoint
|
endpoint = local_cfg.avante_endpoint,
|
||||||
api_key_name = "CARGDEV_API_KEY", -- reference the ENV VAR below
|
api_key_name = local_cfg.avante_api_key_name,
|
||||||
model = "qwen2.5-coder:7b",
|
model = local_cfg.avante_model,
|
||||||
__inherited_from = "ollama", -- ensures compatibility
|
__inherited_from = "ollama", -- ensures compatibility
|
||||||
max_tokens = 8192,
|
max_tokens = 8192,
|
||||||
-- Explicitly ensure tools are enabled
|
-- Explicitly ensure tools are enabled
|
||||||
@@ -27,7 +35,7 @@ return {
|
|||||||
},
|
},
|
||||||
-- Build from source for development
|
-- Build from source for development
|
||||||
-- Run `make BUILD_FROM_SOURCE=true` to build Rust components
|
-- 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",
|
build = "make BUILD_FROM_SOURCE=true",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
|||||||
@@ -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 {
|
return {
|
||||||
"CarGDev/ideadrop.nvim",
|
"CarGDev/ideadrop.nvim",
|
||||||
name = "ideaDrop",
|
name = "ideaDrop",
|
||||||
@@ -7,7 +15,7 @@ return {
|
|||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("ideaDrop").setup({
|
require("ideaDrop").setup({
|
||||||
idea_dir = vim.env.IDEA_DIR,
|
idea_dir = vim.g.cargdev_local.IDEA_DIR,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set up convenient keymaps for ideaDrop
|
-- Set up convenient keymaps for ideaDrop
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
return {
|
return {
|
||||||
--[[ dir = "/Users/carlos/Documents/SSD_Documents/projects/lazygit.nvim", ]]
|
|
||||||
"kdheepak/lazygit.nvim",
|
"kdheepak/lazygit.nvim",
|
||||||
cmd = {
|
cmd = {
|
||||||
"LazyGit",
|
"LazyGit",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
return {
|
return {
|
||||||
--[[ dir = '/Users/carlos/Documents/SSD_Documents/personals/leetcode.nvim', ]]
|
|
||||||
"kawre/leetcode.nvim",
|
"kawre/leetcode.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
|
|||||||
Reference in New Issue
Block a user