Skip to content

Commit

Permalink
winbar and telescope file opts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidosomething committed Sep 21, 2023
1 parent 4d1ab05 commit d9ea424
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 43 deletions.
55 changes: 23 additions & 32 deletions nvim/lua/dko/heirline/cwd.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
return {
{
provider = function(self)
local is_project_root = require("dko.project").root() == self.cwd
return is_project_root and "  ʀᴏᴏᴛ " or ""
end,
hl = "StatusLineNC",
},
{
provider = function(self)
local uis = vim.api.nvim_list_uis()
local ui = uis[1] or { width = 80 }
provider = function(self)
local uis = vim.api.nvim_list_uis()
local ui = uis[1] or { width = 80 }

local extraparts = {
--2 + 1, -- search symbol
--2 + self.search_contents:len(), -- term padding
2 + 5, -- counts
8, -- icon and root text
2 + 1, -- branch indicator
self.branch:len(), -- branch
2 + 7, -- clipboard indicator
2 + 1, -- remote indicator
}
local extrachars = 0
for _, len in pairs(extraparts) do
extrachars = extrachars + len
end
local extraparts = {
--2 + 1, -- search symbol
--2 + self.search_contents:len(), -- term padding
2 + 5, -- counts
8, -- icon and root text
2 + 1, -- branch indicator
self.branch:len(), -- branch
2 + 7, -- clipboard indicator
2 + 1, -- remote indicator
}
local extrachars = 0
for _, len in pairs(extraparts) do
extrachars = extrachars + len
end

local remaining = ui.width - extrachars
local cwd = vim.fn.fnamemodify(self.cwd, ":~")
local output = cwd:len() < remaining and cwd or vim.fn.pathshorten(cwd)
return (" %s "):format(output)
end,
hl = "StatusLineNC",
},
local remaining = ui.width - extrachars
local cwd = vim.fn.fnamemodify(self.cwd, ":~")
local output = cwd:len() < remaining and cwd or vim.fn.pathshorten(cwd)
return ("  %s "):format(output)
end,
hl = "StatusLineNC",
}
21 changes: 15 additions & 6 deletions nvim/lua/dko/heirline/winbar.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local icon_color_enabled = false

local conditions = require("heirline.conditions")

local function active_highlight(active)
active = active or "StatusLine"
return require("heirline.conditions").is_active() and active or "StatusLineNC"
return conditions.is_active() and active or "StatusLineNC"
end

return {
Expand Down Expand Up @@ -33,7 +35,7 @@ return {
{
provider = function()
if
require("heirline.conditions").buffer_matches({
conditions.buffer_matches({
buftype = require("dko.utils.buffer").SPECIAL_BUFTYPES,
filetype = require("dko.utils.buffer").SPECIAL_FILETYPES,
})
Expand Down Expand Up @@ -128,8 +130,13 @@ return {
condition = function()
return not vim.bo.modifiable or vim.bo.readonly
end,
provider = "",
hl = "dkoLineImportant",
{
provider = "",
hl = "dkoLineImportant",
},
{
provider = " ",
},
},
},

Expand Down Expand Up @@ -169,9 +176,11 @@ return {
final = vim.fn.pathshorten(path, 1)
end
end
return ("in %s%s "):format("%<", final)
return ("in %s%s/ "):format("%<", final)
end,
hl = function()
return active_highlight("Comment")
end,
hl = "Comment",
},
},
},
Expand Down
26 changes: 21 additions & 5 deletions nvim/lua/dko/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -680,14 +680,29 @@ M.bind_telescope = function()
require("telescope.builtin").buffers({ layout_strategy = "vertical" })
end, { desc = "Telescope: pick existing buffer" })

map("n", "<A-c>", function()
require("telescope.builtin").find_files({
hidden = true,
layout_strategy = "vertical",
})
end, { desc = "Telescope: files in cwd" })

map("n", "<A-f>", function()
-- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#falling-back-to-find_files-if-git_files-cant-find-a-git-directory
local res =
vim.system({ "git", "rev-parse", "--is-inside-work-tree" }):wait()
local finder = res.code == 0 and require("telescope.builtin").git_files
or require("telescope.builtin").find_files
finder({ layout_strategy = "vertical" })
end, { desc = "Telescope: pick files in CWD" })
if res.code == 0 then
require("telescope.builtin").git_files({
layout_strategy = "vertical",
show_untracked = true,
})
else
require("telescope.builtin").find_files({
hidden = true,
layout_strategy = "vertical",
})
end
end, { desc = "Telescope: files in git work files or CWD" })

map("n", "<A-g>", function()
require("telescope.builtin").live_grep({ layout_strategy = "vertical" })
Expand All @@ -699,8 +714,9 @@ M.bind_telescope = function()

map("n", "<A-p>", function()
require("telescope.builtin").find_files({
hidden = true,
layout_strategy = "vertical",
prompt_title = "Files in project",
prompt_title = "Files in buffer's project",
cwd = require("dko.project").root(),
})
end, {
Expand Down

0 comments on commit d9ea424

Please sign in to comment.