├── LICENSE ├── README.md └── lua └── neorg └── modules └── bookmarks ├── bookmark └── module.lua └── ui ├── capture_popup.lua └── module.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Simon H Moore 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Neorg Bookmark Manager 2 | **This project is not complete, not even started, I'm only capturing some ideas for reference and to allow other people to give ideas** 3 | 4 | This module for [Neorg](https://github.com/nvim-neorg/neorg) is to make your bookmarking life easier, the [Neorg](https://github.com/nvim-neorg/neorg) way. 5 | 6 | ## Features 7 | **Still a work in progress, these are only planned features** 8 | 9 | ### Create bookmarks with tags 10 | Bookmarks are simple [Neorg](https://github.com/nvim-neorg/neorg) links using contexts as tags. 11 | ``` 12 | #contexts tags, tags and more tags 13 | {url}[linktext] 14 | ``` 15 | 16 | ### Compile bookmarks 17 | Compile bookmarks into a bookmark.norg file for easy reference and search ability using telescope and other programs apart from neovim such as fzf or dmenu, I plan on writing a qutebrowser user script ;) 18 | `:Neorg bookmark compile` 19 | 20 | ### Similar interface to Neorg gtd 21 | To be consistent and probably so I can copy a bunch of code :p it will probably be similar in design to Neorg gtd `: Neorg bookmark capture|edit|views` 22 | 23 | 24 | ### Search bookmarks using telescope 25 | Probably using the [Telescope](https://github.com/nvim-telescope/telescope.nvim) module find bookmarks both locally and using the compiled bookmark file, I want to be able to search by tags as well. 26 | -------------------------------------------------------------------------------- /lua/neorg/modules/bookmarks/bookmark/module.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | BOOKMARK 3 | A Neorg module designed to create, edit, search and organise bookmarks 4 | --]] 5 | 6 | require('neorg.modules.base') 7 | require('neorg.events') 8 | 9 | local module = neorg.modules.create("bookmarks.bookmark") 10 | local log = require('neorg.external.log') 11 | 12 | module.setup = function() 13 | return { 14 | success = true, 15 | requires = { 16 | "core.neorgcmd", 17 | "core.keybinds", 18 | "bookmarks.ui", 19 | }, 20 | } 21 | end 22 | 23 | module.public = { 24 | version = "0.0.1", 25 | callbacks = {}, 26 | } 27 | 28 | module.load = function() 29 | 30 | -- Register keybinds 31 | module.required["core.keybinds"].register_keybinds(module.name, { "compile", "views", "edit", "capture" }) 32 | 33 | -- Add neorgcmd commands 34 | module.required["core.neorgcmd"].add_commands_from_table({ 35 | bookmark = { 36 | args = 1, 37 | subcommands = { 38 | compile = { args = 0, name = "bookmark.compile" }, 39 | views = { args = 0, name = "bookmark.views" }, 40 | edit = { args = 0, name = "bookmark.edit" }, 41 | capture = { args = 0, name = "bookmark.capture" }, 42 | }, 43 | }, 44 | }) 45 | 46 | -- Set up callbacks 47 | module.public.callbacks["bookmark.edit"] = module.private.error_loading_message 48 | or module.required["bookmarks.ui"].edit_bookmark_at_cursor 49 | 50 | module.public.callbacks["bookmark.capture"] = module.private.error_loading_message 51 | or module.required["bookmarks.ui"].show_capture_popup 52 | 53 | module.public.callbacks["bookmark.views"] = module.private.error_loading_message 54 | or module.required["bookmarks.ui"].show_views_popup 55 | 56 | module.public.callbacks["bookmark.compile"] = module.private.error_loading_message 57 | or module.required["bookmarks.ui"].compile 58 | end 59 | 60 | 61 | 62 | module.on_event = function(event) 63 | if vim.tbl_contains({ "core.keybinds", "core.neorgcmd" }, event.split_type[1]) then 64 | if vim.tbl_contains({ "bookmark.compile", "bookmarks.bookmark.compile" }, event.split_type[2]) then 65 | module.public.callbacks["bookmark.compile"]() 66 | 67 | elseif vim.tbl_contains({ "bookmark.views", "bookmarks.bookmark.views" }, event.split_type[2]) then 68 | module.public.callbacks["bookmark.views"]() 69 | 70 | elseif vim.tbl_contains({ "bookmark.edit", "bookmarks.bookmark.edit" }, event.split_type[2]) then 71 | module.public.callbacks["bookmark.edit"]() 72 | 73 | elseif vim.tbl_contains({ "bookmark.capture", "bookmarks.bookmark.capture" }, event.split_type[2]) then 74 | module.public.callbacks["bookmark.capture"]() 75 | end 76 | end 77 | end 78 | 79 | 80 | module.config.pulic = { 81 | -- the file name to compile bookmarks too 82 | compile_file = "bookmarks.norg", 83 | -- excluded files or directories from bookmark parsing 84 | exclude = {}, 85 | } 86 | 87 | module.events.subscribed = { 88 | ["core.keybinds"] = { 89 | ["bookmarks.bookmark.compile"] = true, 90 | ["bookmarks.bookmark.capture"] = true, 91 | ["bookmarks.bookmark.views"] = true, 92 | ["bookmarks.bookmark.edit"] = true, 93 | }, 94 | ["core.neorgcmd"] = { 95 | ["bookmark.compile"] = true, 96 | ["bookmark.views"] = true, 97 | ["bookmark.edit"] = true, 98 | ["bookmark.capture"] = true, 99 | }, 100 | } 101 | 102 | return module 103 | -------------------------------------------------------------------------------- /lua/neorg/modules/bookmarks/ui/capture_popup.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Submodule responsible for creating API for capture popup 3 | --]] 4 | 5 | local module = neorg.modules.extend("bookmarks.ui.capture_popup", "bookmarks.ui") 6 | 7 | module.public = { 8 | --- Creates the selection popup for capturing a bookmarks 9 | show_capture_popup = function() 10 | -- Generate views selection popup 11 | local buffer = module.required["core.ui"].create_split("Quick Actions") 12 | 13 | if not buffer then 14 | return 15 | end 16 | 17 | local selection = module.required["core.ui"] 18 | .begin_selection(buffer) 19 | :listener("destroy", { "" }, function(self) 20 | self:destroy() 21 | end) 22 | 23 | selection:title("Capture Bookmark"):blank():concat(module.private.capture_bookmark) 24 | module.public.display_messages() 25 | end, 26 | } 27 | 28 | module.private = { 29 | capture_bookmark = function(selection) 30 | return selection:title("Add a bookmark"):blank():prompt("URI", { 31 | callback = function(text) 32 | local bookmark = {} 33 | bookmark.uri = text 34 | 35 | selection:push_page() 36 | 37 | selection 38 | :title("General informations") 39 | :blank() 40 | :flag("x", "Add to cursor position", function() 41 | return 42 | end) 43 | :flag("", "Add to bookmarks", function() 44 | return 45 | end) 46 | 47 | return selection 48 | end, 49 | -- Do not pop or destroy the prompt when confirmed 50 | pop = false, 51 | destroy = false, 52 | }) 53 | end, 54 | } 55 | 56 | return module 57 | -------------------------------------------------------------------------------- /lua/neorg/modules/bookmarks/ui/module.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | UI 3 | 4 | This module is a sub-module for `bookmarks.bookmark` 5 | --]] 6 | 7 | require("neorg.modules.base") 8 | 9 | local module = neorg.modules.create("bookmarks.ui") 10 | 11 | module.setup = function() 12 | return { 13 | success = true, 14 | requires = { 15 | "core.ui", 16 | }, 17 | imports = { 18 | "capture_popup", 19 | }, 20 | } 21 | end 22 | 23 | module.public = { 24 | display_messages = function() 25 | vim.cmd(string.format([[echom '%s']], "Press ESC to exit without saving")) 26 | end, 27 | edit_bookmark_at_cursor = function() 28 | print "edit bookmark at cursor" 29 | end, 30 | show_views_popup = function() 31 | print "show views popup" 32 | end, 33 | compile = function() 34 | print "compile bookmarks" 35 | end, 36 | } 37 | 38 | return module 39 | --------------------------------------------------------------------------------