Giter VIP home page Giter VIP logo

neorg-telescope's Introduction

Neorg Telescope

This repo hosts a 3rd party module for Neorg to integrate with telescope.nvim

๐ŸŒŸ Showcase

Fuzzy Searching Any Linkable

Simply jump to any important element in the workspace. This includes headings, drawers, markers. The command for this is Telescope neorg find_linkable

Demo find_linkable

Automatic Link Insertion

Simply press a key (<C-l> in insert mode by default) and select what you want to link to.

insert_link only works for elements in the current workspace.

Demo insert_link

Automatic File Link Insertion

You can use Telescope neorg insert_file_link to insert a link to a neorg file. Notice that this only works for files in the current workspace. Note: If no file is selected a link to a file with the name of the prompt value will be inserted. This file will be created if you use the link with neorg's hop

Demo insert_file_link

Fuzzy Searching Headings

With Telescope neorg search_headings you can search through all the headings in the current file.

Demo search_headings

Search File and Heading Backlinks

  • Telescope neorg find_backlinks - find every line in your workspace that links^* to the current file
  • Telescope neorg find_header_backlinks - same but with links to the current file and heading

These are limited to workspace relative links (ie. {:$/worspace/relative/path:}) for the sake of simplicity. Both exact ({:$/path:** lvl 2 heading}) and fuzzy ({:$/path:# heading}) links are found.

Demo

search backlink

Gtd Pickers

Those pickers are all broken since gtd was removed in core

The removed pickers

Find Project Tasks

Use Telescope neorg find_project_tasks to pick a project and then the tasks inside it. You can then jump to those tasks. If you select and empty project (colored gray) then you'll jump to the project.

Screen.Recording.2022-03-14.at.18.26.26.mov

Find Context Tasks

With Telescope neorg find_context_tasks you pick a context and then tasks.

Screen.Recording.2022-03-15.at.15.34.35.mov

Find AOF Tasks

You can use Telescope neorg find_aof_tasks to pick an aof and then search through the tasks of it.

Screen.Recording.2022-03-15.at.15.32.11.mov

Find AOF Project Tasks

When you use Telescope neorg find_aof_project_tasks you can pick an area of focus, then a project inside it and last but not least you can search for tasks inside the project.

Screen.Recording.2022-03-15.at.15.35.48.mov

Until the new GTD infrastructure arrives, you could collect all your todo items with a regex, for example:

-- Make sure you have ripgrep installed.
-- Add the following function to your `~/.config/nvim/init.lua`:
do
    local _, neorg = pcall(require, "neorg.core")
    local dirman = neorg.modules.get_module("core.dirman")
    local function get_todos(dir, states)
        local current_workspace = dirman.get_current_workspace()
        local dir = current_workspace[2]
        require('telescope.builtin').live_grep{ cwd = dir }
        vim.fn.feedkeys('^ *([*]+|[-]+) +[(]' .. states .. '[)]')
    end

    -- This can be bound to a key
    vim.keymap.set('n', '<c-t>', function() get_todos('~/notes', '[^x_]') end)
end

๐Ÿ”ง Installation

First, make sure to pull this plugin down. This plugin does not run any code in of itself. It requires Neorg to load it first:

You can install it through your favorite plugin manager:

  • packer.nvim
    use {
        "nvim-neorg/neorg",
        config = function()
            require('neorg').setup {
                load = {
                    ["core.defaults"] = {},
                    ...
                    ["core.integrations.telescope"] = {}
                },
            }
        end,
        requires = { "nvim-lua/plenary.nvim", "nvim-neorg/neorg-telescope" },
    }
  • vim-plug
    Plug 'nvim-neorg/neorg' | Plug 'nvim-lua/plenary.nvim' | Plug 'nvim-neorg/neorg-telescope'

    You can then put this initial configuration in your init.vim file:

    lua << EOF
    require('neorg').setup {
      load = {
          ["core.defaults"] = {},
          ...
          ["core.integrations.telescope"] = {}
      },
    }
    EOF
  • lazy.nvim
    require("lazy").setup({
        {
            "nvim-neorg/neorg",
            opts = {
                load = {
                    ["core.defaults"] = {},
                    ...
                    ["core.integrations.telescope"] = {},
                },
            },
            dependencies = { { "nvim-lua/plenary.nvim" }, { "nvim-neorg/neorg-telescope" } },
        }
    })

Usage

You can define keybindings like this:

local neorg_callbacks = require("neorg.core.callbacks")

neorg_callbacks.on_event("core.keybinds.events.enable_keybinds", function(_, keybinds)
    -- Map all the below keybinds only when the "norg" mode is active
    keybinds.map_event_to_mode("norg", {
        n = { -- Bind keys in normal mode
            { "<C-s>", "core.integrations.telescope.find_linkable" },
        },

        i = { -- Bind in insert mode
            { "<C-l>", "core.integrations.telescope.insert_link" },
        },
    }, {
        silent = true,
        noremap = true,
    })
end)

Support Welcome

If it's not clear by the code already, I'm a solid noob at telescope related things :)

If you have any awesome ideas or any code you want to contribute then go ahead! Any sort of help is appreciated โค๏ธ

Some Ideas Right Off The Top Of My Head

  • Fuzzy searching content in paragraphs only
  • Fuzzy searching content in the current heading

GIFs

Insert Link

insert_link_gif

neorg-telescope's People

Contributors

max397574 avatar vhyrro avatar zdcthomas avatar metalelf0 avatar github-actions[bot] avatar benlubas avatar taeruh avatar kkharji avatar pysan3 avatar kashelkin avatar d-r-a-b avatar champignoom avatar anakojm avatar znschaffer avatar tj-adams avatar mrossinek avatar mrcjkb avatar sibevin avatar danymat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.