diff --git a/lua/neorg/modules/core/defaults/module.lua b/lua/neorg/modules/core/defaults/module.lua index 7408a4ace..cca061e70 100644 --- a/lua/neorg/modules/core/defaults/module.lua +++ b/lua/neorg/modules/core/defaults/module.lua @@ -39,7 +39,6 @@ return neorg.modules.create_meta( "core.looking-glass", "core.mode", "core.neorgcmd", - "core.news", "core.pivot", "core.promo", "core.qol.toc", diff --git a/lua/neorg/modules/core/news/data/0.0.10.norg b/lua/neorg/modules/core/news/data/0.0.10.norg deleted file mode 100644 index 96b02a576..000000000 --- a/lua/neorg/modules/core/news/data/0.0.10.norg +++ /dev/null @@ -1,97 +0,0 @@ -| 0.0.10 - -* Changes to Core - ** Keybind Changes - There have been some breaking changes in how keybinds are being handled. - They're now much nicer to deal with and don't require as much tinkering. - - Let's talk about what changed exactly: - - *** Defaults - **** Default Keybinds Enabled by Default - By loading `core.keybinds` Neorg now assumes that you want default - keybinds to be enabled. You can disable this with: - - @code lua - ["core.keybinds"] = { - config = { - default_keybinds = false, - } - } - @end - - In your Neorg config. - - **** `` - Neorg now uses `` as the default Neorg leader, allowing you to set it manually - yourself in your config. - - *** Ways to Change Keybinds - We've drastically improved upon how keybinds are handled internally. - Changing just one or a few keys is much easier than before, here's how you do it. - - First, you want to add a `hook` to your keybinds config: - - @code lua - ["core.keybinds"] = { - config = { - hook = function(keybinds) - -- Modifications here - end, - } - } - @end - - This hook gives you a `keybinds` table which provides several functions to map keys. - If {*** Defaults}[`default_keybinds`] is set to `true` then you'll most probably find yourself - remapping existing keys or mapping extra keys on top. - - Here are all the new functions (taken from {https://github.com/nvim-neorg/neorg/wiki/User-Keybinds}[this] page). - - @code lua - ["core.keybinds"] = { - config = { - hook = function(keybinds) - -- Unmaps any Neorg key from the `norg` mode - keybinds.unmap("norg", "n", "gtd") - - -- Binds the `gtd` key in `norg` mode to execute `:echo 'Hello'` - keybinds.map("norg", "n", "gtd", "echo 'Hello!'") - - -- Remap unbinds the current key then rebinds it to have a different action - -- associated with it. - -- The following is the equivalent of the `unmap` and `map` calls you saw above: - keybinds.remap("norg", "n", "gtd", "echo 'Hello!'") - - -- Sometimes you may simply want to rebind the Neorg action something is bound to - -- versus remapping the entire keybind. This remap is essentially the same as if you - -- did `keybinds.remap("norg", "n", ", "Neorg keybind norg core.norg.qol.todo_items.todo.task_done") - keybinds.remap_event("norg", "n", "", "core.norg.qol.todo_items.todo.task_done") - - -- Want to move one keybind into the other? `remap_key` moves the data of the - -- first keybind to the second keybind, then unbinds the first keybind. - keybinds.remap_key("norg", "n", "", "t") - end, - } - } - @end - - ** Links - By default links are now case-insensitive (but still punctuation sensitive!). Be aware of that now when writing links :) - - ** Metadata Generation - In this version metadata generation has been *disabled* by default. Use `:Neorg inject-metadata` to inject metadata into the document - whenever you feel like it. - - You can reenable automatic metagen through: - - @code lua - ["core.norg.esupports.metagen"] = { - config = { - type = "auto", - } - } - @end - - We've also removed the ability to provide a keybind in the `type` field (who thought that was a good idea anyway? oh wait it was me). - Now `type` can only be `none` or `auto`. diff --git a/lua/neorg/modules/core/news/data/0.0.13.norg b/lua/neorg/modules/core/news/data/0.0.13.norg deleted file mode 100644 index acf6670a7..000000000 --- a/lua/neorg/modules/core/news/data/0.0.13.norg +++ /dev/null @@ -1,21 +0,0 @@ -| 0.0.13 - -* Breakages in Highlights - For the uninitiated, treesitter recently had a {https://github.com/neovim/neovim/pull/19931}[breaking change] - related to the way it handles highlight groups and captures. - - This is a very welcome change, and in my opinion is the future of how we will - deal with highlights in Neovim, but it came with the cost of me having to - refactor major parts of Neorg for around 5/6 hours :( - - As a result, the following changes have occurred: - - Neorg is now stricty reliant on Neovim `0.8+`. You can always use the - `0.0.12` tag alongside an earlier version of treesitter to combat this, - however if you have updated other plugins then it may already be too late. - I've tried to make things backwards compatible, but then quickly realized - it's impossible. Sorry! - - Assume that all custom Neorg highlights you may have set are broken. You'll need - to do some solid refactoring. To see all the key/values consult - {https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/highlights/module.lua#L23}[this part of the source code]. - - Some highlights may have accidentally stop working - if they have, let me - know via a github issue! diff --git a/lua/neorg/modules/core/news/data/0.0.17.norg b/lua/neorg/modules/core/news/data/0.0.17.norg deleted file mode 100644 index a5c27959a..000000000 --- a/lua/neorg/modules/core/news/data/0.0.17.norg +++ /dev/null @@ -1,26 +0,0 @@ -* `0.0.17` -** The Upgrade Tool is in! - /It's happening./ - - This is the first step of the incremental merge to new, shiny `1.0` syntax. - The first step is to create a tool that can convert from the old syntax to - the new one, introducing `core.upgrade`! - - If you could, please try out the upgrade tool on some less important files: - - `:Neorg upgrade current-file` - upgrades the current file in-place (with the - option to create a backup) - - `:Neorg upgrade current-directory` - recursively upgrades all files in the - current directory (also asks to create a backup) - - We'll give a slight grace period to users who want to test out the tool, submit - bug reports, missing features etc. After we feel the tool is capable enough we will - merge the {https://github.com/nvim-neorg/neorg/pull/621}[new syntax branch], after - which using the new syntax will be mandatory on the `main` branch. - -** GTD will be removed soon - Be warned! GTD is going to receive a /complete/ rewrite after the new syntax is merged, - that is, the whole of GTD will be removed. After the new syntax is merged, the `1.0` - version of Neorg will be released *without GTD*. - - After this, GTD will become more performant, more integrated, and will use the latest - syntax niceties of `Norg 1.0`. diff --git a/lua/neorg/modules/core/news/data/0.0.8.norg b/lua/neorg/modules/core/news/data/0.0.8.norg deleted file mode 100644 index 371b44817..000000000 --- a/lua/neorg/modules/core/news/data/0.0.8.norg +++ /dev/null @@ -1,148 +0,0 @@ -| 0.0.8 - -* *Breaking Changes* - There are quite a few breaking changes in this version. Pay attention here, you don't wanna miss this. - - ** Branch Changes - After this update we will soon be dropping the `unstable` branch of Neorg in favour of - utilizing PRs more. - - This means that users of the `unstable` branch will no longer receive updates. - Please migrate over to the `main` branch - we have cookies. - - ** Syntax Changes - If you're seeing this then it means Neorg has undergone /several/ changes to its file format - and/or internal structure. Be ready to refactor your documents. We'd love to provide tools - to make the migration process automatic, but it would be difficult to execute well and we - simply do not have the manpower to implement these sorts of things without taking several - weeks haha. Be sure to update your TreeSitter parser too! - - Here are all the things that we've changed: - - *** Link Syntax - *This one is probably the most impactful and important.* - We've realized that the markdown style of defining a link... isn't particularly the best. - You must always define a link description, even if you just want a location. Besides, - `*location` kind of breaks our syntax rules, right? There should always be a space after a - detached modifier like that. Anyway here's the new syntax: - - @code norg - This is a regular link with no special description: - {* A link to a level-1 heading} - You can add a description at the end of the link: - {* A link to a level-1 heading}[link text] - @end - - Apart from only defining a level-1 heading you can link to all of the items you could - previously, this includes: - - @code norg - Linking to markers, definitions: - {| Link to a marker} - {$ Link to a definition} - @end - - Not only that, we have the one, the only, magic link. It links to any item type: - - @code norg - {# Any item} - @end - - Linking to URLs requires no special symbol: - - @code norg - {https://github.com/nvim-neorg/neorg} - @end - - It's important to note that the link location is whitespace independent, however the - link system is case and punctuation sensitive. `{* Linklocation}` and `{* Link location}` - link to the same place, however `{* Link, location}` does not. - - *There have been some additions too:* - - You can now specify a link without a location and only a file (`{:neorg-file:}`) - -- Specifying a location with a file still works the same way: `{:neorg-file:* Location}`. - Don't forget the space between `*` and `Location`! - - You can now link to non-neorg files through the `@` symbol: `{@ non-neorg-file.txt}` - - Links now allow absolute paths - -- Doing `{:/some/file:* Location}` will now point directly to the root of your - filesystem. Beforehand Neorg would convert the `/` to the root of the workspace. - -- If you want to reference the root of your workspace you can use the `$` symbol: - `{:$/some/neorg/file:}`. -- You can now also reference different workspaces - altogether: `{:$workspace-name/some/neorg/file:}` - - You can no longer specify several paths to search within links, only a single one. - i.e. you can no longer do `{:file:another file:* Location}`. It's unnecessarily - complex and won't be used by many people. - - *** TODO Items - TODO items have seen a beautiful buff during our latest updates. First of all, we've - changed the pending symbol from `- [*]` to `- [-]`. This is for a few reasons. First - of all, it makes it easy for org users to transition; second of all, it's cause - we've added several new TODO item types: - - @code norg - - [ ] I'm an undone item - - [-] I'm a pending item - - [x] I'm a done item - - [?] I'm an uncertain item. Will I ever have to perform this task? I dunno. - - [!] *Urgent* task. Do it now! - - [=] On-hold task. If pending is one horizontal line, then an equals sign (two horizontal - lines) are one step further than pending. Use this for when you have to temporarily halt - what you were in the process of doing and have no way to complete the task. - - [_] Cancelled task. The underscore is supposed to signify a "put down" state. Useful for - when you don't want to delete the task from the buffer (in case you need it for future - reference) but also don't want it to counted as an real task you have to do. - - [+] Recurring task. This task doesn't have a deadline nor a reset timer. It's what we call a - "basic" recurrence. Whenever you complete all of the subtasks of this task it will - simply reset. - @end - - *** Definitions - We've also changed the syntax for definitions, although you may have already - realized this one. We've changed the `:` char to `$` to signify a definition: - - @code norg - $ Definition - This is now considered a definition, compared to the previous syntax that used `:` - @end - - *** Carryover Tags - We've changed the syntax for carryover tags - they are no longer `$tags like this`, - however they are now `#tags like this`. - - *** Inline Comments - We've changed inline comments to now be +comment+ instead of #comment#. The hashtag - is reserved for carryover tags. You can think of `+comment+` as being an addition to - your document, one that doesn't get rendered, hence the `+` symbol. - - *** Anchors - This isn't really a change, however it is a new syntax addition. Apart from just - links we've also created the idea of anchors! They're like a cross between links and - something like references or pointers if you know your programming terms. Basically - you can link to a name several times, then define the link location only once. - - Here's an example: - @code norg - I sincerely hope you visit our [github]!. - Have I mentioned our [github] yet? I think you'll like it. - Man, if only you guys visited our [github]{https://github.com/nvim-neorg/neorg} :P - @end - - Did you see what was done here? We created two /anchor declarations/ called - `github`. After that, we created an /anchor definition/ that actually defined the - link location. See? We no longer need to duplicate our links locations, since we can - define them only once! - - **** Don't get confused! - There's a *difference* between anchors and links, and I don't want people getting - confused here. Regular links have `{location}[text]` as an order. This is because - in links we care about emphasising the /location/. Anchors on the other hand have - `[text]{location}` as an order, and that's because we care about emphasising the - /text/. We bind text to a location, not a location to text. - - You may have also noticed another design choice. With links, you can completely - omit the description, like `{this}`, it's made like this for convenience. The text - is the second element of the link construct in that context. In - `[description]{this scenario}` you can omit the second element as well, however - then you get `[description]`, which is an anchor declaration. Do you see the - difference now? It's subtle, but makes a world of difference. Please don't confuse - anchors with links, and slap all your friends who get it wrong 😛. diff --git a/lua/neorg/modules/core/news/module.lua b/lua/neorg/modules/core/news/module.lua index bcc5b6169..1a8f3fe96 100644 --- a/lua/neorg/modules/core/news/module.lua +++ b/lua/neorg/modules/core/news/module.lua @@ -1,306 +1,13 @@ ---[[ - file: Displaying-News - title: It's like newspapers about Neorg... but digital! - description: `core.news` displays information about any breaking changes or important information about the state of Neorg. - summary: Handles the displaying of Neorg news and other forms of media in a popup. - --- -When any sort of critical event occurs within Neorg (a big breaking change is pushed or any other form -of noteworthy information) the next version of Neorg will ship with a new news file, which is then displayed -to you, the user. - -When a new bit of news is found, Neorg will prompt you with a message telling you which versions have news -that you have not viewed yet. The message will appear when Neovim starts up, and will permanently disappear -once you view (or dismiss) the news. - -To view all available news for every version, use `:Neorg news all`. To view only the news you haven't seen -yet, use `:Neorg news new`. Consequently, there is also a `:Neorg news old` command to view only seen news. - -To dismiss all news for the current version, use `:Neorg news dismiss`. This will not display the news, -and you may peacefully continue whatever you were doing previously. ---]] +require("neorg.external.log") local module = neorg.modules.create("core.news") -local function is_version_greater_than(ver1, ver2) - -- Here we assume that the versions aren't malformed - ver1, ver2 = neorg.utils.parse_version_string(ver1), neorg.utils.parse_version_string(ver2) - - return (ver1.major > ver2.major or ver1.minor > ver2.minor or ver1.patch > ver2.patch) - and (ver1.major >= ver2.major and ver1.minor >= ver2.minor and ver1.patch >= ver2.patch) -end - module.setup = function() + log.fatal("`core.news` has been deprecated since `v4.0.0`. Please remove the module from your configuration!") + return { - requires = { - "core.ui", - "core.storage", - "core.neorgcmd", - }, + success = false, } end -module.config.public = { - -- An "enable" switch - when true, will check for new news on startup. - -- If false, will not perform any operations. - check_news = true, -} - -module.load = function() - if not module.config.public.check_news then - return - end - - -- Get the cached Neorg version - local cached_neorg_version = module.required["core.storage"].retrieve(module.name).news_state - log.trace("Retrieved cached version from storage:", cached_neorg_version) - - if not cached_neorg_version then - log.trace("Cached version not found, storing current one:", neorg.configuration.version) - module.required["core.storage"].store(module.name, { - news_state = neorg.configuration.version, - }) - - return - end - - local path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") .. "/data/" - - vim.loop.fs_scandir(path, function(err, data) - local paths = {} - - assert(not err, "Unable to open Neorg news directory at '" .. path .. "'!") - - local entry = vim.loop.fs_scandir_next(data) - - while entry do - if vim.endswith(entry, ".norg") then - paths[entry:sub(1, -(string.len(".norg") + 1))] = path .. entry - end - - entry = vim.loop.fs_scandir_next(data) - end - - log.trace("Collected news entries:", paths) - - for version, filepath in pairs(paths) do - if is_version_greater_than(version, cached_neorg_version) then - log.trace("Version", version, "is greater than", cached_neorg_version) - - module.private.new_news[version] = filepath - else - module.private.old_news[version] = filepath - end - end - - local lib = neorg.lib - - local old_keys, new_keys = vim.tbl_keys(module.private.old_news), vim.tbl_keys(module.private.new_news) - - local commands_table = { - news = { - args = 1, - subcommands = { - old = { - name = "news.old", - max_args = 1, - subcommands = lib.construct(old_keys, function(key) - return { - args = 0, - name = "news.old." .. key, - } - end), - }, - new = { - name = "news.new", - max_args = 1, - subcommands = lib.construct(new_keys, function(key) - return { - args = 0, - name = "news.new." .. key, - } - end), - }, - all = { - name = "news.all", - args = 0, - }, - - dismiss = { - name = "news.dismiss", - args = 0, - }, - }, - }, - } - - module.required["core.neorgcmd"].add_commands_from_table(commands_table) - - module.events.subscribed = { - ["core.neorgcmd"] = lib.to_keys(lib.extract(commands_table.news.subcommands, "name"), true), - } - - if not vim.tbl_isempty(module.private.new_news) then - vim.schedule(function() - neorg.utils.notify(string.format( - [[ -There's some new Neorg news for you! - -New news for versions: %s - -Run `:Neorg news new ` to see the latest news for that specific version. -To view news for all new versions run `:Neorg news new` without arguments. - -To ignore the news for this version run `:Neorg news dismiss`. - ]], - table.concat(new_keys, ", ") - )) - end) - end - end) -end - -module.public = { - get_content = function(versions) - if not versions then - return - end - - versions = neorg.lib.unroll(versions) - - table.sort(versions, function(lhs, rhs) - return is_version_greater_than(lhs[1], rhs[1]) - end) - - local content = {} - - for _, location in ipairs(versions) do - -- Using libuv is totally overkill here - local file = io.open(location[2], "r") - - if not file then - file:close() - goto continue - end - - vim.list_extend( - content, - vim.split(file:read("*a"), "\n", { - plain = true, - }) - ) - - ::continue:: - end - - return content - end, - - create_display = function(content) - if not content then - return - end - - local buf = vim.api.nvim_create_buf(false, true) - - vim.api.nvim_buf_set_option(buf, "buftype", "nofile") - vim.api.nvim_buf_set_lines(buf, 0, -1, true, content) - vim.api.nvim_buf_set_option(buf, "modifiable", false) - vim.api.nvim_buf_set_option(buf, "filetype", "norg") - vim.api.nvim_buf_set_name(buf, "news.norg") - - vim.keymap.set("n", "q", vim.cmd.bdelete, { buffer = buf, silent = true }) - - -- Taken from nvim-lsp-installer at https://github.com/williamboman/nvim-lsp-installer/blob/main/lua/nvim-lsp-installer/ui/display.lua#L143-L157 - -- Big shoutout! I couldn't figure this out myself. - local win_height = vim.o.lines - vim.o.cmdheight - 2 -- Add margin for status and buffer line - local win_width = vim.o.columns - - local window_opts = { - relative = "editor", - height = math.floor(win_height * 0.9), - width = math.floor(win_width * 0.8), - style = "minimal", - border = "rounded", - } - - window_opts.row = math.floor((win_height - window_opts.height) / 2) - window_opts.col = math.floor((win_width - window_opts.width) / 2) - --- - - vim.api.nvim_create_autocmd("WinClosed", { - buffer = buf, - callback = function() - vim.api.nvim_buf_delete(buf, { force = true }) - end, - }) - - return vim.api.nvim_open_win(buf, true, window_opts) - end, -} - -module.private = { - old_news = {}, - new_news = {}, -} - -module.on_event = function(event) - neorg.lib.match(event.split_type[2])({ - ["news.all"] = function() - module.public.create_display( - module.public.get_content(vim.tbl_extend("error", module.private.old_news, module.private.new_news)) - ) - - module.required["core.storage"].store(module.name, { - news_state = neorg.configuration.version, - }) - end, - - ["news.old"] = function() - module.public.create_display(module.public.get_content(module.private.old_news)) - end, - - ["news.new"] = function() - module.public.create_display(module.public.get_content(module.private.new_news)) - - module.required["core.storage"].store(module.name, { - news_state = neorg.configuration.version, - }) - end, - - ["news.dismiss"] = function() - module.required["core.storage"].store(module.name, { - news_state = neorg.configuration.version, - }) - - neorg.utils.notify("Dismissed all news!") - end, - - _ = function() - if vim.startswith(event.split_type[2], "news.new.") then - local version = event.split_type[2]:sub(string.len("news.new.") + 1) - - module.public.create_display( - module.public.get_content({ [version] = module.private.new_news[version] }) - ) - - if - is_version_greater_than(version, module.required["core.storage"].retrieve(module.name).news_state) - then - module.required["core.storage"].store(module.name, { - news_state = version, - }) - end - else - local version = event.split_type[2]:sub(string.len("news.old.") + 1) - - module.public.create_display( - module.public.get_content({ [version] = module.private.old_news[version] }) - ) - end - end, - }) - - module.required["core.storage"].flush() -end - return module