DisposaBoy / GoSublime

A Golang plugin collection for SublimeText 3, providing code completion and other IDE-like features.
MIT License
3.42k stars 302 forks source link

Probable user error = probable doc error = " &golang.GoFmt{}," did not work. #849

Closed dr2chase closed 5 years ago

dr2chase commented 6 years ago

I am sure this is user error, but I thought I read and understood margo.go, yet results show I did not. I added the line below for GoFmt and restarted sublime text, opened a Go file (and it reports Go mode), messed up the formatting, and saved it. It did not format on save.

        // both GoFmt and GoImports will automatically disable the GoSublime version
        // you will need to install the `goimports` tool manually
        // https://godoc.org/golang.org/x/tools/cmd/goimports
        //
        // gs: this replaces settings `fmt_enabled`, `fmt_tab_indent`, `fmt_tab_width`, `fmt_cmd`
        //
        &golang.GoFmt{},
        // or
        // golang.GoImports,

My likely workaround is to figure out how to run GoSublime with go 1.10 and use the old one.

DisposaBoy commented 6 years ago

Do you see an error message in the status bar?

Unlike some of the other reducers that can take options, golang.GoFmt and golang.GoImports are variables, not a types so they'd be used as-is.

Compilation will fail but in that case there should be an error in the console and a note about it in the status bar.

dr2chase commented 6 years ago

I haven't been able to find any error messages. E.g., with &golang.GoFmt{}, looking in the console

[15:24:38] margo: agent#012: starting
[15:24:38] margo: agent#012: ['/usr/local/google/home/drchase/.config/sublime-text-3/Packages/GoSublime/bin/margo.sh', 'start', 'margo.sublime', '-codec', 'msgpack']
[15:24:38] margo: agent#012: log: ``` go install -v -tags=margo -i margo.sh/cmd/margo.sublime ```
[15:24:38] margo: agent#012: log: ``` /usr/local/google/home/drchase/.config/sublime-text-3/Packages/GoSublime/bin/margo.sublime -codec msgpack ```
[15:24:38] margo: agent#012: log: store.go:137: started

But with golang.GoasdfasdfasdfFmt{}, I get the same, and no errors that I can see. Perhaps they flashed by before I could read them?

And also with golang.GoFmt and with &golang.GoFmt, I get no format on save.

DisposaBoy commented 6 years ago

That's baffling. The log seems fine and shows the expected output. Are you sure you're editing the correct file?

Press ctrl+.,ctrl+x which opens ~/.config/sublime-text-3/Packages/User/GoSublime/src/margo/margo.go. Make sure to save it as well.

You can also use the &DayTimeStatus{}, reducer, which should be enabled by default. This will show the time in the status bar confirming that everything's working.

dr2chase commented 6 years ago

Did all that. Saved the file, too.

The status bar shows line, column, tab size, and language. No time/date.

Unset GOPATH.

Went looking for other copies of margo.go

~/.config/sublime-text-3$ find . -name margo.go -print
./Packages/User/GoSublime/src/margo/margo.go

One possible mis-step, in following this instruction Uninstall GoSublime, there were no details, so I just removed Packages/GoSublime. If that's not adequate, perhaps more details are needed.

DisposaBoy commented 6 years ago

That's all that should be required. It's what I did to try to reproduce this.

Reading your logs again I see that it says ... -tags=margo ... instead of ... -tags="margo margo_extension" ... so it seems like the file's either being ignored or for some other reason the margo package isn't being detected.

Can you share the file?

Also I just fixed a fmt bug. It doesn't seem related to this, but you never know. Do the usual git pull to update and see if it helps.

dr2chase commented 6 years ago

Can I share which file?

DisposaBoy commented 6 years ago

your margo.go file

kortschak commented 6 years ago

I'm seeing the same problem. Weirdly, it's fine on my other machine and I see no change in the repo here that would explain that difference between the two.

The margo.go file is as it comes out of the box, or with the golang.GoImports line uncommented.

(I don't know if this is related, but the text "press ctrl+. ctrl+x to configure margo" remains - I don't know if this is intentional).

I'm on bf2ead85bfddd7e442ae89ec4b332ae22fb9dbfd.

disposaboy-afk commented 6 years ago

Do you happen to have a margo pkg in your GOPATH?

I think I found the issue (more GOPATH woes). It should be fixed by https://github.com/DisposaBoy/GoSublime/commit/ffe9020c94df6fb068828aa672ac1bf815fa9e98

kortschak commented 6 years ago

My GOPATH is $HOME, in ~/src I have ./lime/3rdparty/bundles/GoSublime/margo9, that's all.

ffe9020c94df6fb068828aa672ac1bf815fa9e98 does not fix it, since I am at bf2ead85bfddd7e442ae89ec4b332ae22fb9dbfd which is after that. Is there some way I can get mor logging to the console, because at the moment, it doesn't look to me like there is very much useful verbosity available to help figure out what is going on here.

disposaboy-afk commented 6 years ago

I think bf2ead8 came before ffe9020 - just do a git pull to get the latest. I also added some logging when not using the margo extension pkg.

kortschak commented 6 years ago

Sorry, poor reading skills on my part. I am at b8125e243263b212810c7334e23d1cf87063d482, and still see the problem.

kortschak commented 6 years ago

OK, have just pulled to 32965f016f0c3d6b8ec693a09002bc617c2589b7 and the problems appear to be fixed.

Thanks!

disposaboy-afk commented 6 years ago

Great! thanks for confirming :)

dr2chase commented 6 years ago

Related, this time trying it on a Mac. Fresh clone

* 7a6fe69 (HEAD -> development, origin/development) ANN 18.08.15

follow instructions, and I think it tries to look for "margo" in

/Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/margo

instead of in

/Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/gosublime/margo
startup, version: 3176 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/drchase/Library/Application Support/Sublime Text 3/Packages
state path: /Users/drchase/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/drchase/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Sublimerge Pro", "Vintage"]
generating syntax summary
generating meta info summary
pre session restore time: 0.426691
using gpu buffer for window
startup time: 0.522084
environment variables loaded using: /bin/bash -l
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.10-golangconfig
reloading plugin 0_package_control_loader.10-shellenv
reloading plugin 0_package_control_loader.20-newterm
reloading plugin 0_package_control_loader.20-package_events
reloading plugin GoGuru.goGuru
reloading plugin Golang Build.golang_build
reloading plugin GoOracle.goOracle
reloading plugin GoRename.goRename
reloading plugin lispindent.commands
reloading plugin lispindent.indent
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin Sublimerge 3.Sublimerge
reloading plugin ExportHtml.ExportBbcode
reloading plugin ExportHtml.ExportHtml
reloading plugin ExportHtml.HtmlAnnotations
reloading plugin GoSublime._after
reloading plugin GoSublime._before
reloading plugin GoSublime.GoSublime
reloading plugin GoSublime.gs9o
reloading plugin GoSublime.gscommands
reloading plugin GoSublime.gscomplete
reloading plugin GoSublime.gsdoc
reloading plugin GoSublime.gsev
reloading plugin GoSublime.gslint
reloading plugin GoSublime.gspalette
reloading plugin GoSublime.gstest
reloading plugin GoSublime.margo_sublime
reloading plugin SFTP.SFTP
reloading plugin User.characterCounter
plugins loaded
GoRename: ('debug:', False)
GoRename: ('use_golangconfig', False)
GoRename: ('version:', '0.1.12')
GoGuru: ('debug:', False)
GoGuru: ('use_golangconfig', False)
GoGuru: ('version:', '0.1.14')
GoSublime r18.08.15-1: _before.init()
GoSublime r18.08.15-1: gs.init()
GoSublime r18.08.15-1: sh.init()
GoSublime r18.08.15-1 sh: using shell env GOPATH=/Users/drchase/GoogleDrive/work/gocode
GoSublime r18.08.15-1 sh: using shell env GOROOT=/Users/drchase/GoogleDrive/work/go
GoSublime r18.08.15-1 sh: using shell env PATH=/Users/drchase/bin:/Users/drchase/GoogleDrive/work/go/bin:/Users/drchase/GoogleDrive/work/gocode/bin:/opt/local/bin:/opt/local/sbin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/bin:/Users/drchase/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/bin:/Users/drchase/GoogleDrive/work/gocode/bin:/Users/drchase/bin:/Users/drchase/GoogleDrive/work/go/bin:/opt/local/bin:/opt/local/sbin:/Users/drchase/GoogleDrive/work/fuchsia/.jiri_root/bin:/Users/drchase/go/bin:/usr/local/go/bin:/usr/local/opt/go/bin:/Users/drchase/GoogleDrive/work/fuchsia/.jiri_root/bin
GoSublime r18.08.15-1 sh: go version: `devel..c882f4b6b1` (raw version string `devel +c882f4b6b1 Tue Aug 14 20:40:15 2018 +0000`)
GoSublime r18.08.15-1 sh: shell bootstrap took 0.420s
GoSublime r18.08.15-1: margo.init()
GoSublime r18.08.15-1: mg9.init()
[14:50:19] margo: agent#007: starting
GoSublime r18.08.15-1: _after.init()

** 2018-08-15 14:50:19.862642 **:
GoSublime init r18.08.15-1 (0.003s)
|   install margo: no
|   install state: done
| sublime.version: 3176
| sublime.channel: stable
|       about.ann: a18.08.15-1
|   about.version: r18.08.15-1
|         version: r18.08.15-1
|        platform: osx-x64
|            ~bin: ~/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/osx-x64/bin
|       margo.exe: ~bin/gosublime.margo_r18.08.15-1_devel..c882f4b6b1.exe (ok)
|          go.exe: ~/GoogleDrive/work/go/bin/go (ok)
|      go.version: devel..c882f4b6b1
|          GOROOT: ~/GoogleDrive/work/go
|          GOPATH: ~/GoogleDrive/work/gocode
|           GOBIN: (not set)
|       set.shell: []
|       env.shell: /bin/bash
|       shell.cmd: ['/bin/bash', '-l', '-c', '${CMD}']
|    sh.bootstrap: 
|                >  using shell env GOPATH=~/GoogleDrive/work/gocode
|                >  using shell env GOROOT=~/GoogleDrive/work/go
|                >  using shell env PATH=~/bin:~/GoogleDrive/work/go/bin:~/GoogleDrive/work/gocode/bin:/opt/local/bin:/opt/local/sbin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:~/Library/Application Support/Sublime Text 3/Packages/GoSublime/bin:~/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/bin:~/GoogleDrive/work/gocode/bin:~/bin:~/GoogleDrive/work/go/bin:/opt/local/bin:/opt/local/sbin:~/GoogleDrive/work/fuchsia/.jiri_root/bin:~/go/bin:/usr/local/go/bin:/usr/local/opt/go/bin:~/GoogleDrive/work/fuchsia/.jiri_root/bin
|                >  go version: `devel..c882f4b6b1` (raw version string `devel +c882f4b6b1 Tue Aug 14 20:40:15 2018 +0000`)
|                >  shell bootstrap took 0.420s
|                >
--------------------------------

[14:50:21] margo: agent#007: ['/Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/bin/margo.sh', 'start', 'margo.sublime', '-codec', 'msgpack']
[14:50:21] margo: agent#007: log: ``` go install -v -tags=margo -i margo.sh/cmd/margo.sublime ```
[14:50:22] margo: agent#007: log: ``` "/Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/bin/margo.sublime" -codec msgpack ```
Package Control: Skipping automatic upgrade, last run at 2018-08-15 14:38:23, next run at 2018-08-15 15:38:23 or after
[14:50:22] margo: agent#007: log: store.go:137: started
[14:50:22] margo: agent#007: log: restart.go:156: Mg/Restart: exit status 1
[14:50:22] margo: agent#007: log: ``` go install -v -tags=margo -i margo.sh/cmd/margo.sublime ```
[14:50:22] margo: agent#007: log: check console for errors
[14:50:22] margo: agent#007: log: *Not* using margo extension: cannot find package "margo" in any of:
[14:50:22] margo: agent#007: log:   /Users/drchase/GoogleDrive/work/go/src/margo (from $GOROOT)
[14:50:22] margo: agent#007: log:   /Users/drchase/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/src/margo (from $GOPATH)
[14:50:22] margo: agent#007: log:   /Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/margo
[14:50:22] margo: agent#007: log: agent GOPATH is /Users/drchase/Library/Application Support/Sublime Text 3/Packages/User/GoSublime:/Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime
[14:50:22] margo: agent#007: log: 
reloading /Users/drchase/Library/Application Support/Sublime Text 3/Packages/GoSublime/CHANGELOG.md

This is what was actually there:

~/Library/Application Support/Sublime Text 3/Packages$ find . -name margo -print
./GoSublime/pkg/darwin_amd64/margo.sh/cmdpkg/margo
./GoSublime/src/gosublime/cmd/margo
./GoSublime/src/gosublime/margo
./GoSublime/src/margo.sh/cmdpkg/margo
DisposaBoy commented 6 years ago

@dr2chase the package should be at */Users/drchase/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/src/margo*. src/gosublime/margo is from the old version of margo.

When you press cmd+.,cmd+x it should automatically create it for you if it doesn't exist and then open the main pkg file which is margo.go by default.

dr2chase commented 6 years ago

cmd+., cmd+x does the trick, at least when applied to CHANGELOG.md. I think it may not have worked in a different buffer, is that possible?

(thanks!)

DisposaBoy commented 6 years ago

@dr2chase I'm glad it works (finally!:)

The key binding https://github.com/DisposaBoy/GoSublime/blob/development/Default%20(OSX).sublime-keymap#L3 has no context applied to it so it should work everywhere, unless it's conflicting with some other plugin's keybinding.

If you open the command palette and start typing gs: edit margo extension it should tell you what keys it's bound to.