Git Product home page Git Product logo

vim-go-tutorial's Issues

Make GoBuild build and actually save it

Often I'm working and I'd like to keep building, and when it works, actually use the resulting binary. Is there a way to make :GoBuild save the binary? Is there some other command I should use?

Installing vim-go binaries from the command line.

Just for reference, I have created an Ubuntu Docker image to use as a Go development environment. As part of the environment I would like to have vim-go and its binaries preinstalled in the image. However I am having difficulties scripting the :GoInstallBinaries functionality in my Dockerfile.

The command I am using is $ vim +Silent +GoInstallBinaries +qall and it successfully kicks of the install process. However, this always stalls when the 'screen becomes full':

screen shot 2017-09-19 at 12 56 29

The same thing happens when I install directly from within vim with:GoInstallBinaries where I need to press the space bar to carry on the installation process.

Does anyone know of a way to get around this issue?

Independent stacks for each vim window when using GoDef

When using the go to definition :GoDef feature to navigate the source code with multiple vim windows open, each window will operate on the same :GoDefStack. This means that if you navigated to one area of the code in one window, all the other windows opened in the same vim process will see the same GoDef stack and subsequently push and pop on the same stack. This becomes a bit confusing as you move back and forth between windows pushing and popping as needed.

There are all sorts of combinations of this behavior that are cumbersome but here is a trivial example to reproduce it using version 1.14:

  1. Open a Go file for editing inside of a project that you can GoDef in.
  2. Split the window however you'd like (vertical or horizontal) so that you have 2 windows operating on the same buffer for that Go file.
  3. Then go to a spot in the code where you can use GoDef e.g. function, type, etc. and execute :GoDef or your equivalent hot-key.
  4. Move to the other window and run :GoDefStack and observe how you're using the same stack as the first window.
  5. Now go ahead and pop by using :GoDefPop or your equivalent hot-key and observe how you'll go back to the spot that you previously ran :GoDef from in the first window. This is confusing because you never navigated anywhere in this window.
  6. Move back to the first window and try to pop there using :GoDefPop or your equivalent hot-key. Observe how you don't go anywhere because you've already popped in the other window. So you're sort of stuck without a trail back home. :( Now you have to :GoDefStack to try and figure out where you started from to get back home in this window.

While in this trivial example it's not too big a deal, as the levels of the stack grow and you fork to new areas of the code, this begins to get really hairy. Instead, the GoDef feature would be greatly enhanced if we had independent stacks for each vim window.

Filetype not being correctly loaded on Windows

I am running Vim 8.0.311 on Windows 10. I have filetype enabled in my .vimrc
filetype plugin on
If I do :filetype? then Vim reports go. However, it looks like the contents of ftplugin\go.vim are not being loaded because the setlocal omnifunc isn't being set and other mappings like gd aren't being set.

map <c-m> remaps <CR> in vim

map <C-m> :cprevious<CR>

this breaks hitting enter in a command line buffer:
E11: Invalid in command-line window; <CR> executes, CTRL-C quits

verbose map :
<CR> :cprevious<CR>

is probably more appropriate.

Japanese translation

First of all, thanks for writing a great tutorial for vim-go!

Could you give me permission to translate this tutorial to Japanese?
Actually I've done translating 60% of it in my local machine.

If yes, when I finish the translation, can I send it as a pull request to this repository?
Or do you prefer the Japanese translation belong to my fork of this repository?

A query about certain symbol visible in vimgo environment.

This is not an issue exactly rather a question. Not sure if it related to vim-go environment also, suspecting it so as I have never seen it in case of vim.

1 > I am seeing +, ~, -, _ symbols just beside the line number in vim-go environment.
Do they mean something.
I tried searching in vim-go doc but unable to find any clue.

2> Secondly I am unable to copy using Shift + Insert after highlighting a piece of code using mouse pointer. Which works on console though. I am using vim-go in a screen environment via putty.

Kindly let me know if I am missing something obvious.

Different behavior between Neovim and Vim8 when lint

I use neovim as my editor. Recently I find that vim-go doesn't show lint warning when I save my file. And when I switch to vim8, It works.

So I debuged vim-go and found out that, with neovim, vim-go run lint synchronously, which send an extra --include argument to gometalinter. However vim-go send a abs path while gometalinter use a relative path. That's why I lost the lint info.

It's easy to fix this. But what I don't understand is that, why do vim-go use different argument to call gometalinter when synchronously and asynchronously?

Here is my init.vim:

call plug#begin()
Plug 'airblade/vim-gitgutter'
Plug 'altercation/vim-colors-solarized'
Plug 'bling/vim-airline'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'ervandew/supertab'
Plug 'fatih/vim-go'
Plug 'rking/ag.vim'
Plug 'scrooloose/nerdtree'
Plug 'sirver/ultisnips'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
colorscheme solarized
set autowrite
set background=dark
set clipboard=unnamedplus
set foldmethod=syntax
set foldnestmax=1
set list
set mouse=a
set nofoldenable
set noswapfile
set number
set shiftwidth=4
set tabstop=4
set wildignore=*/vendor/*
let g:SuperTabDefaultCompletionType="context"
"let g:go_autodetect_gopath = 0
let g:go_fmt_command="goimports"
let g:go_fmt_experimental=1
let g:go_list_type="quickfix"
let g:go_metalinter_autosave=1
let mapleader=" "
nmap <C-H> <C-W><C-H>
nmap <C-J> <C-W><C-J>
nmap <C-K> <C-W><C-K>
nmap <C-L> <C-W><C-L>
nmap <C-N> :NERDTreeToggle<CR>
nmap <Leader>a :cclose<CR>
nmap <Leader>m :cprevious<CR>
nmap <Leader>n :cnext<CR>
nmap <Leader>c <Plug>(go-coverage-toggle)
nmap <Leader>d <Plug>(go-def-split)
nmap <Leader>e <Plug>(go-rename)
nmap <Leader>f <Plug>(go-referrers)
nmap <Leader>i <Plug>(go-info)
nmap <Leader>r <Plug>(go-run)
nmap <Leader>s <Plug>(go-implements)
nmap <Leader>t <Plug>(go-test)
nmap <Leader>b :<C-u>call <SID>build_go_files()<CR>
function! s:build_go_files()
  let l:file = expand('%')
  if l:file =~# '^\f\+_test\.go$'
    call go#test#Test(0, 1)
  elseif l:file =~# '^\f\+\.go$'
    call go#cmd#Build(0)
  endif
endfunction

Set ENV VAR before running GoTest

My project requires to set some env var before running go test. How can configure vim-go to do something like source .env.dev && go test ... upon calling :GoTest in vim?

cnext and cprevious doesnt work

Hey,

i followed your tutorial and realised that cnext / cprevious wont switch between two errors. In my setup these errors get populated in the location list. Is there anything i have to reconfigure? Here is my simple init.vim

filetype off

call plug#begin('~/.nvim/plugged')
Plug 'flazz/vim-colorschemes'
Plug 'fatih/vim-go'
Plug 'christoomey/vim-tmux-navigator'
call plug#end()

filetype plugin indent on
syntax on
colorscheme materialtheme
set background=dark
syntax enable

let g:tmux_navigator_no_mappings = 1
nnoremap <M-l> :TmuxNavigateRight<cr>
nnoremap <M-h> :TmuxNavigateLeft<cr>
nnoremap <M-j> :TmuxNavigateDown<cr>
nnoremap <M-k> :TmuxNavigateUp<cr>
tnoremap <silent> <M-l> <C-\><C-n>:TmuxNavigateRight<cr>
tnoremap <silent> <M-h> <C-\><C-n>:TmuxNavigateLeft<cr>
tnoremap <silent> <M-j> <C-\><C-n>:TmuxNavigateDown<cr>
tnoremap <silent> <M-k> <C-\><C-n>:TmuxNavigateUp<cr>

let $NVIM_TUI_ENABLE_TRUE_COLOR=1

augroup reload_nvimrc
    autocmd!
    autocmd BufWritePost ~/.config/nvim/init.vim nested source ~/.config/nvim/init.vim

Please add a license to the repo

Hi @fatih,

Could you please add an explicit LICENSE file to the repo so that it's clear under what terms the content is provided, and under what terms user contributions are licensed?

Per GitHub docs on licensing:

Generally speaking, the absence of a license means that the default copyright laws apply. This means that you retain all rights to your source code and that nobody else may reproduce, distribute, or create derivative works from your work. This might not be what you intend.

Thanks!

list of necessary go tools

Hi,

I am following the tutorial to set up vim-go. There is a specific line:
"And finally be sure to install all necessary Go tools (such as guru, goimports, gocode, etc...)".
Is there a list somewhere of what all these tools are ? Even a short tool of the most commonly used ones would be very helpful.

Thanks for a great tool!

Jump to result when using :GoReferrers and :GoDescribe

Put your cursor on top of the handler and call :GoReferrers. This calls the referrers mode of vim-go, which finds references to the selected identifier, scanning all necessary packages within the workspace. The result will be a quickfix list, so you should be able to jump to the results easily.

How to jump to the result? I use 'Enter', but nothing happens. There is error "E553: No more items
" in statusbar. I tried find an answer in google but did not find anything.

Required to update vim though vim is latest version

brew upgrade vim
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (caskroom/versions).
No changes to formulae.

Error: vim 8.0.1553_1 already installed
bash-3.2$ vim golang.go
vim-go requires Vim 7.4.1689 or Neovim, but you're using an older version.
Please update your Vim for the best vim-go experience.
If you really want to continue you can set this to make the error go away:
let g:go_version_warning = 0
Note that some features may error out or behave incorrectly.
Please do not report bugs unless you're using Vim 7.4.1689 or newer.

YouCompleteMe (code completion + snippets setup)

I have always had issues with YouCompleteMe + any snippet plugin .. Can you talk about your setup on how you manage to achieve code completion.. since vim-go has built-in support for this, I would love to see it here.

Case type setting

After a step-by-step practice, I think the document here should be written like this

let g:go_addtags_transform = 'camelcase'

rather than

let g:go_snippet_case_type = "camelcase"

code example

type foo struct {
	ServerName string `json:"serverName"`
}

It's a great tutorial and please forgive me if i am wrong.

Windows instructions needed

Hello, it would be very handy to have Windows instructions, specifically ones which deal with the differences in the way _vimrc is handled. I've edited my _vimrc file so that the first line is Plug 'fatih/vim-go' but I get an error when I start Vim saying E492: Not an editor command Plug 'fatih/vim-go'

Missing information on HTML template

I spent a few month using vim-go without syntax highlighting for Go HTML template. I did not find documentation on the subject and I was using the .gohtml extension for my templates.

Today, I had a look at /ftdetect/gofiletype.vim and found the gohtmltmpl file type. I've just enabled it for .gohtml and I am very happy to have syntax highlighting in vim!

Maybe it is worth mentioning in the tutorial?

snippet section: expand panic after typing errp does not work nor does the section on fn,ff,ln,lf

the following does not work when working through Tutorial for vim-go examples under the snippet section: expand panic after typing errp does not work nor does the section on fn,ff,ln,lf ... the json hit tab does work

Snippet:
....

Let's put our cursor just after the newFoo() expression. Let's panic here if the err is non-nil. Type errp in insert mode and just hit tab. You'll see that it'll be expanded and put your cursor inside the panic()` function:

if err != nil {
panic( )
^
cursor position
}

It does not expand

I get this

19 func main() {
20 res, err := newFoo()errp
21
22 our, err := json.Marshal(res)
23 }

I can't see what is described

In the section Beautify the next line can be found:

"You'll see that it's gray, thus it's not valid. Prepend + to the build word and save it again:"

but I can't see it gray, it was until later that I activate the molokai, that I see it as gray. I am wondering if the theme part should be move a little up.

GoCoverage not Highlighting anything

Hi,
I'm having a weird issue with the vim-go plugin.
I started this tutorial and executed the :GoCoverage command - as it should be, some parts were highlighted green, others red. I then turned it off again, wrote the rest of the code and executed :GoCoverage again.
This time, it didn't highlight anything, but colored the whole file like it was a comment.
I am not able to get it being green and red again, I can just turn the Coverage off again and it's back to normal syntax highlighting.

Any idea on how I can debug this further?
I already tried re-opening vim and also executed go test -coverprofile tempfile, this seems to work just fine (Opened the browser and checked the highlighting).

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.