-
Notifications
You must be signed in to change notification settings - Fork 0
Statusline revamp #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c6f49fd
Revamp statusline
nikero41 5e32cd0
Rename file
nikero41 8409288
Fix nil check
nikero41 6804b44
Change modified hl to match neotree
nikero41 4021368
Move colors variable to be computed once
nikero41 176a9e1
Add on_click for project
nikero41 6e0136c
Change custom name
nikero41 88bf195
Remove unneeded integration override
nikero41 3b9f3c9
Hook into harpoon hooks to refresh lualine
nikero41 5adc53b
Add types
nikero41 0df5ba5
Resolve lua_ls diagnostics
nikero41 e7f56c1
Limit harpoon items in statusline
nikero41 b8157e8
Add null check
nikero41 a3bbae5
Fix property name
nikero41 b9d3cb4
Format code
github-actions[bot] c4df6a5
Remove debug print
nikero41 248ac38
Merge branch 'statusline-revamp' of github.com:snikoletopoulos/neovim…
nikero41 1edb385
Move filetype on bufferline and add click handler
nikero41 14653f3
Fix harpoon widget arrow logic
nikero41 ce6204c
Move diagnostics to bufferline
nikero41 35cb748
Move harpoon widgets to the right side
nikero41 cb05410
Merge branch 'main' into statusline-revamp
nikero41 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,77 @@ | ||
| ---@class StatusLine | ||
| ---@field statusline_icon_hl fun(self: StatusLine, icon_hl: string, default_hl_token: string): string | ||
| local StatusLine = {} | ||
|
|
||
| function StatusLine:statusline_icon_hl(icon_hl, default_hl_token) | ||
| local base_hl = default_hl_token:match("%%#(.-)#") or default_hl_token | ||
| local group = ("Nikero_%s_%s"):format(base_hl, icon_hl):gsub("[^%w_]", "_") | ||
| local icon = vim.api.nvim_get_hl(0, { name = group, link = false }) | ||
|
|
||
| if next(icon) ~= nil then return group end | ||
|
|
||
| local base = vim.api.nvim_get_hl(0, { name = base_hl, link = false }) | ||
| local new_icon = vim.api.nvim_get_hl(0, { name = icon_hl, link = false }) | ||
|
|
||
| vim.api.nvim_set_hl(0, group, { fg = new_icon.fg, bg = base.bg }) | ||
|
|
||
| return group | ||
| end | ||
|
|
||
| function StatusLine:harpoon_item(default_hl, active_index) | ||
| return function(index, item) | ||
| local file_path = vim.fn.fnamemodify(item.value, ":p") | ||
| local icon, base_icon_hl = require("mini.icons").get("file", file_path) | ||
|
|
||
| local is_active = index == active_index | ||
| local base_hl = default_hl | ||
| if is_active then base_hl = "%#OverlayActive#" end | ||
|
|
||
| local icon_hl = self:statusline_icon_hl(base_icon_hl, base_hl) | ||
| local icon_str = self:wrap(icon_hl, icon) .. base_hl | ||
|
|
||
| local value = string.format("%s %d", icon_str, index) | ||
|
|
||
| if is_active then | ||
| local side_hl = self:statusline_icon_hl("OverlayActiveInverted", default_hl) | ||
| value = self:wrap(side_hl, "") .. value .. self:wrap(side_hl, "") .. default_hl | ||
| else | ||
| value = string.format(" %s ", value) | ||
| end | ||
|
|
||
| return value | ||
| end | ||
| end | ||
|
|
||
| local MAX_DISPLAYED_WIDGETS = 3 | ||
|
|
||
| function StatusLine:harpoon_widget(default_hl) | ||
| local current_file = vim.fn.expand("%:p") | ||
| local items = require("harpoon"):list().items | ||
|
|
||
| local active_index = vim.iter(ipairs(items)):find( | ||
| function(_, item) return vim.fn.fnamemodify(item.value, ":p") == current_file end | ||
| ) | ||
|
|
||
| local start_index = 1 | ||
| if #items > MAX_DISPLAYED_WIDGETS and active_index >= MAX_DISPLAYED_WIDGETS - 1 then | ||
| start_index = math.min(math.max(active_index - 1, 0), #items - MAX_DISPLAYED_WIDGETS + 1) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| end | ||
|
|
||
| local widgets = vim | ||
| .iter(ipairs(items)) | ||
| :skip(start_index - 1) | ||
| :take(MAX_DISPLAYED_WIDGETS) | ||
| :map(self:harpoon_item(default_hl, active_index)) | ||
| :join("") | ||
|
|
||
| if start_index ~= 1 then widgets = string.gsub(widgets, "^%s", "<") end | ||
| if start_index ~= #items - MAX_DISPLAYED_WIDGETS + 1 then | ||
| widgets = string.gsub(widgets, "%s$", ">") | ||
| end | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return widgets | ||
| end | ||
|
|
||
| function StatusLine:wrap(hl, text) return "%#" .. hl .. "#" .. text end | ||
|
|
||
| return StatusLine | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.