GithubHelp home page GithubHelp logo

gotags's People

Contributors

afarresg avatar blu3gui7ar avatar dgsb avatar h8liu avatar jstemmer avatar kristofferhagen avatar lmars avatar lukaslueg avatar myitcv avatar outcoldman avatar zhouhua015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gotags's Issues

Why not add pattern to the output files?

Like pattern
random /tmp/nvimVaVjop/1.py /^import random$/;" i line:16
in python tags file.

Currently, i have a gotags file with line
EnvEnableProfiling /tmp/nvimORpwWJ/1.go 45;" c access:public line:45.

Normally this works with tagbar, but not this file https://github.com/ipfs/go-ipfs/blob/master/cmd/ipfs/main.go#L567, the special character '^C' break things.
Tagbar#JumpToTag always go to this line for whatever tags, this is because of the empty pattern, check https://github.com/majutsushi/tagbar/blob/master/autoload/tagbar.vim#L2483.

Parse error on variable-free for-range loops

Gotags chokes on the variable-free form of for-range loops that were introduced in Go 1.4.

For example, given the following code:

package main

import "fmt"

func main() {
        for range [3]int{} {
                fmt.Println("testing")
        }
}

Running gotags produces:

$ gotags main.go
parse error: main.go:6:6: expected operand, found 'range' (and 1 more errors)

!_TAG_FILE_FORMAT       2
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted/
!_TAG_PROGRAM_AUTHOR    Joel Stemmer    /[email protected]/
!_TAG_PROGRAM_NAME      gotags
!_TAG_PROGRAM_URL       https://github.com/jstemmer/gotags
!_TAG_PROGRAM_VERSION   1.3.0

Add or document recursive mode.

Isn't there a way to run this recursively on a directory? If there is, it's really not obvious and should be documented better :) and if there isn't, it would be supremely useful.

Variadic Interface is not recognized

Function with variadic interface as parameter is not recognized. For example, this code :

func Test(v ...interface{}) int {
	return 0
}

will give output like this :

Test    main.go 14;"    f       access:public   line:14 signature:(v )  type:int

I think this is related with #1

Use case question

Hi,

I'm starting with golang and i have installed gotags via https://github.com/fatih/vim-go.

I'd like to know what's the best way to generate the tags file.

My first approach has been go to $GOPATH and from there generate recursively the tags of all its subdirectories and also the contents of $GOROOT/src with a line like:

╭─[14:17:15] gonzalo@tribe/~/dev/sp/go
╰─○ gotags -R $GOROOT/src $GOPATH/src > tags

But if i press C-] over the Printf word in a line like fmt.Printf("Hello, world.\n") what i get from the tag window within vim is a list like:

  # pri kind tag               file
  1 F   m    Printf            /Users/gonzalo/dev/sp/go/src/g...tools/cmd/stringer/stringer.go
               access:public ctype:Generator line:173 signature:(format string, args )
               173
  2 F   f    Printf            /Users/gonzalo/dev/sp/go/src/golang.org/x/tools/cmd/vet/main.go
               access:public line:410 signature:(format string, args )
               410
  3 F   f    Printf            /Users/gonzalo/dev/sp/go/src/g...ools/cmd/vet/testdata/print.go
               access:public line:213 signature:(format string, args )
               213
  4 F   f    Printf            /usr/local/Cellar/go/1.4.2/libexec/src/fmt/print.go
               access:public line:196 signature:(format string, a ) type:int, error
               196
  5 F   m    Printf            /usr/local/Cellar/go/1.4.2/libexec/src/log/log.go
               access:public ctype:Logger line:159 signature:(format string, v )
               159
  6 F   f    Printf            /usr/local/Cellar/go/1.4.2/libexec/src/log/log.go
               access:public line:275 signature:(format string, v )
               275

Because this Printf function is from the fmt package i think that somehow it should be smart enough to jump to the print.go file from the fmt package in the go source code, right?

Have you got to deal with this somehow?

Thanks!

Give useful Usage example in README

Showing the --help output isn't useful. I'm in the root directory of my Go project. How do I generate a tags file for all *.go files recursively? I can do this with ctags with ctags -R . Or am I supposed to do it from within vim?

jump to wrong line

when using tagbar(latest version from master) with gotags (latest version from brew) to display go project tags, it jumps to wrong line of the source file.
most projects works just fine, but the following test project tags are always messing up.

https://github.com/hashicorp/serf

specificly is this file: cmd/serf/command/agent/ipc.go

I dont know which one's bug (gotags or tagbar), so issued it here.
Thank you.

on OSX if exuberant ctags is not installed, TagBar will complain

TagBar seems to check the version of ctags before it runs the language specific ctags (go tags), here. As a result, it will complain, that ctags is not "exuberant ctags". If you install ctags, via brew install ctags, then TagBar will proceed to work, and call gotags.

Perhaps this should be filed on tagbar rather than here, however simply noting the issue in the readme.md might be helpful for others. The error message seemed to imply the problem was with gotags, and not ctags itself.

Inconsistent field order among structs and interfaces

gotags/tag.go

Line 88 in 3751bad

sort.Sort(sort.StringSlice(fields))

This is the sample tags file generated for sarama package:

491 Messages consumer.go 285;" m access:public line:285 ntype:PartitionConsumer signature:() type:chan *ConsumerMessage
492 Messages consumer.go 402;" m access:public ctype:partitionConsumer line:402 signature:() type:chan *ConsumerMessage

For a struct method, the line number is after signature. For an interface method, the line number is before signature. It would be nice to keep the fields in consistent order.

Tagbar fails due to `gotag --version` invocation

Tagbar+gotags used to work fine for me; not sure what I changed, but now when I hit my :TagbarToggle bind, I get this error:

Tagbar: Ctags doesn't seem to be Exuberant Ctags!
BSD ctags will NOT WORK. Please download Exuberant Ctags from ctags.sourceforge.net and install it in a directory in your $PATH or set g:tagbar_ctags_bin.
Executed command: "'gotags' --version"
Command output:
flag provided but not defined: -version
gotags version 1.4.1
Usage: gotags [options] file(s)
  -L string
...

My vim config includes:

let g:tagbar_type_go = {
    \ 'ctagstype' : 'go',
    \ 'kinds'     : [
        \ 'p:package',
        \ 'i:imports:1',
        \ 'c:constants',
        \ 'v:variables',
        \ 't:types',
        \ 'n:interfaces',
        \ 'w:fields',
        \ 'e:embedded',
        \ 'm:methods',
        \ 'r:constructor',
        \ 'f:functions'
    \ ],
    \ 'sro' : '.',
    \ 'kind2scope' : {
        \ 't' : 'ctype',
        \ 'n' : 'ntype'
    \ },
    \ 'scope2kind' : {
        \ 'ctype' : 't',
        \ 'ntype' : 'n'
    \ },
    \ 'ctagsbin'  : 'gotags',
    \ 'ctagsargs' : '-sort -silent'
\ }
let g:tagbar_autoclose = 1
let g:tagbar_ctags_bin = 'gotags'

how to integrate with vim :tselect

vim/nvim :tselect can be used to search for a tag and select one from the results and jump to it.

this requires vim to read a tags file which is generated from ctags.

is gotags somehow a replacement for ctags ? is yes how do i use gotags with :tselect

Ignoring vendor folder

Anyway we can ignore the vendor folder easily ?

Current bash solution:

for x in $(ls -d -- */ | grep -v "vendor/"); do gotags -R ${x}. >> tags; done

aliased to gomktags

Allow additional return values in a constructor

For a function to be considered a constructor it must have a name starting with New, following the struct name. Its return value must be of the same struct type. There are some cases however where the constructor also returns an additional type, for example error or bool to indicate success. These functions are currently not seen as constructors.

As long as one of the parameters contains the actual struct type being created, mark the function as a constructor.

Add a struct scope to the symbol files

It would be nice to have something similar as the +m flag we have for C++ files in exhuberant ctags. It adds to the tags the name of the owning class. The tag file could also adds the package scope to the symbol.

Make command interface compatible with Exuberant and Universal ctags

Several editor plugins (e.g. vim-gutentags) invoke the tags generators with some specific flags:

                                            gutentags-ctags-requirements

If you're using the ctags modules (which is the default and only working one
at this point, really), you will need a tags generator that supports the
following arguments:

  • -f (to specify the output file)
  • --append (to append to an existing file while keeping it sorted)
  • --exclude (to exclude file patterns)
  • --options (to specify an options file)

This means you probably want Exhuberant Ctags or Universal Ctags. The basic
old BSD Ctags WON'T WORK. Other language-specific versions may or may not
work. Check with their help or man page.

In order to be able to use gotags with these plugins it needs to accept at least these flags:

  • -f
  • --append
  • --exclude
  • --options

parser error for interface type

I have the following code

type BasicTypes interface {
  // array types supported by KeyInArray generic function. The byte type is covered by uint8
  int | int8 | int16 | int32 | int64 |                           //    <==================
  uint | uint8 | uint16 | uint32 | uint64 |
  float32 | float64 | string
}
func KeyInArray[K BasicTypes](key K, list []K) bool {
  for _, lval := range list {
    if lval == key {
      return true
    }
  }
  return false
}

I am getting the following error when I run gotags on my code:

parse error: ...14:6: expected ';', found '|' (and 2 more errors)

The referenced line is indicated above with <====. The code compiles fine and works fine. Only gotags is complaining. Could someone explain why this is happening. Thanks.

Empty interface not recognized as type

Functions with an empty interface in the parameter list or return list are not recognized. When running gotags on a file containing the following function, the type of the resulting tag will have an incomplete signature and a missing return type:

func example(param interface{}) interface{} {
    return nil
}

actual output:
example test.go 3;" f access:private line:3 signature:(param )

expected:
example test.go 3;" f access:private line:3 signature:(param interface{}) type:interface{}

Unable to create the ctags for a list of files in a directory

The examples given in the readme file are pretty sparse on how you can run the gotags command over a directory structure without to provide an input file with the go files list to obtain the ctags file. Please give an example how you can do it with a single command to obtain all the files in a project and construct the ctags structure for them.

gotags fails for generics

Hi,
I have the following code.

type SdpDataSchemaCache[K comparable, V any] struct {
  capacity int
  dll      *list.List
  elements map[K]*list.Element
}

This code compiles with golang v1.21/22. However, I get the following error with gotags.

parse error: cache.go:9:27: expected ']', found comparable (and 2 more errors)

Not sure why gotags fails which the go compiler doesn't complain?

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.