Skip to content

Commit

Permalink
feat(config): customisable group action icon (#347)
Browse files Browse the repository at this point in the history
Co-authored-by: sofa <babalark@proton.me>
Co-authored-by: Marc Jakobi <mrcjkb89@outlook.com>
Co-authored-by: Marc Jakobi <marc@jakobi.dev>
  • Loading branch information
4 people authored Apr 14, 2024
1 parent c5caed0 commit 555ba5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.22.0] - 2024-04-14

### Added

- Config: Customise group action icon with `tools.code_actions.group_icon`.
Thanks [@ColdMacaroni](https://github.com/ColdMacaroni)!

## [4.21.2] - 2024-04-13

### Fixed
Expand Down
1 change: 1 addition & 0 deletions doc/rustaceanvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ RustaceanHoverActionsOpts *RustaceanHoverActionsOpts*
RustaceanCodeActionOpts *RustaceanCodeActionOpts*

Fields: ~
{group_icon?} (string) Text appended to a group action. Default: `" ▶"`
{ui_select_fallback?} (boolean) Whether to fall back to `vim.ui.select` if there are no grouped code actions. Default: `false`


Expand Down
4 changes: 2 additions & 2 deletions lua/rustaceanvim/commands/code_action_group.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ local function compute_width(action_tuples, is_group)
local text = action.title

if is_group and action.group then
text = action.group .. ''
text = action.group .. config.tools.code_actions.group_icon
end
local len = string.len(text)
if len > width then
Expand Down Expand Up @@ -180,7 +180,7 @@ local function on_code_action_results(results, ctx)
local idx = 1
for key, value in pairs(M.state.actions.grouped) do
value.idx = idx
vim.api.nvim_buf_set_lines(M.state.primary.bufnr, -1, -1, false, { key .. '' })
vim.api.nvim_buf_set_lines(M.state.primary.bufnr, -1, -1, false, { key .. config.tools.code_actions.group_icon })
idx = idx + 1
end

Expand Down
1 change: 1 addition & 0 deletions lua/rustaceanvim/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim
---@field replace_builtin_hover? boolean Whether to replace Neovim's built-in `vim.lsp.buf.hover` with hover actions. Default: `true`

---@class RustaceanCodeActionOpts
---@field group_icon? string Text appended to a group action
---@field ui_select_fallback? boolean Whether to fall back to `vim.ui.select` if there are no grouped code actions. Default: `false`

---@alias lsp_server_health_status 'ok' | 'warning' | 'error'
Expand Down
4 changes: 4 additions & 0 deletions lua/rustaceanvim/config/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ local RustaceanDefaultConfig = {
},

code_actions = {
--- text appended to a group action
---@type string
group_icon = '',

--- whether to fall back to `vim.ui.select` if there are no grouped code actions
---@type boolean
ui_select_fallback = false,
Expand Down

0 comments on commit 555ba5e

Please sign in to comment.