Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ishchow/nvim-deardiary
Journaling plugin for NeoVim
https://github.com/ishchow/nvim-deardiary
lua neovim-plugin
Last synced: 2 months ago
JSON representation
Journaling plugin for NeoVim
- Host: GitHub
- URL: https://github.com/ishchow/nvim-deardiary
- Owner: ishchow
- License: mit
- Created: 2020-12-06T01:08:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-15T15:32:55.000Z (about 2 years ago)
- Last Synced: 2024-08-07T18:38:54.502Z (6 months ago)
- Topics: lua, neovim-plugin
- Language: Lua
- Homepage:
- Size: 51.8 KB
- Stars: 20
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![ci](https://github.com/ishchow/nvim-deardiary/workflows/ci/badge.svg)
# Overview
deardiary is a plugin that makes journaling in neovim easy and convenient.
Features:
- Manage multiple journals
- Set different frequencies of entries per journal (ex. daily, weekly)
- Custom frequencies of journal entries (ex. can add quarterly frequencies)
- Control filesystem paths of new entries
- Templating of new entiresRequirements:
- neovim 0.5+
- Currently requires latest neovim nightly since 0.5 isn't released yet# Quickstart
## Installation
deardiary can be installed just like any other neovim plugin.
Plug:
```
Plug 'ishchow/nvim-deardiary'
```Packer:
```
use 'ishchow/nvim-deardiary'
```## Configuration
Add the following to a file under `$XDG_CONFIG_HOME/nvim/lua` (ex.
~/.config/nvim/lua/diary.lua)```lua
local config = require("deardiary.config")config.journals = {
{
path = "~/journals/personal",
frequencies = {"daily", "weekly"},
},
{
path = "~/journals/work",
frequencies = {"daily", "weekly", "monthly", "yearly"},
},
}
```Then, in your init.vim file, add this to use your configuration:
```viml
lua require("diary")
```## Usage
### Basic Usage
Run the following command to set the active journal from `config.journals`.`:DearDiarySelectJournal` or `js`.
A menu will open up like this:
```
1 ~/journals/personal
2 ~/journals/work
Type in journal index and press (empty cancels):
```Enter a number to pick the desired journal.
Then, open todays entry using:
`:DearDiaryToday` or `jdc`.
Today's entry will be opened in a new buffer and filled with the contents from
a template.`# Saturday, December 26, 2020`
Save the file and the contents of this buffer will be saved to:
`~/journals/personal/daily/2020/12/26.md`
### Set current journal based on cwd
If the current working directory has a common path prefix with any of the
configured journals, you can automatically using this command:`:DearDiarySetCurrentJournalCwd` or `jsc`
To automatically set the current journal based on the current working
directory upon entering vim, add the following to your init.vim:```viml
augroup deardiary
autocmd!
autocmd VimEnter * lua require("deardiary").set_current_journal_cwd()
augroup end
```## Commands and Mappings
The following commands and mappings are provided by the plugin. The mappings
simply execute the commands and are provided for convenience.```vimhelp
:DearDiarySelectJournal | (DearDiarySelectJournal) | js
Selects current journal:DearDiarySetCurrentJournalCwd | (DearDiarySetCurrentJournalCwd) | jsc
Sets the current journal based on the current working directory:DearDiaryToday | (DearDiaryToday) | jdc
Go to entry for today:DearDiaryTomorrow | (DearDiaryTomorrow) | jdn
Go to entry for tomorrow:DearDiaryYesterday | (DearDiaryYesterday) | jdp
Go to entry for yesterday:DearDiaryThisWeek | (DearDiaryThisWeek) | jwc
Go to entry for this week:DearDiaryNextWeek | (DearDiaryNextWeek) | jwn
Go to entry for next week:DearDiaryLastWeek | (DearDiaryLastWeek) | jwp
Go to entry for last week:DearDiaryThisMonth | (DearDiaryThisMonth) | jmc
Go to entry for this month:DearDiaryNextMonth | (DearDiaryNextMonth) | jmn
Go to entry for next month:DearDiaryLastMonth | (DearDiaryLastMonth) | jmp
Go to entry for last month:DearDiaryThisYear | (DearDiaryThisYear) | jyc
Go to entry for this year:DearDiaryNextYear | (DearDiaryNextYear) | jyn
Go to entry for next year:DearDiaryLastYear | (DearDiaryLastYear) | jyp
Go to entry for last year
```Default mappings can be overriden if a mapping to the mapping name already
exists in your init.vim file.For example:
```viml
nmap ds (DearDiarySelectJournal)
```To completely disable all default mappings, add the following line to your
init.vim.```viml
let g:deardiary_use_default_mappings = 0
```## Documentation
Open the [help file](https://github.com/ishchow/deardiary/blob/main/doc/deardiary.txt)
for complete documentation. Help file contains examples of advanced
configuration such as custom frequencies and templating.# Contributing
## Repo structure
```
.
├── doc # NeoVim built-in help files
├── lua # Plugin lua modules
│ └── deardiary # Lua module containing plugin
│ └── lib # Lua module containing vendored, external libraries
├── mock # Lua modules containng mocks for unit test
│ └── mock # Mock lua module
├── plugin # Vimscript runtime files, provides glue code for mappings and commands
└── spec # Unit tests
```## Testing plugin locally
`nvim --cmd "set rtp+=$(pwd)" README.md`
## Unit testing
### Setup hererocks
Setup an isolated lua environment using [hererocks](https://github.com/mpeterv/hererocks).
This is done so that your system lua isn't polluted with rocks used to test this
plugin.```
pip3 install hererocks # use sudo if this doesn't work
hererocks -j 2.1.0-beta3 -r latest env
source env/bin/activate
```### Run tests
Installs test dependencies if not already installed and runs unit tests.
`luarocks test`
After test dependencies are installed, the above command can be used to re-run
tests or you can run tests directly using busted.`busted`
### Deactivate hererocks
Deactivate the lua environment.
`lua-deactivate`