85 lines
2.6 KiB
Diff
85 lines
2.6 KiB
Diff
diff --git a/lua/orgmode/init.lua b/lua/orgmode/init.lua
|
|
index 3b72f78..046a02e 100644
|
|
--- a/lua/orgmode/init.lua
|
|
+++ b/lua/orgmode/init.lua
|
|
@@ -1,11 +1,9 @@
|
|
_G.orgmode = _G.orgmode or {}
|
|
-local ts_revision = '081179c52b3e8175af62b9b91dc099d010c38770'
|
|
-local setup_ts_grammar_used = false
|
|
local instance = nil
|
|
|
|
---@class Org
|
|
---@field initialized boolean
|
|
---@field files Files
|
|
---@field agenda Agenda
|
|
---@field capture Capture
|
|
---@field clock Clock
|
|
@@ -60,52 +58,21 @@ function Org:setup_autocmds()
|
|
pattern = 'org',
|
|
group = org_augroup,
|
|
callback = function()
|
|
require('orgmode').reload(vim.fn.expand('<afile>:p'))
|
|
end,
|
|
})
|
|
end
|
|
|
|
---- @param revision string?
|
|
-local function setup_ts_grammar(revision)
|
|
- setup_ts_grammar_used = true
|
|
- local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
|
|
- parser_config.org = {
|
|
- install_info = {
|
|
- url = 'https://github.com/milisims/tree-sitter-org',
|
|
- revision = revision or ts_revision,
|
|
- files = { 'src/parser.c', 'src/scanner.cc' },
|
|
- },
|
|
- filetype = 'org',
|
|
- }
|
|
-end
|
|
-
|
|
-local function check_ts_grammar()
|
|
- vim.defer_fn(function()
|
|
- if setup_ts_grammar_used then
|
|
- return
|
|
- end
|
|
- local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
|
|
- if parser_config and parser_config.org and parser_config.org.install_info.revision ~= ts_revision then
|
|
- require('orgmode.utils').echo_error({
|
|
- 'You are using outdated version of tree-sitter grammar for Orgmode.',
|
|
- 'To use latest version, replace current grammar installation with "require(\'orgmode\').setup_ts_grammar()" and run :TSUpdate org.',
|
|
- 'More info in setup section of readme: https://github.com/nvim-orgmode/orgmode#setup',
|
|
- })
|
|
- end
|
|
- end, 200)
|
|
-end
|
|
-
|
|
---@param opts? table
|
|
---@return Org
|
|
local function setup(opts)
|
|
opts = opts or {}
|
|
instance = Org:new()
|
|
- check_ts_grammar()
|
|
local config = require('orgmode.config'):extend(opts)
|
|
vim.defer_fn(function()
|
|
if config.notifications.enabled and #vim.api.nvim_list_uis() > 0 then
|
|
require('orgmode.parser.files').load(vim.schedule_wrap(function()
|
|
instance.notifications = require('orgmode.notifications'):new():start_timer()
|
|
end))
|
|
end
|
|
config:setup_mappings('global')
|
|
@@ -187,15 +154,14 @@ end
|
|
function _G.orgmode.statusline()
|
|
if not instance or not instance.initialized then
|
|
return ''
|
|
end
|
|
return instance.statusline_debounced() or ''
|
|
end
|
|
|
|
return {
|
|
- setup_ts_grammar = setup_ts_grammar,
|
|
setup = setup,
|
|
reload = reload,
|
|
action = action,
|
|
cron = cron,
|
|
instance = get_instance,
|
|
}
|