ctag database for Go - go

How to generate tags file for Go source
In mac, I installed exuberant ctags , and tried the below command in source directory
ctags -f gosource.tags -R `pwd`
But, it doesn't consider *.go files. Do I have to use -h option? But, isn't it only for header files, as per the manual?
Please give me the correct command so that I can use the tags file with vim. I also prefer absolute path so that I can keep the file anywhere
Thanks.
Edit:
I assumed current ctags support Go, seeing http://groups.google.com/group/golang-nuts/browse_thread/thread/3a4848db231b02c9.
but, http://ctags.sourceforge.net/languages.html desn't have go listed.

Add the following to ~/.ctags
--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/
(From http://go-wise.blogspot.com/2011/09/using-ctags-with-go.html)

--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/f,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/v,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/t,type/
Does indeed work with ctags 5.8. One slight change from the previous poster, ctags requires unique 1-char types at the ends of the regex lines. Thus /d,func/ should read /f,func/ intuitively. This allows the ctags to distinguish between and identify types, allowing ctags --go-types=fvt i.e.

I saw your post, bumbled around a bit trying to find a good tool for the job, tried ctags, and ultimately was unsatisfied. I wrote a program 'gotags' in Go that generates a ctags file for Go code. Its better than the current ctags support because, for example, it tags struct field names as well as the struct name itself. You can get it here: https://github.com/necro351/gotags.
Its a nice short simple Go program because it uses the standard library parser and has no extra features other than good Go parsing and tagging. Just check it out (or go get it) and do a go install. Also, if you have any suggestions or ideas about improving it, let me know.
Edit: I am an active Gopher and so will be updating this tool over time and as I use it.
Edit: I am not actively developing Go anymore. But my tool is very short and pretty much works as is so it should "just work" :)

universal-ctags supports Go. It's the successor of exuberant-ctags and works perfectly fine. See here for the man pages.

Check Go Dashborad/Projects, section "Tag Generators". Status of those tools is not known to me.
Edit 2011-11-22: Latest egotags fork announced today (cyclic reference possible ;-)

Related

vscode: Move Go code (type/function) to other file

How to move a function/type from one Go file to an other Go file in vscode?
... and the IDE should update all usages of the moved function/type ...
In the past I used Python and PyCharm, and it supported this kind of refactoring.
It seems that this feature (the move-refactoring) hasn't been implemented in VSCode yet. The only workaround that just came into my mind is this.
You can use the cmd gomvpkg to move a package to a new one. Thanks to this, if you have only the function within the file you should be good to go. It should also update the import statements (make sure to double-check them anyway). I know that it's boring in fact I keep copying/pasting functions between packages as it's faster.
It seems that this feature is already supported in Goland, so you can give it a try maybe if you wish.
Let me know!

How to spellcheck R comments with RStudio on R source files?

How to conveniently spellcheck R comments with RStudio on R source files?
I am writing a package and I want it to look professional. Thanks to Oxygen, all package's documentation lives in R comments, which by default is excluded from spell checking. So even if spell checking functionality does exist in RStudio, I don't know how to use it.
The spelling package is great for this: https://github.com/ropensci/spelling.
devtools::install_github("ropensci/spelling")
spelling::spell_check_package() # path to package Project
RStudio 1.3 will include this feature; and it is possible to already try it out.
Well this is moot now that Rstudio has spellcheck for spin documents!
So, I write a lot of my lessons and examples for teaching using spin rather than markdown. It just makes for an easier flow. The problem is that there is no spell-check in a spin document, much like your package documentation example.
What I have resorted to is using the terminal then running a command line spellchecker on the document.
I'm on linux so here is my workflow.
save the file I am working let's say example_lesson.R (typos and all)
open the terminal pane of Rstudio and cd to the right folder
make sure the file example_lesson.R is there
run the spell-checker
> aspell check example_lesson.R
Once I'm done with aspell, I go back to the editor window in Rstudio and it updates what I am working on with the spell-checked version. I spin it and I am done.
I've only tested with small examples, but it has worked thus far. Your mileage may vary. Hope that helps.

godoc without showing source code

I got several Go projects which is documented compatibly with godoc. We use godoc to share doc and code internally as a doc server without significant problem. However we need more control on opening code when we want to share doc with 3rd party. Is there a way to run godoc in a special mode that showing types and docs but never link to or showing source code?
I've tried
godoc -http=0.0.0.0:8090 -links=false -src=false
but not working, still can link to type definition code. Just wondering if missed sth. Go version, 1.3.
The src file only refers to command line mode, not to server mode, so it won't help you. The way I see it there are a few options:
Rewrite godoc for your needs and use your own fork.
Don't use the server mode, render the docs in command line mode and just create a server out of that.
Better yet (I'm not entirely sure 2 will work) - rewrite the templates a bit so the source code won't be linked. But you'll still need to make sure people who enter the path manually won't see the code so it will require fudging the source templates as well. or...
Maybe the simplest thing - run it behind nginx or a similar reverse proxy, and make sure the /src path in the server is closed to outside visitors, or password protected or whatever. That way your internal team can still use it.
Personally I'd go with 4, it's a couple minutes of work and will be the most robust and flexible solution.

Better autocomplete in VIM

All,
I have been working with vim for some time now, and love everything about it - there is only one thing I really miss from IDEs like RubyMine, and that is advanced autocompletion.
For reference, here is my standard VIM setup: https://github.com/wrwright/.vim
I have tried ctags with omnicomplete + supertab, and the one major element I miss is the ability to bring up a context sensitive list of attributes/constants/methods. For example, as I learn RubyMotion, I'd love to have some help remembering iOS SDK constants/attributes/methods, but my VIM autocomplete stops with suggesting class names..or if it does suggest methods/attributes, it lists a ton of methods/attributes that don't even apply to the class I'm working with.
I'd like to (simple example) be able to type UIColor.bl and have it autocomplete with UIColor.blueColor (or suggest if there are multiple options that start with "bl" that are properties of UIColor.
RubyMine does this very well, and if I can get VIM to be similarly smart with autocomplete it would be heavenly (and a great boon while learning RubyMotion/iOS Development.
I have also tried SnipMate (and even a RubyMotion tailored variation at https://github.com/rcyrus/snipmate-snippets-rubymotion), but that doesn't seem to offer the features I'm looking for either.
Relatively satisfied with stock Vim's omnicomplete + vim-ruby and vim-rails having completion abilities on par with NetBeans but with all the bells&whistles of Vim and much lower resource requirements, of course.
From my .vimrc concerning completion options :
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
One thing that I have had a bit of luck with Rubymotion is YouCompleteMe and enabling tag Support. you will need a lot of ram(YCM uses ~2GB when indexing a large tag file) because the tags that rubymotion uses are about 40k tags.
The downside is that the rubymotion people don't seem to want to review pull requests and provide any feedback so I am not sure if they will add the needed things to the rake task that creates the tag files for ycm to work correctly out of the box.
To get it to work you need to set the tags files correct
set tags=./tags;,tags;
and then you need to setup ycm to complete off tags.
let g:ycm_collect_identifiers_from_tags_files = 1
you need to make the ctags file compatible with ycm as well. This pull request does that. You need to add a language field to the ctags creation and then change bridgesupport to ruby.
pull request for that
after that you need to run rake ctags in the root of your project.
If you don't want to modify the project.rb file you could probably create your own rake task that does pretty much the same thing.
Yes, Vim is an awesome... text editor.
As such, it can't be expected to match any IDE's "code awareness". Furthermore, it completely relies on the community for providing more than default support for a given language. If google or the rubymotion site didn't help you to find a serious "autocompletion" solution I doubt you'll find it here.
The process explained in the blog post below sounds ok, if not very precise on the vim configuration front.
http://rayhightower.com/blog/2013/02/12/automatic-ctags-with-rubymotion-and-vim/

How to work GNOME's Looking Glass?

I want to step into extension development for Gnome Shell, but I can't seem to understand how I do a few tasks in Looking Glass lg to actually debug my stuff.
When I type global.log("hi"); into LG, it throws me back r(...) = undefined. Why?
When I want to debug an extensions that doesn't load, how do I do that?
It would be nice to see why an extension can't be loaded.
I tried Main.ExtensionSystem.loadExtension() but it returns undefined no matter if I give it the extension's name string or the extension's object.
Where do I find documentation for classes, objects and member methods?
(The LG inspector does not seem to be able to inspect functions.)
If I had these resources I could at least start to work on updating some extensions for newer Gnome versions. I would not ask these simple questions if they would be nicely explained somewhere but getting all the info seems really tough (I've googled for hours).
1: LookingGlass is basically a GJS console. It allows you to execute and test lines of GJS, grab and manipulate objects and use r(...) to use results in following commands.
The reason you get r(...) = undefined is because log(String); does not return anything, thus the result is undefined.
2: Either log throughout init() and enable(), then check where it breaks and try to pinpoint the breaking line using log or commenting out lines of code (although the culprit is probably defined in the general logging, described in the section at the bottom).
3: There is no official documentation. They have some outdated tutorials for GNOME Shell 3.4 with a small difference explanation to 3.6, a few pages on the C(++) ends of the libraries you use (most of the functions, variables and constants use the same names though), but for any real info you'd need experience, digging through other GNOME and shell extension code or some unofficial sources. Unofficial sources aren't always up to date, however.
Up to date generated docs at RooJS, although at least events are off as they are separated with - (minus) rather than _ (underscore).
Old, but mostly useful documentation, MathematicalCoffee has more useful things, like in depth explained code that is quite a solid learning source.
Generated docs, almost everything is there, very extensive, but sometimes the site drops offline for a few days. You could try to clone the git repo to run it locally, but the readme.md is a verbatim copy of what they forked...
More recent reference made by a user, although this is quite extensive, it's not of much use if you're on an older version of GNOME Shell, as deprecated and old is more likely to work than next gen stuff.
I recommend checking the official extensions website and go through whatever interesting extensions' source code you can get, as that is your best bet to learn anything.
Generally Debugging gnome can be done in several ways.
- use the log() function and follow journalctl in a commandline, check either GNOME or JS, use journalctl -f | grep -i js (or use grep -i gnome). You will see some warnings no matter what, but most mention what extension they're from. This is nice and works on all distros implementing systemd
- Or log a specific process that is a part of GNOME like journalctl /usr/bin/gnome-session -f -o cat, just beware that some distros and versions log to different files and old GNOME versions often log to whatever your display manager logs to.
- use the official (albeit tricky) manner of logging: GNOME on debugging.
I personally couldn't get this to work.

Resources