Created
May 30, 2019 22:03
-
-
Save rseyf/6b2998dafc8059fb0cbbed554e35c960 to your computer and use it in GitHub Desktop.
Sublime text 3 setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sublime text 3 basic setup: | |
=========================== | |
1 - install sublime text 3 | |
2 - install packagecontrol.io/installation | |
3 - install packages: Gofmt, Golang Build, sidebarenhancements, Materialized CSS Snippets, jquery, | |
Standard Format,CSS Media Query Snippets, Shell Exec,Terminal, Live Reload, git, HTMLAttributes | |
Sass,LESS, Color Picker, JsFormat, HTML-CSS-JS Prettify, All Autocomplete, Sublime Linter-jshint, | |
Babel, JavaScriptNext - ES6 Syntax, AdvancedNewFile, DocBlockr, Dockerfile Syntax Highlighting, | |
Laravel Blade Highlighter, PHPCompanion, Vuetify, ClangAutoComplete, EasyClangComplete | |
-- Open Shell Exec: Linux: ctrl + shift + c , Mac: shift + super + c | |
-- Open Terminal at File Press ctrl+shift+t on Windows and Linux, or cmd+shift+t on OS X | |
-- Open Terminal at Project Folder Press ctrl+alt+shift+t on Windows and Linux, or cmd+alt+shift+t on OS X | |
4 - go get golang.org/x/tools/cmd/goimports | |
5 - which goimports | |
6 - "Preferences > Package Settings > Gofmt > Settings - User" and add below content to it: | |
{ | |
"cmds": [ | |
["goimports"] | |
], | |
"format_on_save": true | |
} | |
now, Each time you save a .go file, you'll find that it gets automatically formatted and the import packages are updated. No more "imported and not used" errors! | |
========== | |
golinting: | |
========== | |
- install package "SublimeLinter" | |
- install an actual linter: | |
-- go get github.com/alecthomas/gometalinter | |
-- which gometalinter | |
-- gometalinter --install | |
- install the "SublimeLinter-contrib-gometalinter" plugin | |
-- go to "Preferences > Package Settings > SublimeLinter > Settings" and add the following settings to the SublimeLinter Settings - User file: | |
{ | |
"show_panel_on_save": "window", | |
"lint_mode": "save", | |
} | |
============= | |
autocomplete: | |
============= | |
- go get github.com/mdempsky/gocode | |
- which gocode | |
- cp -r $GOPATH/src/github.com/mdempsky/gocode/subl3 ~/.config/sublime-text-3/Packages/gocode | |
Note: If you're using MacOS then you will probably need to create a new Library/Application\ Support/Sublime\ Text\ 3/Packages/gocode directory | |
and copy the plugin into this. | |
- now you should see "gocode" in "Package Control: List Packages" list | |
- go to "Preferences > Settings" and add new trigger in the "Preferences.sublime-settings - User" file: | |
"auto_complete_triggers": [ | |
{"selector": "text.html", "characters": "<"}, | |
{"selector": "source.go", "characters": "."} | |
], | |
- restart the sublime text | |
=============== | |
Code navigation | |
=============== | |
- go get golang.org/x/tools/cmd/guru | |
- which guru | |
- install "GoGuru" package | |
To use the GoGuru tool, first place your cursor over the piece of code you're interested in. | |
Then if you open the command palette and type the GoGuru prefix you'll see a list of available commands, including: | |
GoGuru: callees – Show possible targets of selected function call | |
GoGuru: callers – Show possible callers of selected function | |
GoGuru: callstack – Show path from callgraph root to selected function | |
GoGuru: definition – Show declaration of selected identifier | |
GoGuru: describe – Describe selected syntax: definition, methods, etc | |
GoGuru: freevars – Show free variables of selection | |
GoGuru: implements – Show 'implements' relation for selected type or method | |
GoGuru: jump to definition – Open the file at the declaration of selected identifier | |
GoGuru: peers – Show send/receive corresponding to selected channel op | |
GoGuru: pointsto – Show variables the selected pointer may point to | |
GoGuru: referrers – Show all refs to thing denoted by selected identifier | |
GoGuru: what – Show basic information about the selected syntax node | |
GoGuru: whicherrs – Show possible values of the selected error variable | |
I find the GoGuru: jump to definition and GoGuru: callers commands particularly useful, and easier to use | |
than grepping or running Ctrl+F on the repository. | |
======== | |
snippets | |
======== | |
https://www.freecodecamp.org/news/a-guide-to-preserving-your-wrists-with-sublime-text-snippets-7541662a53f2/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment