1- local log = require (" down.util. log" )
1+ local log = require (" down.log" )
22local mod = require (" down.mod" )
33local modconf = require (" down.mod.util" )
44
@@ -27,6 +27,30 @@ Config.toggles = {
2727 " bench" ,
2828}
2929
30+ --- Default keymaps for down.nvim, specified in user's config
31+ --- or to be loaded via a toggle
32+ Config .keys = {
33+ { " <space>di" , " <CMD>Down index<CR>" , desc = " Down index" },
34+ { " <space>dy" , " <CMD>Down yesterday<CR>" , desc = " Down yesterday" },
35+ { " <space>dt" , " <CMD>Down today<CR>" , desc = " Down today" },
36+ { " <space>dm" , " <CMD>Down tomorrow<CR>" , desc = " Down tomorrow" },
37+ { " <space>dw" , " <CMD>Down workspace<CR>" , desc = " Down workspace" },
38+ { " <space>dc" , " <CMD>Down calendar<CR>" , desc = " Down calendar" },
39+ { " <space>df" , " <CMD>Down find<CR>" , desc = " Down find" },
40+ { " <space>dn" , " <CMD>Down note<CR>" , desc = " Down note" },
41+ { " <space>dp" , " <CMD>Down note template<CR>" , desc = " Down note template" },
42+ { " <space>dd" , " <CMD>Down<CR>" , desc = " Down" },
43+ }
44+
45+ --- Default dependencies for down.nvim, specified in user's config
46+ Config .dependencies = {
47+ " nvim-lua/plenary.nvim" ,
48+ " nvim-treesitter/nvim-treesitter" ,
49+ }
50+
51+ --- Default command for down.nvim, specified in user's config
52+ Config .command = { " Down" }
53+
3054function Config :check_hook (...)
3155 if self .user .hook and type (self .user .hook ) == " function" then
3256 return self .user .hook (... )
3761--- @param v ? boolean
3862function Config :check_toggle (k , v )
3963 if
40- k
41- and type (k ) == " string"
42- and v
43- and type (v ) == " boolean"
44- and vim .tbl_contains (self .toggles , k )
64+ k
65+ and type (k ) == " string"
66+ and v
67+ and type (v ) == " boolean"
68+ and vim .tbl_contains (self .toggles , k )
4569 then
4670 self [k ] = v
4771 end
5276--- @param ... any
5377--- @return down.Config
5478function Config :load (user , ...)
55- if self .started and self .started == false then
56- return self
57- elseif not type (user ) == " table" then
79+ if
80+ (self .started and self .started == false )
81+ or (not type (user ) == " table" )
82+ or (type (user ) == " nil" )
83+ then
5884 return self
5985 elseif user .defaults and user .defaults == false then
6086 self .user = user
@@ -139,12 +165,12 @@ end
139165--- @return boolean
140166function Config .check_mod_test (mod )
141167 return mod ~= nil
142- and mod .id ~= nil
143- and modconf .check_id (mod .id )
144- and type (mod ) == " table"
145- and mod .tests ~= nil
146- and type (mod .tests ) == " table"
147- and not vim .tbl_isempty (mod .tests )
168+ and mod .id ~= nil
169+ and modconf .check_id (mod .id )
170+ and type (mod ) == " table"
171+ and mod .tests ~= nil
172+ and type (mod .tests ) == " table"
173+ and not vim .tbl_isempty (mod .tests )
148174end
149175
150176--- @param mods ? down.Mod.Mod[]
@@ -161,20 +187,20 @@ end
161187function Config .test (mod )
162188 vim .print (" Testing " .. tostring (vim .inspect (mod .id )))
163189 return vim
164- .iter (pairs (mod .tests ))
165- :filter (function (tn , t )
166- return tn and type (t ) == " function"
167- end )
168- :all (function (tn , tt )
169- if not type (tt ) == " function" then
170- return false
171- end
172- local res = tt (mod ) or false --- @type boolean
173- vim .print (
174- " Testing mod " .. mod .id .. " test: " .. tn .. " : " .. tostring (res )
175- )
176- return res
177- end )
190+ .iter (pairs (mod .tests ))
191+ :filter (function (tn , t )
192+ return tn and type (t ) == " function"
193+ end )
194+ :all (function (tn , tt )
195+ if not type (tt ) == " function" then
196+ return false
197+ end
198+ local res = tt (mod ) or false --- @type boolean
199+ vim .print (
200+ " Testing mod " .. mod .id .. " test: " .. tn .. " : " .. tostring (res )
201+ )
202+ return res
203+ end )
178204end
179205
180206return Config
0 commit comments