Skip to content

Commit

Permalink
more scaffolding, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
clpi committed Dec 15, 2024
1 parent 7653a6c commit 1df6314
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 47 deletions.
9 changes: 8 additions & 1 deletion lua/word/mod/integration/blink/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
local M = Mod.create("integration.blink")
local mod = require("word.mod")

---@type word.Mod
local M = mod.create("integration.blink")

local has_blink, blink = pcall(require, "blink.cmp")

---@class word.integration.blink.Config
M.config.public = {}
---@class word.integration.blink.Data
M.data = {}
M.data.source = require("word.mod.integration.blink.source")
M.data.format = require("word.mod.integration.blink.format")

Expand Down
4 changes: 3 additions & 1 deletion lua/word/mod/integration/fzf/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local F = Mod.create("integration.fzf")
local mod = require("word.mod")

---@type word.Mod
local F = mod.create("integration.fzf")

return F
5 changes: 3 additions & 2 deletions lua/word/mod/integration/lualine/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---@type word.mod
local L = Mod.create("integration.lualine")
local mod = require("word.mod")
---@type word.Mod
local L = mod.create("integration.lualine")

return L
88 changes: 45 additions & 43 deletions lua/word/mod/integration/telescope/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local M = Mod.create("integration.telescope")
local mod = require("word.mod")
local M = mod.create("integration.telescope")
local tok, t = pcall(require, "telescope")

local k = vim.keymap.set
Expand All @@ -11,29 +12,30 @@ M.setup = function()
}
else
return {
loaded = false
loaded = false,
}
end
end

---@class word.integration.telescope.Data
M.data = {
picker_names = {
"linkable",
"files",
-- "insert_link",
-- "insert_file_link",
-- "search_headings",
-- "find_project_tasks",
-- "find_aof_project_tasks",
-- "find_aof_tasks",
-- "find_context_tasks",
"workspace",
-- "backlinks.file_backlinks",
-- "backlinks.header_backlinks",
picker_names = {
"linkable",
"files",
-- "insert_link",
-- "insert_file_link",
-- "search_headings",
-- "find_project_tasks",
-- "find_aof_project_tasks",
-- "find_aof_tasks",
-- "find_context_tasks",
"workspace",
-- "backlinks.file_backlinks",
-- "backlinks.header_backlinks",
},
}
M.config.public = {
}
---@class word.integration.telescope.Config
M.config.public = {}
M.data.pickers = function()
local r = {}
for _, pic in ipairs(M.data.picker_names) do
Expand All @@ -47,45 +49,45 @@ M.data.pickers = function()
end
M.events.subscribed = {
cmd = {
["cmd.integration.telescope.find.files"] = true,
["cmd.integration.telescope.find.workspace"] = true,
["integration.telescope.find.files"] = true,
["integration.telescope.find.workspace"] = true,
},
}
M.load = function()
if tok then
Mod.await("cmd", function(cmd)
cmd.add_commands_from_table({
find = {
args = 0,
name = "integration.telescope.find",
subcommands = {
files = {
name = "cmd.integration.telescope.find.files",
args = 0,
},
workspace = {
name = "cmd.integration.telescope.find.workspace",
args = 0,
mod.await("cmd", function(cmd)
cmd.add_commands_from_table({
find = {
args = 0,
name = "integration.telescope.find",
subcommands = {
files = {
name = "integration.telescope.find.files",
args = 0,
},
workspace = {
name = "integration.telescope.find.workspace",
args = 0,
},
},
},
},
})
end)
assert(tok, t)
t.load_extension("word")
for _, pic in ipairs(M.data.picker_names) do
-- t.load_extension(pic)
k("n", "<plug>word.telescope." .. pic .. "", M.data.pickers()[pic])
end
})
end)
assert(tok, t)
t.load_extension("word")
for _, pic in ipairs(M.data.picker_names) do
-- t.load_extension(pic)
k("n", "<plug>word.telescope." .. pic .. "", M.data.pickers()[pic])
end
else
return
end
end

M.on = function(event)
if event.type == "cmd.events.integration.telescope.find.files" then
if event.type == "integration.telescope.find.files" then
vim.cmd([[Telescope word find_word]])
elseif event.type == "cmd.events.integration.telescope.find.workspace" then
elseif event.type == "integration.telescope.find.workspace" then
vim.cmd([[Telescope word workspace]])
require("telescope._extensions.word.picker.workspace")()
end
Expand Down

0 comments on commit 1df6314

Please sign in to comment.