Skip to content

Commit

Permalink
add ability to configure colors with highlight groups (#57)
Browse files Browse the repository at this point in the history
* fix: global highlights are overridden on pick

* fix: hl set by nvim API is not applied

* fix: lint issues
  • Loading branch information
s1n7ax committed Jul 28, 2023
1 parent 6e98757 commit 57cf8cf
Show file tree
Hide file tree
Showing 9 changed files with 446 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.globals": [
"vim"
],
"diagnostics.disable": [
"duplicate-set-field"
]
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ require('window-picker').pick_window({
})
```

## Theming

If you just want to define the colors using Neovim Highlights, then it's totally
possible. You can set following highlights manually.

- `WindowPickerStatusLine` (currently focused window statusline highlights)
- `WindowPickerStatusLineNC` (currently unfocused window statusline highlights)
- `WindowPickerWinBar` (currently focused window winbar highlights)
- `WindowPickerWinBarNC` (currently unfocused window winbar highlights)

## Breaking changes in v2.0.0

_Before_: return value from `selection_display` will be wrapped by `'%='` and
Expand Down
72 changes: 69 additions & 3 deletions dev/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
local cwd = vim.fn.getcwd()
vim.opt.runtimepath:prepend(cwd)

--[[
-- plugin name will be used to reload the loaded modules
--]]
Expand All @@ -21,12 +24,75 @@ end

-- executes the run method in the package
local run_action = function()
require(package_name).setup()
local window = require(package_name).pick_window()
vim.cmd.messages('clear')

require(package_name).setup({
include_current_win = true,
picker_config = {
statusline_winbar_picker = {
use_winbar = 'always', -- "always" | "never" | "smart"
},
},
highlights = {
statusline = {
focused = {
fg = 'yellow',
bg = 'yellow',
bold = true,
},
unfocused = {
fg = 'yellow',
bg = 'yellow',
bold = true,
},
},
winbar = {
focused = {
fg = 'red',
bg = 'blue',
bold = true,
},
unfocused = {
fg = 'green',
bg = 'black',
bold = true,
},
},
},
})

vim.pretty_print('>>>', window)
local window = require(package_name).pick_window({
-- highlights = {
-- enabled = false,
-- statusline = {
-- focused = {
-- fg = 'blue',
-- bg = 'red',
-- bold = true,
-- },
-- unfocused = {
-- fg = 'black',
-- bg = 'white',
-- bold = true,
-- },
-- },
-- winbar = {
-- focused = {
-- fg = 'red',
-- bg = 'blue',
-- bold = true,
-- },
-- unfocused = {
-- fg = 'green',
-- bg = 'black',
-- bold = true,
-- },
-- },
-- },
})

if not window then
print('result is nil')
return
end

Expand Down
1 change: 1 addition & 0 deletions lua/window-picker/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ local config = {
-- You can pass in the highlight name or a table of content to set as
-- highlight
highlights = {
enabled = true,
statusline = {
focused = {
fg = '#ededed',
Expand Down
Loading

0 comments on commit 57cf8cf

Please sign in to comment.