Hover support

This commit is contained in:
Zachary Yedidia
2020-08-11 19:40:59 -04:00
parent 4af1dfcbd8
commit e3689ffbd8
11 changed files with 301 additions and 83 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/zyedidia/micro/v2/internal/buffer"
"github.com/zyedidia/micro/v2/internal/clipboard"
"github.com/zyedidia/micro/v2/internal/config"
"github.com/zyedidia/micro/v2/internal/lsp"
"github.com/zyedidia/micro/v2/internal/screen"
"github.com/zyedidia/micro/v2/internal/shell"
"github.com/zyedidia/micro/v2/internal/util"
@@ -1814,6 +1815,20 @@ func (h *BufPane) RemoveAllMultiCursors() bool {
return true
}
func (h *BufPane) SemanticInfo() bool {
info, err := h.Buf.Server.Hover(h.Buf.AbsPath, lsp.Position(h.Cursor.X, h.Cursor.Y))
if err != nil {
InfoBar.Error(err)
return false
}
info = strings.Split(info, "\n")[0]
InfoBar.Message(info)
return true
}
// None is an action that does nothing
func (h *BufPane) None() bool {
return true

View File

@@ -688,6 +688,7 @@ var BufKeyActions = map[string]BufKeyAction{
"JumpLine": (*BufPane).JumpLine,
"Deselect": (*BufPane).Deselect,
"ClearInfo": (*BufPane).ClearInfo,
"SemanticInfo": (*BufPane).SemanticInfo,
"None": (*BufPane).None,
// This was changed to InsertNewline but I don't want to break backwards compatibility

View File

@@ -72,6 +72,7 @@ var bufdefaults = map[string]string{
"Ctrl-w": "NextSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Alt-i": "SemanticInfo",
"Insert": "ToggleOverwriteMode",
// Emacs-style keybindings