Skip to content

Commit 0b14c09

Browse files
author
Kristijan Husak
committed
Auto format code with stylua.
1 parent 1eb42ae commit 0b14c09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1702
-1166
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10+
- uses: JohnnyMorganz/[email protected]
11+
with:
12+
token: ${{ secrets.GITHUB_TOKEN }}
13+
# CLI arguments
14+
args: --check lua/ tests/
1015
- name: Install Plenary
1116
uses: actions/checkout@v2
1217
with:

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ test:
22
nvim --headless --noplugin -u tests/minimal_init.vim -c "PlenaryBustedDirectory tests/plenary/ {minimal_init = 'tests/minimal_init.vim'}"
33
docs:
44
md2vim -desc "*orgmode* *orgmode.nvim*\n* NOTE: This file is autogenerated from DOCS.md file" DOCS.md doc/orgmode.txt
5+
format:
6+
stylua lua/ tests/

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ make test
194194
### Documentation
195195
Vim documentation is auto generated from [DOCS.md](DOCS.md) file with [md2vim](https://github.com/FooSoft/md2vim).
196196

197+
### Formatting
198+
Formatting is done via [StyLua](https://github.com/JohnnyMorganz/StyLua). To format everything run:
199+
```
200+
make format
201+
```
202+
197203
### Parser
198204
Parser is written manually from scratch. It doesn't follow any parser writing patterns (AFAIK), because I don't have
199205
much experience with those. Any help on this topic is appreciated.

lua/orgmode/agenda/agenda_item.lua

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ local hl_map = Highlights.get_agenda_hl_map()
33
local config = require('orgmode.config')
44
local FUTURE_DEADLINE_AS_WARNING_DAYS = math.floor(config.org_deadline_warning_days / 2)
55
local function add_padding(datetime)
6-
if datetime:len() >= 11 then return datetime..' ' end
7-
return datetime..string.rep('.', 11 - datetime:len())..' '
6+
if datetime:len() >= 11 then
7+
return datetime .. ' '
8+
end
9+
return datetime .. string.rep('.', 11 - datetime:len()) .. ' '
810
end
911

1012
---@class AgendaItem
@@ -20,7 +22,6 @@ end
2022
---@field highlights table[]
2123
local AgendaItem = {}
2224

23-
2425
---@param headline_date Date single date in a headline
2526
---@param headline Headline
2627
---@param date Date date for which item should be rendered
@@ -60,25 +61,38 @@ function AgendaItem:_process()
6061
end
6162

6263
function AgendaItem:_is_valid_for_today()
63-
if not self.headline_date.active or self.headline_date:is_closed() or self.headline_date:is_obsolete_range_end() then return false end
64+
if not self.headline_date.active or self.headline_date:is_closed() or self.headline_date:is_obsolete_range_end() then
65+
return false
66+
end
6467
if self.headline_date:is_none() then
6568
return self.is_same_day or self.is_in_date_range
6669
end
6770

6871
if self.headline_date:is_deadline() then
69-
if self.headline:is_done() and config.org_agenda_skip_deadline_if_done then return false end
70-
if self.is_same_day then return true end
72+
if self.headline:is_done() and config.org_agenda_skip_deadline_if_done then
73+
return false
74+
end
75+
if self.is_same_day then
76+
return true
77+
end
7178
if self.headline_date:is_before(self.date, 'day') then
7279
return not self.headline:is_done()
7380
end
74-
return not self.headline:is_done() and self.date:is_between(self.headline_date:get_adjusted_date(), self.headline_date, 'day')
81+
return not self.headline:is_done()
82+
and self.date:is_between(self.headline_date:get_adjusted_date(), self.headline_date, 'day')
7583
end
7684

77-
if self.headline:is_done() and config.org_agenda_skip_scheduled_if_done then return false end
85+
if self.headline:is_done() and config.org_agenda_skip_scheduled_if_done then
86+
return false
87+
end
7888

7989
if not self.headline_date:get_negative_adjustment() then
80-
if self.is_same_day then return true end
81-
if self.headline_date:is_before(self.date, 'day') and not self.headline:is_done() then return true end
90+
if self.is_same_day then
91+
return true
92+
end
93+
if self.headline_date:is_before(self.date, 'day') and not self.headline:is_done() then
94+
return true
95+
end
8296
return false
8397
end
8498

@@ -90,7 +104,9 @@ function AgendaItem:_is_valid_for_today()
90104
end
91105

92106
function AgendaItem:_is_valid_for_date()
93-
if not self.headline_date.active or self.headline_date:is_closed() or self.headline_date:is_obsolete_range_end() then return false end
107+
if not self.headline_date.active or self.headline_date:is_closed() or self.headline_date:is_obsolete_range_end() then
108+
return false
109+
end
94110

95111
if self.headline:is_done() then
96112
if self.headline_date:is_deadline() and config.org_agenda_skip_deadline_if_done then
@@ -112,33 +128,35 @@ function AgendaItem:_generate_label()
112128
local time = not self.headline_date.date_only and add_padding(self.headline_date:format_time()) or ''
113129
if self.headline_date:is_deadline() then
114130
if self.is_same_day then
115-
return time..'Deadline:'
131+
return time .. 'Deadline:'
116132
end
117-
return self.headline_date:humanize(self.date)..':'
133+
return self.headline_date:humanize(self.date) .. ':'
118134
end
119135

120136
if self.headline_date:is_scheduled() then
121137
if self.is_same_day then
122-
return time..'Scheduled:'
138+
return time .. 'Scheduled:'
123139
end
124140

125141
local diff = math.abs(self.date:diff(self.headline_date))
126142

127-
return 'Sched. '..diff..'x:'
143+
return 'Sched. ' .. diff .. 'x:'
128144
end
129145

130146
if self.headline_date.is_date_range_start then
131-
if not self.is_in_date_range then return time end
147+
if not self.is_in_date_range then
148+
return time
149+
end
132150
local range = string.format('(%d/%d):', self.date:diff(self.headline_date) + 1, self.date_range_days)
133151
if not self.is_same_day then
134152
return range
135153
end
136-
return time..range
154+
return time .. range
137155
end
138156

139157
if self.headline_date.is_date_range_end then
140158
local range = string.format('(%d/%d):', self.date_range_days, self.date_range_days)
141-
return time..range
159+
return time .. range
142160
end
143161

144162
return time
@@ -172,12 +190,14 @@ function AgendaItem:_generate_highlight()
172190
end
173191

174192
function AgendaItem:_add_keyword_highlight()
175-
if self.headline.todo_keyword.value == '' then return end
193+
if self.headline.todo_keyword.value == '' then
194+
return
195+
end
176196
local hlgroup = hl_map[self.headline.todo_keyword.value]
177197
if hlgroup then
178198
table.insert(self.highlights, {
179199
hlgroup = hlgroup,
180-
todo_keyword = self.headline.todo_keyword.value
200+
todo_keyword = self.headline.todo_keyword.value,
181201
})
182202
end
183203
end

0 commit comments

Comments
 (0)