Remove hardcoded options, do repo house-cleaning

Update readme and tmux.session file.

Remove unused tests, update option calling.
This commit is contained in:
Marty Oehme 2020-11-04 22:27:30 +01:00
parent e95bcf53b4
commit d29d92cc0a
Signed by: Marty
GPG key ID: B7538B8F50A1C800
6 changed files with 34 additions and 21 deletions

View file

@ -7,7 +7,7 @@ select-pane -t 1
split-window -v watch -t -n 1 -c '[ $(git diff --staged | wc -l) -eq 0 ] && git -c color.ui=always log --graph --date=short --decorate --oneline --all --remotes || git -c color.ui=always diff --staged | tail -n $(($LINES - 2))' split-window -v watch -t -n 1 -c '[ $(git diff --staged | wc -l) -eq 0 ] && git -c color.ui=always log --graph --date=short --decorate --oneline --all --remotes || git -c color.ui=always diff --staged | tail -n $(($LINES - 2))'
select-pane -t 4 select-pane -t 4
new-window -n code new-window -n code
send-keys "v ." C-m I send-keys "nvim --cmd "set rtp+=$(pwd)" ." C-m I
split-window -v -l 10% split-window -v -l 10%
send-keys "find . -type f -name '*.lua' | entr -c busted51 --exclude-tags='skip' --suppress-pending -C lua ." C-m send-keys "find . -type f -name '*.lua' | entr -c busted51 --exclude-tags='skip' --suppress-pending -C lua ." C-m
split-window -h split-window -h

View file

@ -5,9 +5,13 @@ To develop / debug:
start neovim with `nvim --cmd "set rtp+=$(pwd)" .` to automatically load the files in project dir as if they were on path start neovim with `nvim --cmd "set rtp+=$(pwd)" .` to automatically load the files in project dir as if they were on path
next up: next up:
* [x] link following option (under cursor, next on line) [ ] fix link following:
* [x] next link on line function (actions) * [x] empty space (e.g. in link text, or link itself) disrupts link regex search
* [x] helper function to decide which one to use from A.open * [x] line-end following breaks if cursor is in the MIDDLE of the link
* [ ] extract anchor from link/string (anchor.lua)
* [ ] opening zettel should use generated link table for full filename anchor search
* [ ] probably stop hardcoding anchor regex, make an option
* [ ] implement fallback to filename
## TODO: needed functionality ## TODO: needed functionality
@ -40,6 +44,7 @@ next up:
## TODO: nice-to-haves ## TODO: nice-to-haves
* [ ] refactor parsers (md/wiki) to be tables of functions/regex in options, so e.g. valid link detection can call `options.parser.isValidLink(link)` or transformation `options.parser.styleLink(anchor, text)` * [ ] refactor parsers (md/wiki) to be tables of functions/regex in options, so e.g. valid link detection can call `options.parser.isValidLink(link)` or transformation `options.parser.styleLink(anchor, text)`
* [ ] use unified parser model (e.g. containing `turn-to-link()`, `parse-link()`) function
* [ ] enable custom parser supply * [ ] enable custom parser supply
* [ ] completion engine (e.g. for `completion-nvim`, look in completion_buffers/completion-tags for reference) * [ ] completion engine (e.g. for `completion-nvim`, look in completion_buffers/completion-tags for reference)
* [ ] zettel caching for big directories * [ ] zettel caching for big directories
@ -53,6 +58,10 @@ next up:
* [ ] provide option to rename and automatically change backlinks * [ ] provide option to rename and automatically change backlinks
* [ ] zettel 'lens' (preview first headline + content of linked zettel through floating window etc, on keypress) * [ ] zettel 'lens' (preview first headline + content of linked zettel through floating window etc, on keypress)
## TODO: maintenance
* [ ] remove hard-coding of option vimnames in tests, now that we can dynamically change this through a single table
* anchor creation * anchor creation
* *must* be unique * *must* be unique
* default: 10 digits, usually current date+time (YYMMDDHHmm) * default: 10 digits, usually current date+time (YYMMDDHHmm)

View file

@ -2,7 +2,8 @@ local ZK = {}
local ls = require 'zettelkasten.list' local ls = require 'zettelkasten.list'
local o = require 'zettelkasten.options' local o = require 'zettelkasten.options'
local a = require 'zettelkasten.anchor' local anchor = require 'zettelkasten.anchor'
local action = require 'zettelkasten.action'
-- Returns all zettel in path as a -- Returns all zettel in path as a
-- { "anchor" = "path/to/zettel/anchor filename.md" } -- { "anchor" = "path/to/zettel/anchor filename.md" }
@ -14,6 +15,13 @@ end
-- Return a valid zettelkasten anchor for the current time, -- Return a valid zettelkasten anchor for the current time,
-- composed of yymmddHHMM. -- composed of yymmddHHMM.
function ZK.create_anchor() return a.create() end function ZK.get_anchor() return anchor.create() end
return {get_zettel_list = ZK.get_zettel_list, create_anchor = ZK.create_anchor} -- Open link under cursor, or next on line
function ZK.open_link() return action.open_selected() end
return {
get_zettel_list = ZK.get_zettel_list,
get_anchor = ZK.get_anchor,
open_link = ZK.open_link
}

View file

@ -1,7 +1,6 @@
ZK = require 'zettelkasten.init' ZK = require 'zettelkasten.init'
describe("Zettelkasten", function() -- describe("Zettelkasten", function()
it("should create an anchor for the current datetime", -- it("should create an anchor for the current datetime",
function() assert.same(os.date('%y%m%d%H%M'), ZK.create_anchor()) end) -- function() assert.same(os.date('%y%m%d%H%M'), ZK.create_anchor()) end)
-- end)
end)

View file

@ -1,5 +1,7 @@
local ls = {} local ls = {}
local o = require 'zettelkasten.options'
local function isDirectory(ftype) local function isDirectory(ftype)
if ftype == 'directory' then return true end if ftype == 'directory' then return true end
return false return false
@ -12,8 +14,9 @@ function ls.get_anchors_and_paths(path, recursive, options)
options = options or {} options = options or {}
-- TODO check for duplicates and warn user -- TODO check for duplicates and warn user
local zettel = {} local zettel = {}
-- TODO let user set as option, at least remove magic var
local anchorreg = '^.*/?([%d][%d][%d][%d][%d][%d][%d][%d][%d][%d])[^/]*%' .. local anchorreg = '^.*/?([%d][%d][%d][%d][%d][%d][%d][%d][%d][%d])[^/]*%' ..
(options.zettel_extension or '.md') .. '$' o.zettel().extension .. '$'
local handle = vim.loop.fs_scandir(path) local handle = vim.loop.fs_scandir(path)
while handle do while handle do
@ -35,11 +38,10 @@ end
-- Take a list of zettel as an optional variable, without which -- Take a list of zettel as an optional variable, without which
-- it will use the (recursive) results of the zettel_root directory. -- it will use the (recursive) results of the zettel_root directory.
function ls.get_zettel(anchor, all) function ls.get_zettel(anchor, all)
if not all then all = ls.get_anchors_and_paths('somepath') end -- TODO why is there 'somepath' here?
if not all then all = ls.get_anchors_and_paths('/home/marty/documents/notes') end
return all[anchor] return all[anchor]
end end
function ls.open_zettel(anchor, all) end
return ls return ls

View file

@ -159,8 +159,3 @@ describe("get_zettel", function()
assert.same("1910291645 myfile.wiki", ls.get_zettel("1910291645")) assert.same("1910291645 myfile.wiki", ls.get_zettel("1910291645"))
end) end)
end) end)
describe("open_zettel", function()
it("should set the current buffer to the zettel passed in as anchor",
function() pending("not implemented") end)
end)