mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
feat: add argument description to UI when suggestions are available
Signed-off-by: cpendery <cpendery@vt.edu>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package suggestions
|
||||
|
||||
import "github.com/charmbracelet/lipgloss"
|
||||
|
||||
var SuggestionWithDescriptionBorder = lipgloss.Border{
|
||||
Top: "─",
|
||||
Bottom: "─",
|
||||
Left: "│",
|
||||
Right: "│",
|
||||
TopLeft: "┌",
|
||||
TopRight: "┐",
|
||||
BottomLeft: "├",
|
||||
BottomRight: "┤",
|
||||
}
|
||||
|
||||
var ArgumentDescriptionBorder = lipgloss.Border{
|
||||
Top: "",
|
||||
Bottom: "─",
|
||||
Left: "│",
|
||||
Right: "│",
|
||||
TopLeft: "",
|
||||
TopRight: "",
|
||||
BottomLeft: "└",
|
||||
BottomRight: "┘",
|
||||
}
|
||||
@@ -132,10 +132,15 @@ func pageSuggestions(suggestions []autocomplete.Suggestion, cursorLocation int)
|
||||
}
|
||||
|
||||
func (m Model) renderSuggestions(width int) string {
|
||||
suggestionBorder := lipgloss.NormalBorder()
|
||||
if m.argDescription != "" {
|
||||
suggestionBorder = SuggestionWithDescriptionBorder
|
||||
}
|
||||
|
||||
var style = lipgloss.NewStyle().
|
||||
Bold(true).
|
||||
Width(width).
|
||||
BorderStyle(lipgloss.NormalBorder()).
|
||||
BorderStyle(suggestionBorder).
|
||||
BorderForeground(lipgloss.Color("63"))
|
||||
|
||||
m.suggestions = pageSuggestions(m.suggestions, m.cursor)
|
||||
@@ -145,6 +150,17 @@ func (m Model) renderSuggestions(width int) string {
|
||||
r[idx] = m.renderSuggestion(suggestion.Name, idx, m.cursor, width)
|
||||
}
|
||||
|
||||
if m.argDescription != "" {
|
||||
descriptionStyle := lipgloss.NewStyle().
|
||||
Width(width).
|
||||
Border(ArgumentDescriptionBorder, false, true, true, true).
|
||||
BorderForeground(lipgloss.Color("63"))
|
||||
|
||||
return lipgloss.JoinVertical(
|
||||
lipgloss.Left,
|
||||
style.Render(strings.Join(r, "\n")),
|
||||
descriptionStyle.Render(m.argDescription))
|
||||
}
|
||||
return style.Render(strings.Join(r, "\n"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user