natural language dates for neovim
  • Lua 89.5%
  • JavaScript 10.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
zizhou teng (n451) 54e929231e fix: lazy.nvim build
2026-02-19 19:21:18 +00:00
lua fix: register node provider if not found 2026-02-19 19:12:55 +00:00
rplugin/node/nldates doc: readme 2026-02-19 19:03:09 +00:00
.gitignore feat: working! 2025-09-07 01:18:22 +08:00
LICENSE Initial commit 2025-09-07 01:10:56 +08:00
package-lock.json doc: readme 2026-02-19 19:03:09 +00:00
README.md fix: lazy.nvim build 2026-02-19 19:21:18 +00:00

nldates.nvim

Natural language dates for Neovim. Parse date strings like "next Friday", "tomorrow", or "2 weeks ago" into formatted dates.

Features

  • Parse natural language dates using chrono-node
  • Format dates with moment.js
  • Visual mode integration - select text and transform in place

Requirements

  • Neovim >= 0.9.0
  • Node.js >= 18
  • npm

Run :checkhealth provider in Neovim to verify your Node provider is working.

Installation

Lazy.nvim

return {
   "obsidian-nvim/nldates.nvim",
   build = function()
      if not vim.g.node_host_prog then
         vim.g.node_host_prog = vim.fn.exepath("neovim-node-host")
      end
      vim.fn.jobstart("cd rplugin/node/nldates; npm install")
      vim.cmd("UpdateRemotePlugins")
   end,
}

Manual npm Installation

cd ~/.local/share/nvim/lazy/nldates.nvim/rplugin/node/nldates
npm install

Restart Neovim after installation.

Node Provider Setup

  1. Install Node.js >= 18
  2. Install the neovim npm package: npm install -g neovim
  3. Run :checkhealth provider in Neovim to verify

Usage

Select a date string in visual mode and run:

:'<,'>lua require("nldates").replace_selection()

Keybinding

Replace date

vim.keymap.set("v", "<leader>nd", function()
   require("nldates").replace_selection()
end)

Select next friday and press gd → becomes 2025-02-21

Format with moment.js

See https://momentjs.com/docs/#/displaying/format/ for full reference.

vim.keymap.set("v", "<leader>nd", function()
   require("nldates").replace_selection({ format = "[[][[]YYYY-MM-DD[]][]]" })
end)

Select next friday and press gd → becomes 2025-02-21

API

require("nldates").replace_selection(opts?)

Parses the visual selection as a natural language date and replaces it.

Options:

  • format (string): Output format. Default: "YYYY-MM-DD"

Supported Date Formats

  • Relative: "tomorrow", "next week", "2 days ago"
  • Specific: "January 15th", "2025-01-15"
  • Day names: "next friday", "last monday"
  • Time: "at 3pm", "tomorrow morning"