Skip to content

Commit 779a568

Browse files
chore: Fix types and remove unused code
1 parent be396b9 commit 779a568

File tree

8 files changed

+36
-66
lines changed

8 files changed

+36
-66
lines changed

lua/orgmode/capture/_meta.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---@meta
2+
3+
---@class OrgProcessRefileOpts
4+
---@field source_headline OrgHeadline
5+
---@field destination_file? OrgFile
6+
---@field destination_headline? OrgHeadline
7+
---@field lines? string[]
8+
---@field message? string
9+
10+
---@class OrgProcessCaptureOpts
11+
---@field template OrgCaptureTemplate
12+
---@field source_file OrgFile
13+
---@field source_headline? OrgHeadline
14+
---@field destination_file OrgFile
15+
---@field destination_headline? OrgHeadline
16+
17+
---@class OrgDatetreeTreeItem
18+
---@field format string - The lua date format to use for the tree item
19+
---@field pattern string - Pattern to match important date parts the date format
20+
---@field order number[] - Order of checking the date parts matched from the pattern
21+
22+
---@class OrgCaptureTemplateDatetreeOpts
23+
---@field date OrgDate
24+
---@field time_prompt? boolean
25+
---@field reversed? boolean
26+
---@field tree? OrgDatetreeTreeItem[]
27+
---@field tree_type? 'day' | 'week' | 'month' | 'custom'
28+
29+
---@alias OrgCaptureTemplateDatetree boolean | OrgCaptureTemplateDatetreeOpts

lua/orgmode/capture/init.lua

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ local CaptureWindow = require('orgmode.capture.window')
88
local Date = require('orgmode.objects.date')
99
local Datetree = require('orgmode.capture.template.datetree')
1010

11-
---@class OrgProcessRefileOpts
12-
---@field source_headline OrgHeadline
13-
---@field destination_file? OrgFile
14-
---@field destination_headline? OrgHeadline
15-
---@field lines? string[]
16-
---@field message? string
17-
18-
---@class OrgProcessCaptureOpts
19-
---@field template OrgCaptureTemplate
20-
---@field source_file OrgFile
21-
---@field source_headline? OrgHeadline
22-
---@field destination_file OrgFile
23-
---@field destination_headline? OrgHeadline
24-
2511
---@class OrgCapture
2612
---@field templates OrgCaptureTemplates
2713
---@field closing_note OrgCaptureWindow
@@ -30,11 +16,11 @@ local Datetree = require('orgmode.capture.template.datetree')
3016
local Capture = {}
3117
Capture.__index = Capture
3218

33-
---@param opts { files: OrgFiles }
19+
---@param opts { files: OrgFiles, templates?: OrgCaptureTemplates }
3420
function Capture:new(opts)
3521
local this = setmetatable({}, self)
3622
this.files = opts.files
37-
this.templates = Templates:new()
23+
this.templates = opts.templates or Templates:new()
3824
this.closing_note = this:_setup_closing_note()
3925
return this
4026
end

lua/orgmode/capture/template/init.lua

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ local expansions = {
3434
end,
3535
}
3636

37-
---@class OrgDatetreeTreeItem
38-
---@field format string - The lua date format to use for the tree item
39-
---@field pattern string - Pattern to match important date parts the date format
40-
---@field order number[] - Order of checking the date parts matched from the pattern
41-
42-
---@class OrgCaptureTemplateDatetreeOpts
43-
---@field date OrgDate
44-
---@field time_prompt? boolean
45-
---@field reversed? boolean
46-
---@field tree? OrgDatetreeTreeItem[]
47-
---@field tree_type? 'day' | 'week' | 'month' | 'custom'
48-
49-
---@alias OrgCaptureTemplateDatetree boolean | OrgCaptureTemplateDatetreeOpts
50-
5137
---@class OrgCaptureTemplate
5238
---@field description? string
5339
---@field template? string|string[]

lua/orgmode/config/init.lua

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,6 @@ end
127127

128128
function Config:_deprecation_notify(opts)
129129
local messages = {}
130-
if
131-
opts.mappings
132-
and opts.mappings.org
133-
and (opts.mappings.org.org_increase_date or opts.mappings.org.org_decrease_date)
134-
then
135-
table.insert(
136-
messages,
137-
'org_increase_date/org_decrease_date mappings are deprecated in favor of org_timestamp_up/org_timestamp_down (More granular increase/decrease).'
138-
)
139-
table.insert(messages, 'See https://github.com/nvim-orgmode/orgmode/blob/tree-sitter/DOCS.md#changelog')
140-
if opts.mappings.org.org_increase_date then
141-
opts.mappings.org.org_timestamp_up = opts.mappings.org.org_increase_date
142-
end
143-
if opts.mappings.org.org_decrease_date then
144-
opts.mappings.org.org_timestamp_down = opts.mappings.org.org_decrease_date
145-
end
146-
end
147-
148130
if opts.org_indent_mode and type(opts.org_indent_mode) == 'string' then
149131
table.insert(
150132
messages,
@@ -369,7 +351,7 @@ function Config:setup_ts_predicates()
369351
end
370352

371353
return false
372-
end, true)
354+
end, { force = true })
373355

374356
vim.treesitter.query.add_predicate('org-is-valid-priority?', function(match, _, source, predicate)
375357
local node = match[predicate[2]]
@@ -404,7 +386,7 @@ function Config:setup_ts_predicates()
404386
local todo_text = vim.treesitter.get_node_text(prev_sibling, source)
405387
local is_prev_sibling_todo_keyword = todo_keywords[todo_text] and true or false
406388
return is_prev_sibling_todo_keyword
407-
end, true)
389+
end, { force = true })
408390

409391
vim.treesitter.query.add_directive('org-set-block-language!', function(match, _, bufnr, pred, metadata)
410392
local lang_node = match[pred[2]]
@@ -416,7 +398,7 @@ function Config:setup_ts_predicates()
416398
return
417399
end
418400
metadata['injection.language'] = utils.detect_filetype(text) or text
419-
end, true)
401+
end, { force = true })
420402
end
421403

422404
---@param content table

lua/orgmode/files/elements/table/cell.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function TableCell:to_string()
5555
return self.content
5656
end
5757

58-
---@param data table
58+
---@param data table | string
5959
---@param col_number number
6060
---@param row OrgTableRow
6161
---@return OrgTableCell

lua/orgmode/files/file.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local Link = require('orgmode.org.hyperlinks.link')
1616
---@field lines string[]
1717
---@field content string
1818
---@field metadata OrgFileMetadata
19-
---@field parser LanguageTree
19+
---@field parser vim.treesitter.LanguageTree
2020
---@field root TSNode
2121
local OrgFile = {}
2222

lua/orgmode/objects/edit_special/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local Help = require('orgmode.objects.help')
21
local config = require('orgmode.config')
32
local ts_utils = require('orgmode.utils.treesitter')
43
local utils = require('orgmode.utils')

lua/orgmode/org/syntax.lua

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)