plugins/ux: don't check tree-sitter orgmode

This commit is contained in:
Dmitriy Pleshevskiy 2022-11-02 01:14:06 +03:00
parent 019d8ae991
commit 0d27956624
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
3 changed files with 96 additions and 4 deletions

View File

@ -189,19 +189,27 @@
mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }:
let
inherit (builtins) getAttr;
inherit (builtins) getAttr attrNames pathExists readDir;
inherit (lib) listToAttrs nameValuePair;
buildPlugin = name: vimUtils.buildVimPluginFrom2Nix {
name = name;
src = getAttr name inputs;
patches = lib.mkIf
(pathExists ./patches/${name})
(map
(fn: ./pathes/${name}/${fn})
(attrNames (readDir ./patches/${name}))
);
};
buildPluginValuePair = n: nameValuePair n (buildPlugin n);
customPlugins = listToAttrs (map buildPluginValuePair inputPlugins);
customPlugins = (listToAttrs (map buildPluginValuePair inputPlugins));
in
{ vimPlugins = vimPlugins // customPlugins; };
{
vimPlugins = vimPlugins // customPlugins;
};
in
{
overlays = {

View File

@ -0,0 +1,85 @@
diff --git a/lua/orgmode/init.lua b/lua/orgmode/init.lua
index 274e004..7a25318 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
@@ -66,52 +64,21 @@ function Org:setup_autocmds()
pattern = { '*.org', '*.org_archive' },
group = org_augroup,
callback = function()
require('orgmode.org.diagnostics').report()
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')
@@ -185,15 +152,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,
}

View File

@ -1,4 +1,3 @@
require("orgmode").setup_ts_grammar()
require("orgmode").setup({
org_agenda_files = { "~/orgs/**/*" },
org_default_notes_file = "~/orgs/refile.org",