Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snippets: Some golang snippets not expanding #11

Open
nvkalinin opened this issue Mar 21, 2022 · 0 comments
Open

snippets: Some golang snippets not expanding #11

nvkalinin opened this issue Mar 21, 2022 · 0 comments

Comments

@nvkalinin
Copy link

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant