summaryrefslogtreecommitdiffstats
path: root/after/plugin/telescope.lua
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2023-10-22 18:17:21 -0400
committerSquibid <me@zacharyscheiman.com>2023-10-22 18:17:21 -0400
commit01729e261340a4462a57bf80f6e591c1371ae996 (patch)
tree67b6488d097ac04cb5d27d794b530ee15ce65593 /after/plugin/telescope.lua
parente522d7d3faa895c2722113b316d4fc8203158996 (diff)
downloadnvim-01729e261340a4462a57bf80f6e591c1371ae996.tar.gz
nvim-01729e261340a4462a57bf80f6e591c1371ae996.tar.bz2
nvim-01729e261340a4462a57bf80f6e591c1371ae996.zip
kitchen sink:
- add code action previews - change indent blankline style - more luasnip snippets - change default mason stuff - customize neorg more - change notify style - change startpage completely - add line info to statusline - change telescope style - change how todo comments look - make indentation work via treesitter
Diffstat (limited to 'after/plugin/telescope.lua')
-rw-r--r--after/plugin/telescope.lua65
1 files changed, 60 insertions, 5 deletions
diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua
index 9411e61..519ecbd 100644
--- a/after/plugin/telescope.lua
+++ b/after/plugin/telescope.lua
@@ -5,18 +5,71 @@ end
local actions = require('telescope.actions')
local action_layout = require("telescope.actions.layout")
+local function telescopew()
+ if vim.o.columns <= 80 then
+ return vim.o.columns
+ else
+ return 80
+ end
+end
+
telescope.setup {
defaults = {
borderchars = {
- prompt = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
+ prompt = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
results = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
preview = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
},
- sorting_strategy = 'ascending',
+ preview = {
+ -- add image previews via chafa
+ mime_hook = function(filepath, bufnr, opts)
+ local is_image = function(filepath)
+ local image_extensions = { -- supported image formats
+ 'png',
+ 'jpg',
+ 'jpe',
+ 'jpeg',
+ 'webp',
+ 'gif',
+ }
+ local split_path = vim.split(filepath:lower(), '.', { plain=true })
+ local extension = split_path[#split_path]
+ return vim.tbl_contains(image_extensions, extension)
+ end
+ if is_image(filepath) then
+ local term = vim.api.nvim_open_term(bufnr, {})
+ local function send_output(_, data, _ )
+ for _, d in ipairs(data) do
+ vim.api.nvim_chan_send(term, d..'\r\n')
+ end
+ end
+ vim.fn.jobstart({
+ 'chafa',
+ '-C',
+ 'on',
+ '--animate',
+ 'off',
+ '-s',
+ (telescopew() - 10)..'x25',
+ '--clear',
+ filepath
+ }, { on_stdout = send_output, stdout_buffered = true, pty = true })
+ a.nvim_set_option_value("number", false, {buf = bufnr})
+ else
+ require("telescope.previewers.utils").set_preview_message(bufnr, opts.winid, "File cannot be previewed")
+ end
+ end
+ },
+
+ winblend = 0,
-- 'horizontal', 'vertical', 'bottom_pane', or 'cursor'
- layout_strategy = 'bottom_pane',
+ layout_strategy = 'vertical',
+ sorting_strategy = 'ascending',
layout_config = {
- bottom_pane = { height = 0.4, },
+ vertical = {
+ width = telescopew(),
+ prompt_position = "top",
+ }
},
mappings = {
i = {
@@ -42,5 +95,7 @@ telescope.load_extension('projects')
a.nvim_create_autocmd('User', {
pattern = 'TelescopePreviewerLoaded',
- command = 'setlocal number',
+ callback = function()
+ vim.opt.winblend = 0
+ end,
})