Skip to content

Instantly share code, notes, and snippets.

@deepakkamesh
Last active June 17, 2018 02:17
Show Gist options
  • Select an option

  • Save deepakkamesh/0f3875f5fd0c357ee323618133348849 to your computer and use it in GitHub Desktop.

Select an option

Save deepakkamesh/0f3875f5fd0c357ee323618133348849 to your computer and use it in GitHub Desktop.
Setting up golang dev on Linux ARM (raspberry pi)
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# set window split
bind-key v split-window -h
bind-key b split-window
# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01
# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange
# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange
# clock
set-window-option -g clock-mode-colour green #green
set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left-length 20
set -g status-right-length 140
set -g status-left '#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]'
set -g status-right '#[fg=green,bg=default,bright]#(tmux-mem-cpu-load) #[fg=red,dim,bg=default]#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'
set -g default-terminal "screen-256color"
# Enable Mouse
#set -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on
set-option -g mouse on
# C-b is not acceptable -- Vim uses it
# set-option -g prefix C-q
# bind-key C-q last-window
unbind C-b
set-option -g prefix `
bind ` send-prefix
# Vi copypaste mode
set-window-option -g mode-keys vi
bind [ copy-mode
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind ] paste-buffer
# Focus:
set -g focus-events on
set nocompatible
filetype off
call plug#begin()
Plug 'fatih/vim-go'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'fatih/molokai'
Plug 'Valloric/YouCompleteMe'
Plug 'flazz/vim-colorschemes'
Plug 'google/vim-maktaba'
Plug 'google/vim-codefmt'
Plug 'google/vim-glaive'
call plug#end()
call glaive#Install()
" Color Scheme
let g:rehash256 = 1
let g:molokai_original = 1
" colorscheme molokai
colorscheme mopkai
" AutoFormat multiple file types.
augroup autoformat_settings
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,proto,javascript AutoFormatBuffer clang-format
autocmd FileType dart AutoFormatBuffer dartfmt
autocmd FileType go AutoFormatBuffer gofmt
autocmd FileType gn AutoFormatBuffer gn
autocmd FileType html,css,json AutoFormatBuffer js-beautify
autocmd FileType java AutoFormatBuffer google-java-format
autocmd FileType python AutoFormatBuffer yapf
" Alternative: autocmd FileType python AutoFormatBuffer autopep8
augroup END
" Syntax highlighting
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_trailing_whitespace_error = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_array_whitespace_error = 1
" go fmt settings
let g:go_fmt_fail_silently = 0
let g:go_fmt_command = "goimports"
" Additional highlights
let g:go_auto_type_info = 0
" Disabled because of lack of json_decode
let g:go_auto_sameids = 0
let g:go_fmt_autosave = 1
" Current leader key \
let mapleader = ","
" Show function declarations
nmap <C-g> :GoDecls<cr>
imap <C-g> <esc>:<C-u>GoDecls<cr>
" Show documentation
nmap <C-d> :GoDoc<cr>
imap <C-d> <esc>:<C-u>GoDoc<cr>
" Command Mappings
au FileType go nmap <Leader>s <Plug>(go-def-split)
au FileType go nmap <Leader>v <Plug>(go-def-vertical)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>l <Plug>(go-metalinter)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>d <Plug>(go-doc)
au FileType go nmap <Leader>c <Plug>(go-coverage)
" Go-Info
nmap <C-i> :GoInfo<cr>
imap <C-i> <esc>:GoInfo<cr>
" Fast saving
nnoremap <leader>w :w!<cr>
nmap <C-w> :w!<cr>
imap <C-w> <esc>:w!<cr>
" Autocomplete
inoremap <C-a> <C-x><C-o>
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" Better split switching
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Quick fix window navigation
" Next line
map <C-n> :cn<CR>
" Prev Line
map <C-m> :cp<CR>
" Close window
nnoremap <leader>a :cclose<CR>
set nocompatible
set autowrite "Autowrite on save
set mouse=a
syntax on
filetype on
set completeopt=menu,menuone
set number
set nowrap
set showcmd " Show me what I'm typing
set showmode " Show current mode.
set clipboard=unnamed
"rotate between open buffers
map <S-Tab> :bn <CR>
"Select between open buffers
map <C-o> :CtrlPBuffer <CR>
match ErrorMsg '\s\+$'
set tabstop=2
set backspace=2
set expandtab
set ruler
##### install the latest golang for ARM
# wget https://golang.org/dl/<ver>
tar -C /usr/local -xvf <downloaded file>
# add the following to your .profile
export GOPATH=/home/dkg/Projects/golang
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
export TERM=xterm-256color
# Create golang dir if not exists
mkdir -p /home/dkg/Projects/golang
# Install misc dev tools
sudo apt-get install git
sudo apt-get install gcc
sudo apt-get install vim
sudo apt-get install make
##### Setup VIM for go dev.
## Setup plugin manager
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Copy .vimrc to local path.
#From VIM
:PlugInstall
# OPTIONAL Install grpc/protobug
# http://www.grpc.io/docs/quickstart/go.html
go get google.golang.org/grpc
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
# Install proto compiler
# for ARM follow C++ install instructions
https://github.com/google/protobuf/blob/master/src/README.md
Tmux: (tmux buffer is sync'ed with clipboard)
Copy to its buffer: `[ v y
Paste from its buffer: `]
Use this to copy between tmux windows or tmux and clipboard.
Vim (without tmux)
set clipboard=unnamed sync the clipboard with vim so just (y and ctrl+v) or (ctrl+c and p) depending on direction.
VIM Shortcuts:
C + ] or gd - Go to definition
C + t - Go back to previous location.
C + g - GoDecls
[[ ]] - Navigate between functions
% - move to the matching bracket
y,d i {,( - yank or delete inside
:GoRename - identified refactor
C + p - show list of files on disk in directory
C + o - show open buffers
C + w - save in any mode
C + a - autocomplete
o - insert new line below
O - inert new line above
ma - set mark `a - go to mark a
copy/cut and replace: yw or dw to copy or cut and viwp to replace word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment