Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 632 support for obsidian callouts #665

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8de014c
Add mappings for default callouts
aquilesg Jul 7, 2024
1e92f06
ISSUE-632 Add in scaffolding for callout support
aquilesg Jul 9, 2024
4ac9521
Added stack to track highlight group
aquilesg Jul 12, 2024
3d68c7b
Adjust how headers are generated
Jul 14, 2024
3b58eab
Tweak casing
aquilesg Jul 25, 2024
050a50e
Remove Accidentally committed file
aquilesg Jul 25, 2024
bec06d4
Fix issue where different callout group types at the same indentation
aquilesg Jul 25, 2024
f6836c9
Update readme for callout groups
aquilesg Jul 26, 2024
a471efd
Fix linting errors
aquilesg Jul 26, 2024
71f1626
Fix styling issues
aquilesg Jul 26, 2024
55aed05
Add `opts.follow_img_func` option
epwalsh Jul 26, 2024
5dc44f8
chore(docs): auto generate docs
epwalsh Jul 26, 2024
bf5b1a6
Fixed an edge case with collecting backlinks
epwalsh Jul 26, 2024
b457a63
Rename `image_name_func` to `attachments.img_name_func`
epwalsh Jul 26, 2024
c15d42c
chore(docs): auto generate docs
epwalsh Jul 26, 2024
533672d
Prompt for undefined template fields (#666)
epwalsh Jul 28, 2024
12d4f2c
Correct typo in ObsidianPasteImg's description (#667)
Yoquec Jul 28, 2024
d3664aa
Remove accidentally committed field
aquilesg Jul 29, 2024
4a6cc77
Move stack implementation to collections.lua
aquilesg Jul 29, 2024
06d3983
Require spacing for header
aquilesg Jul 30, 2024
5ce9c5d
DOn't render spaces before sentances start
aquilesg Jul 30, 2024
5a8186f
Adjust styling
aquilesg Jul 30, 2024
9b54112
Fix documentation for `:ObsidianNewFromTemplate`
epwalsh Jul 30, 2024
807b13d
chore(docs): auto generate docs
epwalsh Jul 30, 2024
fde4d10
Remove unused variables
aquilesg Jul 31, 2024
6220e17
Remove 'stack' implementation
aquilesg Jul 31, 2024
3e1a857
Adjust trailing space
aquilesg Jul 31, 2024
1b40797
Adjust again
aquilesg Jul 31, 2024
dd313c0
Adjust how tables are checked
aquilesg Jul 31, 2024
f8538c4
Adjust empty check again
aquilesg Jul 31, 2024
af0bcae
Merge branch 'main' into ISSUE-632-support-for-obsidian-callouts
aquilesg Jul 31, 2024
f12cf34
Fix styling issues
Jul 31, 2024
1688f24
Merge branch 'main' into ISSUE-632-support-for-obsidian-callouts
aquilesg Aug 1, 2024
ecb4505
Merge branch 'main' into ISSUE-632-support-for-obsidian-callouts
aquilesg Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added
- Added: Support for UI highlights on calloutblocks
- Added: Support for custom callout block defintions

## [v3.9.0](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.9.0) - 2024-07-11

### Added
Expand Down
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,97 @@ This is a complete list of all of the options that can be passed to `require("ob
enable = true, -- set to false to disable all additional syntax features
update_debounce = 200, -- update delay after a text change (in milliseconds)
max_file_length = 5000, -- disable UI features for files with more than this many lines

-- Define / create custom callouts
callouts = {
-- This is how the Callout will be rendered after the char
-- ex: <char>Note
["Note"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutNote",
},
["Abstract"] = {
aliases = {
"Summary",
"Tldr",
},
char = "",
hl_group = "ObsidianCalloutAbstract",
},
["Info"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutInfo",
},
["Todo"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutTodo",
},
["Tip"] = {
aliases = {
"Hint",
"Important",
},
char = "󰈸",
hl_group = "ObsidianCalloutTip",
},
["Success"] = {
aliases = {
"Check",
"Done",
},
char = "󰄬",
hl_group = "ObsidianCalloutSuccess",
},
["Question"] = {
aliases = {
"Help",
"FAQ",
},
char = "",
hl_group = "ObsidianCalloutQuestion",
},
["Warning"] = {
aliases = {
"Caution",
"Attentition",
},
char = "",
hl_group = "ObsidianCalloutWarning",
},
["Failure"] = {
aliases = {
"Fail",
"Missing",
},
char = "",
hl_group = "ObsidianCalloutFailure",
},
["Danger"] = {
aliases = {
"Error",
},
char = "",
hl_group = "ObsidianCalloutDanger",
},
["Bug"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutBug",
},
["Example"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutExample",
},
["Quote"] = {
aliases = {},
char = "󱆨",
hl_group = "ObsidianCalloutQuote",
},
},
-- Define how various check-boxes are displayed
checkboxes = {
-- NOTE: the 'char' value has to be a single character, and the highlight groups are defined below.
Expand Down Expand Up @@ -510,6 +601,20 @@ This is a complete list of all of the options that can be passed to `require("ob
ObsidianTag = { italic = true, fg = "#89ddff" },
ObsidianBlockID = { italic = true, fg = "#89ddff" },
ObsidianHighlightText = { bg = "#75662e" },
-- Callout highlights
ObsidianCalloutNote = { bg = "#1072b8" },
ObsidianCalloutAbstract = { bg = "#d7e6fa" },
ObsidianCalloutInfo = { bg = "#6a93e5" },
ObsidianCalloutTodo = { bg = "#6a93e5" },
ObsidianCalloutTip = { bg = "#d7e6fa" },
ObsidianCalloutSuccess = { bg = "#9fc360" },
ObsidianCalloutQuestion = { bg = "#faebd7" },
ObsidianCalloutWarning = { bg = "#faebd7" },
ObsidianCalloutFailure = { bg = "#ee5d5c" },
ObsidianCalloutDanger = { bg = "#ee5d5c" },
ObsidianCalloutBug = { bg = "#ee5d5c" },
ObsidianCalloutExample = { bg = "#c792ea" },
ObsidianCalloutQuote = { bg = "#E9F0FD" },
},
},

Expand Down
108 changes: 108 additions & 0 deletions lua/obsidian/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ end
---@field enable boolean
---@field update_debounce integer
---@field max_file_length integer|?
---@field callouts table<string, obsidian.config.CalloutSpec>
---@field checkboxes table<string, obsidian.config.CheckboxSpec>
---@field bullets obsidian.config.UICharSpec|?
---@field external_link_icon obsidian.config.UICharSpec
Expand All @@ -422,6 +423,12 @@ config.UIOpts = {}
---@field hl_group string
---@field order integer

---@class obsidian.config.CalloutSpec : obsidian.config.UICharSpec
---
---@field aliases table<string>
---@field hl_group string
---@field char string

---@class obsidian.config.UIStyleSpec
---
---@field hl_group string
Expand All @@ -432,6 +439,93 @@ config.UIOpts.default = function()
enable = true,
update_debounce = 200,
max_file_length = 5000,
callouts = {
["Note"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutNote",
},
["Abstract"] = {
aliases = {
"Summary",
"Tldr",
},
char = "",
hl_group = "ObsidianCalloutAbstract",
},
["Info"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutInfo",
},
["Todo"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutTodo",
},
["Tip"] = {
aliases = {
"Hint",
"Important",
},
char = "󰈸",
hl_group = "ObsidianCalloutTip",
},
["Success"] = {
aliases = {
"Check",
"Done",
},
char = "󰄬",
hl_group = "ObsidianCalloutSuccess",
},
["Question"] = {
aliases = {
"Help",
"FAQ",
},
char = "",
hl_group = "ObsidianCalloutQuestion",
},
["Warning"] = {
aliases = {
"Caution",
"Attentition",
},
char = "",
hl_group = "ObsidianCalloutWarning",
},
["Failure"] = {
aliases = {
"Fail",
"Missing",
},
char = "",
hl_group = "ObsidianCalloutFailure",
},
["Danger"] = {
aliases = {
"Error",
},
char = "",
hl_group = "ObsidianCalloutDanger",
},
["Bug"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutBug",
},
["Example"] = {
aliases = {},
char = "",
hl_group = "ObsidianCalloutExample",
},
["Quote"] = {
aliases = {},
char = "󱆨",
hl_group = "ObsidianCalloutQuote",
},
},
checkboxes = {
[" "] = { order = 1, char = "󰄱", hl_group = "ObsidianTodo" },
["~"] = { order = 2, char = "󰰱", hl_group = "ObsidianTilde" },
Expand All @@ -457,6 +551,20 @@ config.UIOpts.default = function()
ObsidianTag = { italic = true, fg = "#89ddff" },
ObsidianBlockID = { italic = true, fg = "#89ddff" },
ObsidianHighlightText = { bg = "#75662e" },
-- Callout highlights
ObsidianCalloutNote = { bg = "#1072b8" },
ObsidianCalloutAbstract = { bg = "#d7e6fa" },
ObsidianCalloutInfo = { bg = "#6a93e5" },
ObsidianCalloutTodo = { bg = "#6a93e5" },
ObsidianCalloutTip = { bg = "#d7e6fa" },
ObsidianCalloutSuccess = { bg = "#9fc360" },
ObsidianCalloutQuestion = { bg = "#faebd7" },
ObsidianCalloutWarning = { bg = "#faebd7" },
ObsidianCalloutFailure = { bg = "#ee5d5c" },
ObsidianCalloutDanger = { bg = "#ee5d5c" },
ObsidianCalloutBug = { bg = "#ee5d5c" },
ObsidianCalloutExample = { bg = "#c792ea" },
ObsidianCalloutQuote = { bg = "#E9F0FD" },
},
}
end
Expand Down
1 change: 1 addition & 0 deletions lua/obsidian/search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ M.Patterns = {

-- Miscellaneous
Highlight = "==[^=]+==", -- ==text==
Callout = "%[!.*%]",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't callouts always start with ">"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's right


-- References
WikiWithAlias = "%[%[[^][%|]+%|[^%]]+%]%]", -- [[xxx|yyy]]
Expand Down
Loading