Code Monkey home page Code Monkey logo

kiwi.nvim's Introduction

kiwi.nvim 🥝

Hits


Introduction

kiwi.nvim is a stripped down version of VimWiki for Neovim.

VimWiki kiwi.nvim
Multiple syntaxes Sticks to markdown
Syntax highlights included User can install Treesitter plugins markdown and markdown-inline if required
Keymaps like Backspace for autosave Stick to manual saves and <C-o> to move back

With kiwi.nvim, you can:

  • Organize notes and ideas
  • Manage to-do lists
  • Write documentation
  • Write blog posts to Hugo or Astro

To do a quick start, press <Leader>ww (default is \ww) to go to your index wiki file. By default, it is located in ~/wiki/index.md. To register a different path for the wiki, you can specify the path inside the setup function if required

Feed it with the following example:

# My knowledge base
- Tasks -- things to be done _yesterday_!!!
- Project Gutenberg -- good books are power.
- Scratchpad -- various temporary stuff.

Place your cursor on Tasks and press Enter to create a link. Once pressed, Tasks will become [Tasks](./Tasks.md) and open it. Edit the file, save it. To go back, you can press <C-o> to move to the previous file. Backspace is not mapped to go back since we already have vim keybindings to move back.

A markdown link can be constructed from more than one word. Just visually select the words to be linked and press Enter. Try it, with Project Gutenberg. The result should look something like:

# My knowledge base
- [Tasks](./Tasks.md) -- things to be done _yesterday_!!!
- [Project Gutenberg](./Project_Gutenberg.md) -- good books are power.
- Scratchpad -- various temporary stuff.

Screenshots

custom_note.md todo.md

Installation

kiwi.nvim has been tested on Neovim >= 0.7. It will likely work on older versions but will not be officially supported.

Dependencies

kiwi.nvim has dependency on nvim-lua/plenary.nvim.

Installation using Vim-Plug

Add the following to the plugin-configuration in your vimrc:

Plug 'serenevoid/kiwi.nvim'

Then run :PlugInstall.

Installation using Packer

use {
    'serenevoid/kiwi.nvim', 
    requires = { {'nvim-lua/plenary.nvim'} }
}

Installation using Lazy

-- init.lua:
{
    'serenevoid/kiwi.nvim', dependencies = { 'nvim-lua/plenary.nvim' }
}

-- plugins/kiwi.lua:
return {
    'serenevoid/kiwi.nvim', dependencies = { 'nvim-lua/plenary.nvim' }
}

Usage

For Lazy users,

{
    'serenevoid/kiwi.nvim',
    dependencies = {
        "nvim-lua/plenary.nvim"
    },
    opts = {
        {
            name = "work",
            path = "/home/username/wiki_1"
        },
        {
            name = "personal",
            path = "/home/username/wiki_2"
        }
    },
    keys = {
        { "<leader>ww", ":lua require(\"kiwi\").open_wiki_index()<cr>", desc = "Open Wiki index" },
        { "<leader>wp", ":lua require(\"kiwi\").open_wiki_index(\"personal\")<cr>", desc = "Open index of personal wiki" },
        { "T", ":lua require(\"kiwi\").todo.toggle()<cr>", desc = "Toggle Markdown Task" }
    },
    lazy = true
}

For others,

-- Setup Custom wiki path if required
require('kiwi').setup({
    {
        name = "work",
        path = "C:\\Users\\username\\personal-wiki" -- For Windows users
    },
    {
        name = "personal",
        path = "/home/username/personal-wiki"
    }
})

-- Use default path (i.e. ~/wiki/)
local kiwi = require('kiwi')

-- Necessary keybindings
vim.keymap.set('n', '<leader>ww', kiwi.open_wiki_index, {})
vim.keymap.set('n', 'T', kiwi.todo.toggle, {})

Key bindings

Basic key bindings

  • <Enter> -- In visual mode: Follow/Create wiki link, in Normal mode just follow
  • <Tab> -- Find next wiki link.

Helping kiwi.nvim

This is a new project which aims to be a minimal wiki plugin which is very barebones and doesn't add features which a lot people doesn't use now. You can help by raising issues and bug fixes to help develop this project for the neovim community.

Stargazers over time

Stargazers over time

kiwi.nvim's People

Contributors

catalinplesu avatar clanktron avatar jqfeld avatar kitsugo avatar mcjvanschaik avatar serenevoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kiwi.nvim's Issues

Using directory structures

I structure my notes in one wiki, but in a directory structure. At the moment kiwi.nvim try to always use the main wiki directory. I need to define a path manually:
[diary](./diary/diary.md)
Then if I create links in the diary.md, they will be created also under the main path. The link [entry](./entry.md) doesn't construct the file under the directory "diary" as a ./ suggest.

If directory structures should be supported then two option is possible:
If the actual .md is in a sub directory

  1. then the [entry](./entry.md) should be created in the same directory
  2. or the directory should be added to the path [entry](./diary/entry.md)

Can't save file on Windows

So i installed the plugin with lazy.nvim:

{
    'serenevoid/kiwi.nvim',
    dependencies = {
        "nvim-lua/plenary.nvim"
    },
    opts = {
        {
            name = "wiki",
            path = "C:\\Users\\leogo\\vimwiki"
        },
    },
    keys = {
        { "<leader>www", ":lua require(\"kiwi\").open_wiki_index()<cr>", desc = "Open Wiki index" },
        { "<leader>wp", ":lua require(\"kiwi\").open_wiki_index(\"personal\")<cr>", desc = "Open index of personal wiki" },
        { "T", ":lua require(\"kiwi\").todo.toggle()<cr>", desc = "Toggle Markdown Task" }
    },
    lazy = true
  },

My Problem is when i create a new markdown file and wont to safe it, it says:
"~\vimwikiC:/Users/leogo/vimwiki/test.md"
E212: Can't open file for writing: no such file or directory

Maybe someone can help me :)

Plans to implement Journal?

Hey @serenevoid,

first of all: Great project. I found it looking for a neovim implementation of vimwiki.

Are there any plans to implement the journal feature? If not, do you think there is a way to script the Journal behavior and map it to key bindings?

Like:

  • create a new page journal/yyyy-mm-dd.md
  • create/update an index page with all journal entries

I think I need to refresh my Lua Fu and may contribute myself.

Best,
Moritz

Specify use of path as diary and/or wiki

I'd love the ability to have my diary and wiki in two different places. Meaning I'd like to specify in my config whether or not a filepath is meant to be used for a wiki or diary or both.

Since this is meant to be a stripped down version of vimwiki I understand features are supposed to be minimal, but I feel like toggling an existing feature on or off is still in scope.

I'm pretty comfortable with lua and might draft a PR adding this functionality if this seems desirable to @serenevoid and/or other users.

Some examples of how this might look in the lua config.

booleans for each:

require('kiwi').setup({
  {
    name = "personal",
    path = "/home/username/personal-wiki",
    -- for diary and wiki (current default)
    wiki = true,
    diary = true
  },
  {
    name = "work",
    path = "/other/wiki/path"
    -- for just wiki
    wiki = true,
    diary = false
  },
  {
    name = "work",
    path = "/other/diary/path"
    -- for just diary
    wiki = false,
    diary = true
  }
})

OR

lua table with options:

require('kiwi').setup({
  {
    name = "personal",
    path = "/home/username/personal-wiki",
    -- for diary and wiki (current default)
    usage = { "diary", "wiki" }
  },
  {
    name = "work",
    path = "/other/wiki/path"
    -- for just wiki
    usage = { "wiki" }
  },
  {
    name = "work",
    path = "/other/diary/path"
    -- for just diary
    usage = { "diary" }
  }
})

failed to run `config` for kiwi.nvim path.lua not found

image

my config located in "~/.config/nvim/lua/lucas/lazy/kiwi.lua"

return {
    'serenevoid/kiwi.nvim',
    opts = {
        {
            name = "todo",
            path = "~/Sync/todo"
        },
        {
            name = "zet",
            path = "~/Sync/zet"
        }
    },
    keys = {
        { "<leader>ww", ":lua require(\"kiwi\").open_wiki_index()<cr>", desc = "Open Wiki index" },
        { "<leader>wp", ":lua require(\"kiwi\").open_wiki_index(\"todo\")<cr>", desc = "Open index of personal wiki" },
        { "<C-Enter>", ":lua require(\"kiwi\").todo.toggle()<cr>", desc = "Toggle Markdown Task" }
    },
    lazy = true
}

Keybinding <Enter> from readme behaves differently

In the readme file the following key bindings are mentioned.

<Enter> -- Follow/Create wiki link.
<Tab> -- Find next wiki link.
T -- Toggle TODO list

Enter does not create a wiki link in Normal mode, this only works in Visual mode.

Helpfile missing

I might be the very first user that doesn´t have experience with Vimwiki that tries kiwi.nvim.

After installation I automatically entered :he kiwi, but then I saw the same readme and it wasn´t pleasant to read.

I have tried to make a first version for the help file. Would you like me to send a pull request for it?

Porting from VimWiki to Kiwi

Hi,
I noticed the VimWiki (markdown) has hyperlink defined as [topic](topic), whereas kiwi uses the actual file path [topic](./topic.md). Both contain markdown notes are in a flat folder.

I wrote a python script to convert the VimWiki notes to the Kiwi notes. Perhaps it can help others.

[update, 10/04/2023] fix a bug: replace space in filename with underscore

import regex as re
import sys
from pathlib import Path

# usage:
#   python vimwiki2kiwi.py <path_of_vimwiki_note_folder> <path_of_kiwi_note_folder>
#   e.g. python vimwiki2kiwi.py ./notes ./output
input_folder = Path(sys.argv[1])
output_folder = Path(sys.argv[2])
p = re.compile("(\[.*\]\()(.*)(\))")


def func(obj):
    m = obj.group(2).replace(" ", "_")
    m = "./" + m + ".md"
    return obj.group(1) + m + obj.group(3)


if not input_folder.exists():
    print(f"input folder {input_folder} does not exist.")
    exit(1)

if not output_folder.exists():
    print(f"output folder {output_folder} does not exist.")
    print("creating one")
    output_folder.mkdir(parents=True, exist_ok=True)

for file in input_folder.glob("./*.md"):
    print(f"converting {file}")
    outfile = output_folder / file.name.replace(" ", "_")
    outfile.touch()
    with open(file, "r") as ifp, open(outfile, "w") as ofp:
        for line in ifp:
            newline = re.sub(p, func, line)
            print(newline, file=ofp, end="")

Duplication of path on new entry creation (MacOS)

While this plugin looks promising, I cannot get it work as expected with more than one notes location.

My configuration:

return {
    'serenevoid/kiwi.nvim',
    dependencies = {
        "nvim-lua/plenary.nvim"
    },
    opts = {
        {
            name = "work",
            path = "/Users/avastmick/notes/edu-docs"
        },
        {
            name = "personal",
            path = "/Users/avastmick/notes/local-notes"
        }
    },
    keys = {
        { "<leader>kw", ":lua require(\"kiwi\").open_wiki_index(\"work\")<cr>",     desc = "Open Wiki index" },
        { "<leader>kp", ":lua require(\"kiwi\").open_wiki_index(\"personal\")<cr>", desc = "Open index of personal wiki" },
        { "T",          ":lua require(\"kiwi\").todo.toggle()<cr>",                 desc = "Toggle Markdown Task" }
    },
    lazy = true
}

Usage:

I open the personal and add in a line 'Daily Plan', select words and , I get the following path (see the status line)

image

I hit Ctrl+o to return to index.md, hovered link does not show duplicated path elements:

image

If I remove the leading ./ from the new link, navigates to a new file in the directory I opened nvim.

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.