-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 Feat: Add source to find template telescope
- Loading branch information
1 parent
5a4ac98
commit a79de66
Showing
6 changed files
with
94 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-- Credit https://github.com/glepnir/template.nvim/blob/main/lua/telescope/_extensions/find_template.lua | ||
local telescope = require("telescope") | ||
local finders = require("telescope.finders") | ||
local pickers = require("telescope.pickers") | ||
local conf = require("telescope.config").values | ||
local entry_display = require("telescope.pickers.entry_display") | ||
|
||
local templates = require("templates.templates") | ||
|
||
local find_template = function(opts) | ||
opts = opts or {} | ||
|
||
-- Credit https://github.com/xiyaowong/telescope-emoji.nvim/blob/master/lua/telescope/_extensions/emoji.lua | ||
local displayer = entry_display.create({ | ||
separator = " ", | ||
items = { | ||
{ width = 40 }, | ||
{ width = 18 }, | ||
{ remaining = true }, | ||
}, | ||
}) | ||
|
||
local make_display = function(entry) | ||
return displayer({ | ||
entry.value .. " " .. entry.name, | ||
}) | ||
end | ||
|
||
pickers.new(opts, { | ||
prompt_title = "Templates", | ||
results_title = "Templates", | ||
sorter = conf.generic_sorter(opts), | ||
finder = finders.new_table({ | ||
results = templates, | ||
entry_maker = function(template) | ||
return { | ||
ordinal = template.name, | ||
display = make_display, | ||
|
||
name = template.name, | ||
value = template.value, | ||
} | ||
end, | ||
}), | ||
}):find() | ||
end | ||
|
||
return telescope.register_extension({ exports = { find_template = find_template } }) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local M = {} | ||
|
||
M.templates = { | ||
{ | ||
name = "java/class", | ||
value = require("templates.java.class").template, | ||
}, | ||
{ | ||
name = "java/interface", | ||
value = require("templates.java.interface").template, | ||
}, | ||
{ | ||
name = "java/enum", | ||
value = require("templates.java.enum").template, | ||
}, | ||
{ | ||
name = "java/mongo repository", | ||
value = require("templates.java.mongo_repository").template, | ||
}, | ||
} | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters