Skip to content

Commit 3ffc68c

Browse files
committed
feat: add markdown opt-in extra + fix local.lua load order
Adds lua/whipsmart/plugins/markdown.lua as an opt-in extra that bundles render-markdown.nvim (unconditional) and obsidian.nvim + blink.compat (gated on vim.g.obsidian_vaults being set in local.lua). Uses blink.cmp.config.merge_with to extend the completion config post-setup with markdown-specific per_filetype sources and [[wikilink trigger behaviour. Also fixes a load-order bug where pcall(require, 'local') ran before vim.g.have_nerd_font and all vim.o.* defaults were set, making it impossible for local.lua to override them. The call is now at the end of Section 1 so local.lua runs last and overrides work correctly. UNIFIED.md updated: markdown extra documented, roci migration and load-order fix checked off the roadmap.
1 parent 262d652 commit 3ffc68c

3 files changed

Lines changed: 104 additions & 6 deletions

File tree

UNIFIED.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ require 'whipsmart.plugins.debug'
3131
```
3232

3333
Available extras: `autopairs`, `debug` (DAP/Go), `gitsigns` (extended keymaps),
34-
`indent_line`, `lint`, `neo-tree`.
34+
`indent_line`, `lint`, `markdown` (render-markdown + obsidian), `neo-tree`.
35+
36+
The `markdown` extra reads `vim.g.obsidian_vaults` from `local.lua` to configure
37+
obsidian.nvim; render-markdown loads unconditionally. Example `local.lua` snippet:
38+
```lua
39+
vim.g.obsidian_vaults = { { name = 'personal', path = '~/Obsidian/Main' } }
40+
```
41+
Then activate in `lua/custom/plugins/markdown.lua`:
42+
```lua
43+
require 'whipsmart.plugins.markdown'
44+
```
3545

3646
## 💻 Per-Machine Local Config
3747
Each machine maintains a `lua/local.lua` that is **gitignored** and never committed.
@@ -60,6 +70,9 @@ cp ~/.config/nvim/lua/local.lua.example ~/.config/nvim/lua/local.lua
6070
- [x] Document LSP server setup and opt-in extras workflow.
6171
- [x] Replace hostname detection with gitignored lua/local.lua per-machine overrides.
6272
- [x] Port hecate config: LSP servers, formatters, treesitter parsers, custom plugins.
73+
- [x] Fix `local.lua` load order — `pcall(require, 'local')` moved to end of Section 1 so it can override defaults.
74+
- [x] Add markdown opt-in extra (render-markdown, obsidian, blink.compat).
75+
- [x] Migrate roci to whipsmart.
6376
- [ ] Migrate vera and tau to whipsmart (create their lua/local.lua files).
6477
- [ ] Add machine-specific UI toggles for terminal vs. GUI Neovim (via local.lua).
6578
- [ ] Centralize snippet collections.

init.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ do
4747
vim.g.mapleader = ' '
4848
vim.g.maplocalleader = ' '
4949

50-
-- [[ Machine Specific Setup ]]
51-
-- lua/local.lua is gitignored — each machine maintains its own copy.
52-
-- See lua/local.lua.example for available options.
53-
pcall(require, 'local')
54-
5550
-- Set to true if you have a Nerd Font installed and selected in the terminal
5651
vim.g.have_nerd_font = true
5752

@@ -118,6 +113,12 @@ do
118113
group = vim.api.nvim_create_augroup('whipsmart-highlight-yank', { clear = true }),
119114
callback = function() vim.hl.on_yank() end,
120115
})
116+
117+
-- [[ Machine Specific Setup ]]
118+
-- lua/local.lua is gitignored — each machine maintains its own copy.
119+
-- Loaded last so it can override any default set above.
120+
-- See lua/local.lua.example for available options.
121+
pcall(require, 'local')
121122
end
122123

123124
-- ============================================================

lua/whipsmart/plugins/markdown.lua

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
local function gh(repo) return 'https://github.com/' .. repo end
2+
3+
-- ── render-markdown (always loaded) ─────────────────────────────────────────
4+
vim.pack.add {
5+
gh 'MeanderingProgrammer/render-markdown.nvim',
6+
gh 'nvim-treesitter/nvim-treesitter',
7+
}
8+
9+
require('render-markdown').setup {
10+
render_modes = { 'n', 'c' },
11+
heading = { enabled = true },
12+
bullet = { enabled = true },
13+
checkbox = { enabled = true },
14+
code = { enabled = true },
15+
}
16+
17+
vim.api.nvim_create_autocmd('FileType', {
18+
desc = 'Markdown editing options',
19+
group = vim.api.nvim_create_augroup('whipsmart-markdown', { clear = true }),
20+
pattern = 'markdown',
21+
callback = function()
22+
vim.opt_local.wrap = true
23+
vim.opt_local.linebreak = true
24+
vim.opt_local.spell = true
25+
vim.opt_local.spelllang = 'en_us'
26+
vim.opt_local.conceallevel = 2
27+
end,
28+
})
29+
30+
-- ── obsidian (opt-in — requires vim.g.obsidian_vaults to be set in local.lua) ─
31+
-- Example local.lua entry:
32+
-- vim.g.obsidian_vaults = { { name = 'personal', path = '~/Obsidian/Main' } }
33+
if not vim.g.obsidian_vaults then return end
34+
35+
-- blink.compat must be unversioned (HEAD) — released tags lack cmp.get_config()
36+
vim.pack.add {
37+
{ src = gh 'epwalsh/obsidian.nvim', version = vim.version.range '*' },
38+
gh 'nvim-lua/plenary.nvim',
39+
gh 'saghen/blink.compat',
40+
}
41+
42+
require('blink.compat').setup {}
43+
44+
require('obsidian').setup {
45+
workspaces = vim.g.obsidian_vaults,
46+
completion = { nvim_cmp = false, min_chars = 2 },
47+
}
48+
49+
-- Register obsidian nvim-cmp sources via blink.compat shim
50+
local cmp = require 'cmp'
51+
cmp.register_source('obsidian', require('cmp_obsidian').new())
52+
cmp.register_source('obsidian_new', require('cmp_obsidian_new').new())
53+
cmp.register_source('obsidian_tags', require('cmp_obsidian_tags').new())
54+
55+
-- Extend blink.cmp config post-setup via the v1 merge_with API.
56+
-- Called from custom/plugins/ (Section 3), so plugins.cmp has already run setup().
57+
require('blink.cmp.config').merge_with {
58+
completion = {
59+
trigger = {
60+
-- Remove '[' so [[ wikilinks trigger the completion menu
61+
show_on_x_blocked_trigger_characters = { "'", '"', '(', '{' },
62+
},
63+
menu = {
64+
-- Suppress auto-popup in markdown/text except when '[' was the trigger
65+
auto_show = function(ctx)
66+
if vim.tbl_contains({ 'markdown', 'text' }, vim.bo.filetype) then
67+
return ctx.trigger.initial_kind == 'trigger_character'
68+
and ctx.trigger.initial_character == '['
69+
end
70+
return true
71+
end,
72+
},
73+
},
74+
sources = {
75+
per_filetype = {
76+
markdown = { 'obsidian', 'obsidian_new', 'obsidian_tags', 'lsp', 'path', 'snippets', 'buffer' },
77+
},
78+
providers = {
79+
obsidian = { name = 'obsidian', module = 'blink.compat.source' },
80+
obsidian_new = { name = 'obsidian_new', module = 'blink.compat.source' },
81+
obsidian_tags = { name = 'obsidian_tags', module = 'blink.compat.source' },
82+
},
83+
},
84+
}

0 commit comments

Comments
 (0)