Skip to content

Commit

Permalink
Merge pull request #19 from chrisgrieser/dev
Browse files Browse the repository at this point in the history
feat: add syntax highlighting to picker results
  • Loading branch information
piersolenski authored Jan 8, 2024
2 parents 9fc3e51 + 1711957 commit 2a95c99
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/import/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ local function picker(opts)
return nil
end

-- add syntax highlighting to the rsults of the picker
local currentFiletype = vim.bo.filetype
vim.api.nvim_create_autocmd("FileType", {
pattern = "TelescopeResults",
once = true, -- do not affect other Telescope windows
callback = function(ctx)
-- add filetype highlighting
vim.api.nvim_buf_set_option(ctx.buf, "filetype", currentFiletype)

-- make discernible as the results are now colored
local ns = vim.api.nvim_create_namespace("telescope-import")
vim.api.nvim_win_set_hl_ns(0, ns)
vim.api.nvim_set_hl(ns, "TelescopeMatching", { reverse = true })
end,
})

pickers
.new(opts, {
prompt_title = "Imports",
Expand Down

0 comments on commit 2a95c99

Please sign in to comment.