z_mirror/luapls
git clone https://git.raiguard.me/z_mirror/luapls
582fe74
main
1package lsp 2 3import ( 4"errors" 5 6"github.com/raiguard/luapls/lua/ast" 7"github.com/tliron/glsp" 8 protocol"github.com/tliron/glsp/protocol_3_16" 9) 10 11func (s * Server )textDocumentHighlight (ctx * glsp.Context ,params * protocol.DocumentHighlightParams ) ([]protocol.DocumentHighlight ,error ) { 12file := s .getFile (params .TextDocument .URI ) 13if file == nil { 14return nil ,errors .New ("File not found" ) 15 } 16if file .Block == nil { 17return nil ,errors .New ("Attempted to highlight file that has no AST" ) 18 } 19nodePath := ast .GetSemanticNode (file .Block ,file .LineBreaks .ToPos (params .Position )) 20if nodePath .Node == nil { 21return nil ,nil 22 } 23highlights := []protocol.DocumentHighlight {} 24// TODO: Labels 25_ ,ok := nodePath .Node .(ast.LeafNode ) 26if ! ok { 27return nil ,nil 28 } 29// TODO: References 30highlights = append (highlights , protocol.DocumentHighlight {Range :file .LineBreaks .ToProtocolRange (ast .Range (nodePath .Node ))}) 31 32// TODO: 33// def := file.Env.FindDefinition(nodePath) 34// if def != nil { 35// highlights = append(highlights, protocol.DocumentHighlight{Range: file.LineBreaks.ToProtocolRange(ast.Range(def))}) 36// } 37 38return highlights ,nil 39}