I want a helper command for refactoring code in Go language. I have not found ready for use function for this task in
lsp. It should declare variable from the word under the point and place it as a type definition for example in the previous row. In Go syntax it looks like: var name type where name is a variable name and type is a variable type.
I have got the code:
(defun my-go-declare-var () "Insert var declaration." (interactive) (let ((name (current-word))) (previous-line) (insert "var " name " <type>")))
It looks for current word and inserts it on previous line.
The problem is how to get the type of my variable? I tried to find appropriate
lsp functions but not found any that returns the type in plain text. Also lsp-ui shows the hint with variable type in echo area:
But I can't understand how to catch it.