Skip to content

snippets: Some golang snippets not expanding #11

Description

@nvkalinin

Steps to reproduce:

  1. Install micro and run plugin install snippets command.
  2. Open any .go file (e. g. micro main.go) and put the following text (make sure lf is indented with a tab):
package main

func main() {
	lf
}
  1. Place cursor right to lf and run the snippetinsert command (or use Alt-S).

Result: it says Unknown snippet "lf"

Expected behavior: lf expands to log.Printf("%s", var)

I looked through the snippets.lua code. It seems that the CursorWord function is problematic. It looks back for a word until it encounters a space (literally: if (r == " ") then) or beginning of the line. But in go they use tabs for indents. So it captures \tlf as a snippet name.

I think it should check for any white space, not just "space".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions