Skip to content

Commit b53765b

Browse files
Price Hillerkristijanhusak
Price Hiller
andauthored
feat: add org-indent-mode-turns-on-hiding-stars equivalent (#659)
* feat: add equivalent of `org-indent-mode-turns-on-hiding-stars` * docs: add documentation for `org_indent_mode_turns_on_hiding_stars` * docs: add reference to `org_indent_mode` for hiding stars Co-authored-by: Kristijan Husak <[email protected]> * fix: ensure hl group for hiding stars is applied See #659 (review) Co-authored-by: Kristijan Husak <[email protected]> --------- Co-authored-by: Kristijan Husak <[email protected]>
1 parent 7a91a83 commit b53765b

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

DOCS.md

+8
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ Possible values:
296296
* `true` - Disable [`org_adapt_indentation`](#org_adapt_indentation) by default when [`org_startup_indented`](#org_startup_indented) is enabled.
297297
* `false` - Do not disable [`org_adapt_indentation`](#org_adapt_indentation) by default when [`org_startup_indented`](#org_startup_indented) is enabled.
298298

299+
#### **org_indent_mode_turns_on_hiding_stars**
300+
301+
*type*: `boolean`<br />
302+
*default value*: `true`<br />
303+
Possible values:
304+
* `true` - Enable [`org_hide_leading_stars`](#org_hide_leading_stars) by default when [`org_indent_mode`](#org_startup_indented) is enabled for buffer (`vim.b.org_indent_mode = true`).
305+
* `false` - Do not modify the value in [`org_hide_leading_stars`](#org_hide_leading_stars) by default when [`.org_indent_mode`](#org_startup_indented) is enabled for buffer (`vim.b.org_indent_mode = true`).
306+
299307
#### **org_src_window_setup**
300308
*type*: `string|function`<br />
301309
*default value*: "top 16new"<br />

lua/orgmode/colors/highlighter/stars.lua

+13-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,20 @@ function OrgStars:new(opts)
1414
return data
1515
end
1616

17+
function OrgStars:_is_enabled(bufnr)
18+
if config.org_hide_leading_stars then
19+
return true
20+
end
21+
22+
if vim.b[bufnr].org_indent_mode and config.org_indent_mode_turns_on_hiding_stars then
23+
return true
24+
end
25+
26+
return false
27+
end
28+
1729
function OrgStars:on_line(bufnr, line)
18-
if not config.org_hide_leading_stars then
30+
if not self:_is_enabled(bufnr) then
1931
return
2032
end
2133

lua/orgmode/colors/highlights.lua

+4-6
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,11 @@ function M.define_org_headline_colors(faces)
102102
for _, face in pairs(faces) do
103103
table.insert(contains, face)
104104
end
105-
if config.org_hide_leading_stars then
106-
if not ts_highlights_enabled then
107-
vim.cmd([[syn match OrgHideLeadingStars /^\*\{2,\}/me=e-1 contained]])
108-
end
109-
vim.cmd([[hi default OrgHideLeadingStars ctermfg=0 guifg=bg]])
110-
table.insert(contains, 'OrgHideLeadingStars')
105+
if not ts_highlights_enabled then
106+
vim.cmd([[syn match OrgHideLeadingStars /^\*\{2,\}/me=e-1 contained]])
111107
end
108+
vim.cmd([[hi default OrgHideLeadingStars ctermfg=0 guifg=bg]])
109+
table.insert(contains, 'OrgHideLeadingStars')
112110
for i, color in ipairs(headline_colors) do
113111
local j = i
114112
while j < 40 do

lua/orgmode/config/defaults.lua

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ local DefaultConfig = {
3939
org_adapt_indentation = true,
4040
org_startup_indented = false,
4141
org_indent_mode_turns_off_org_adapt_indentation = true,
42+
org_indent_mode_turns_on_hiding_stars = true,
4243
org_time_stamp_rounding_minutes = 5,
4344
org_blank_before_new_entry = {
4445
heading = true,

0 commit comments

Comments
 (0)