feat(nvim): telescope style/autocmd
This commit is contained in:
parent
3c42ae4797
commit
7499e4b345
4 changed files with 72 additions and 69 deletions
|
@ -12,16 +12,44 @@ vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
desc = "Highlight yanked text",
|
desc = "Highlight yanked text",
|
||||||
})
|
})
|
||||||
|
|
||||||
local trnuGroup = vim.api.nvim_create_augroup("toggleRnu", {})
|
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", {})
|
||||||
vim.api.nvim_create_autocmd("InsertEnter,BufLeave,WinLeave,FocusLost", {
|
local ignore_ft = { "alpha", "TelescopePrompt", "" }
|
||||||
|
|
||||||
|
---@param callback fun(): nil
|
||||||
|
local ft_guard = function(callback)
|
||||||
|
if not vim.tbl_contains(ignore_ft, vim.bo.filetype) then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd(
|
||||||
|
{ "InsertEnter", "BufLeave", "WinLeave", "FocusLost" },
|
||||||
|
{
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.relativenumber = false
|
ft_guard(function()
|
||||||
|
vim.opt_local.rnu = false
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
group = trnuGroup,
|
group = numbertoggle,
|
||||||
})
|
}
|
||||||
vim.api.nvim_create_autocmd("InsertLeave,BufEnter,WinEnter,FocusGained", {
|
)
|
||||||
|
vim.api.nvim_create_autocmd(
|
||||||
|
{ "InsertLeave", "BufEnter", "WinEnter", "FocusGained" },
|
||||||
|
{
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.relativenumber = true
|
ft_guard(function()
|
||||||
|
vim.opt_local.rnu = true
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
group = trnuGroup,
|
group = numbertoggle,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
vim.api.nvim_create_autocmd({ "CmdlineEnter", "CmdlineLeave" }, {
|
||||||
|
callback = function(data)
|
||||||
|
ft_guard(function()
|
||||||
|
vim.opt.rnu = data.event == "CmdlineLeave"
|
||||||
|
vim.cmd("redraw")
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
group = numbertoggle,
|
||||||
})
|
})
|
||||||
|
|
|
@ -37,63 +37,27 @@ vim.o.signcolumn = "yes:1"
|
||||||
-- hide search notices, intro
|
-- hide search notices, intro
|
||||||
vim.opt.shortmess:append("sI")
|
vim.opt.shortmess:append("sI")
|
||||||
|
|
||||||
|
-- stylua: ignore
|
||||||
local borderchars = {
|
local borderchars = {
|
||||||
single = {
|
single = {
|
||||||
style = "single",
|
style = "single",
|
||||||
vert = "│",
|
vert = "│", vertleft = "┤", vertright = "├", horiz = "─", horizup = "┴", horizdown = "┬", verthoriz = "┼", topleft = "┌", topright = "┐", botleft = "└", botright = "┘"
|
||||||
vertleft = "┤",
|
|
||||||
vertright = "├",
|
|
||||||
horiz = "─",
|
|
||||||
horizup = "┴",
|
|
||||||
horizdown = "┬",
|
|
||||||
verthoriz = "┼",
|
|
||||||
topleft = "┌",
|
|
||||||
topright = "┐",
|
|
||||||
botleft = "└",
|
|
||||||
botright = "┘",
|
|
||||||
},
|
},
|
||||||
double = {
|
double = {
|
||||||
style = "double",
|
style = "double",
|
||||||
vert = "║",
|
vert = "║", vertleft = "╣", vertright = "╠", horiz = "═", horizup = "╩", horizdown = "╦", verthoriz = "╬", topleft = "╔", topright = "╗", botleft = "╚", botright = "╝"
|
||||||
vertleft = "╣",
|
|
||||||
vertright = "╠",
|
|
||||||
horiz = "═",
|
|
||||||
horizup = "╩",
|
|
||||||
horizdown = "╦",
|
|
||||||
verthoriz = "╬",
|
|
||||||
topleft = "╔",
|
|
||||||
topright = "╗",
|
|
||||||
botleft = "╚",
|
|
||||||
botright = "╝",
|
|
||||||
},
|
},
|
||||||
rounded = {
|
rounded = {
|
||||||
style = "rounded",
|
style = "rounded",
|
||||||
vert = "│",
|
vert = "│", vertleft = "┤", vertright = "├", horiz = "─", horizup = "┴", horizdown = "┬", verthoriz = "┼", topleft = "╭", topright = "╮", botleft = "╰", botright = "╯"
|
||||||
vertleft = "┤",
|
|
||||||
vertright = "├",
|
|
||||||
horiz = "─",
|
|
||||||
horizup = "┴",
|
|
||||||
horizdown = "┬",
|
|
||||||
verthoriz = "┼",
|
|
||||||
topleft = "╭",
|
|
||||||
topright = "╮",
|
|
||||||
botleft = "╰",
|
|
||||||
botright = "╯",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- my custom borderchars
|
-- my custom borderchars
|
||||||
vim.g.bc = borderchars.rounded
|
vim.g.bc = borderchars.rounded
|
||||||
-- drawing characters for splits
|
|
||||||
vim.opt.fillchars:append({
|
-- stylua: ignore
|
||||||
horiz = vim.g.bc.horiz,
|
vim.opt.fillchars:append({ horiz = vim.g.bc.horiz, horizup = vim.g.bc.horizup, horizdown = vim.g.bc.horizdown, vert = vim.g.bc.vert, vertright = vim.g.bc.vertright, vertleft = vim.g.bc.vertleft, verthoriz = vim.g.bc.verthoriz })
|
||||||
horizup = vim.g.bc.horizup,
|
|
||||||
horizdown = vim.g.bc.horizdown,
|
|
||||||
vert = vim.g.bc.vert,
|
|
||||||
vertright = vim.g.bc.vertright,
|
|
||||||
vertleft = vim.g.bc.vertleft,
|
|
||||||
verthoriz = vim.g.bc.verthoriz,
|
|
||||||
})
|
|
||||||
|
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
vim.g.neovide_refresh_rate = 60
|
vim.g.neovide_refresh_rate = 60
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"f-person/auto-dark-mode.nvim",
|
"f-person/auto-dark-mode.nvim",
|
||||||
|
cond = vim.fn.has("mac"),
|
||||||
config = function()
|
config = function()
|
||||||
local autodm = require("auto-dark-mode")
|
local autodm = require("auto-dark-mode")
|
||||||
if vim.fn.has("mac") ~= 1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local update_neovide_background = function()
|
local update_neovide_background = function()
|
||||||
if not vim.g.neovide then
|
if not vim.g.neovide then
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
local bc = vim.g.bc
|
||||||
|
|
||||||
|
-- stylua: ignore
|
||||||
|
local no_preview = function()
|
||||||
|
return require("telescope.themes").get_dropdown({
|
||||||
|
borderchars = {
|
||||||
|
{ bc.horiz, bc.vert, bc.horiz, bc.vert, bc.topleft, bc.topright, bc.botright, bc.botleft },
|
||||||
|
prompt = { bc.horiz, bc.vert, " ", bc.vert, bc.topleft, bc.topright, bc.vert, bc.vert },
|
||||||
|
results = { bc.horiz, bc.vert, bc.horiz, bc.vert, bc.vertright, bc.vertleft, bc.botright, bc.botleft },
|
||||||
|
preview = { bc.horiz, bc.vert, bc.horiz, bc.vert, bc.topleft, bc.topright, bc.botright, bc.botleft },
|
||||||
|
},
|
||||||
|
width = 0.8,
|
||||||
|
previewer = false,
|
||||||
|
prompt_title = false,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
---@type LazySpec[]
|
---@type LazySpec[]
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
|
@ -30,16 +47,12 @@ return {
|
||||||
prompt_prefix = " ",
|
prompt_prefix = " ",
|
||||||
selection_caret = " ",
|
selection_caret = " ",
|
||||||
multi_icon = "│",
|
multi_icon = "│",
|
||||||
borderchars = {
|
-- stylua: ignore
|
||||||
vim.g.bc.horiz,
|
borderchars = { bc.horiz, bc.vert, bc.horiz, bc.vert, bc.topleft, bc.topright, bc.botright, bc.botleft },
|
||||||
vim.g.bc.vert,
|
|
||||||
vim.g.bc.horiz,
|
|
||||||
vim.g.bc.vert,
|
|
||||||
vim.g.bc.topleft,
|
|
||||||
vim.g.bc.topright,
|
|
||||||
vim.g.bc.botright,
|
|
||||||
vim.g.bc.botleft,
|
|
||||||
},
|
},
|
||||||
|
pickers = {
|
||||||
|
find_files = no_preview(),
|
||||||
|
live_grep = no_preview(),
|
||||||
},
|
},
|
||||||
extensions = {
|
extensions = {
|
||||||
file_browser = {
|
file_browser = {
|
||||||
|
|
Loading…
Reference in a new issue