From dd6440a73b45410e7c22410a6694adc114e1c3c8 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 2 Aug 2017 05:39:35 +0800 Subject: [PATCH 1/6] Update git ignore --- .gitignore | 20 +++++- autoload/SpaceVim/layers/tags.vim | 0 docs/layers/tags.md | 109 ++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 autoload/SpaceVim/layers/tags.vim create mode 100644 docs/layers/tags.md diff --git a/.gitignore b/.gitignore index 05ea2578b..759a81299 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -tags doc/tags *.class .floo @@ -6,7 +5,22 @@ doc/tags *.netrwhist *-rplugin~ *rplugin.vim -/config/local.vim -.SpaceVim.logA +.SpaceVim.log docs/_site/* docs/Gemfile.lock +# Ignore tags created by etags, ctags, gtags (GNU global) and cscope +TAGS +.TAGS +!TAGS/ +tags +.tags +!tags/ +gtags.files +GTAGS +GRTAGS +GPATH +GSYMS +cscope.files +cscope.out +cscope.in.out +cscope.po.out diff --git a/autoload/SpaceVim/layers/tags.vim b/autoload/SpaceVim/layers/tags.vim new file mode 100644 index 000000000..e69de29bb diff --git a/docs/layers/tags.md b/docs/layers/tags.md new file mode 100644 index 000000000..0b2a302ec --- /dev/null +++ b/docs/layers/tags.md @@ -0,0 +1,109 @@ +--- +title: "SpaceVim tags layer" +--- + +# [SpaceVim Layers:](https://spacevim.org/layers) tags + + +* [Description](#description) +* [Features](#features) +* [Install](#install) + * [GNU Global (gtags)](#gnu-global-gtags) + * [Install on OSX using Homebrew](#install-on-osx-using-homebrew) + * [Install on \*nix from source](#install-on-nix-from-source) + * [Install recommended dependencies](#install-recommended-dependencies) + * [Install with recommended features](#install-with-recommended-features) + * [Configure your environment to use pygments and ctags](#configure-your-environment-to-use-pygments-and-ctags) + * [Load tags layer](#load-tags-layer) + + + +## Description + +This layer provide tags manager for project. This layer need `core` layer's project manager feature. + +## Features + +- Select any tag in a project retrieved by gtags +- Resume previous helm-gtags session +- Jump to a location based on context +- Find definitions +- Find references +- Present tags in current function only +- Create a tag database +- Jump to definitions in file +- Show stack of visited locations +- Manually update tag database +- Jump to next location in context stack +- Jump to previous location in context stack +- Jump to a file in tag database +- Enables eldoc in modes that otherwise might not support it. +- Enables company complete in modes that otherwise might not support it. + +## Install + +### GNU Global (gtags) + +To use gtags, you first have to install [GNU Global](https://www.gnu.org/software/global/download.html). + +You can install global from the software repository of your OS; however, many OS distributions are out of date, and you will probably be missing support for pygments and exuberant ctags, and thus support for many languages. We recommend installing from source. If not for example to install on Ubuntu: + +```sh +sudo apt-get install global +``` + +#### Install on OSX using Homebrew + +```sh +brew install global --with-pygments --with-ctags +``` + +#### Install on \*nix from source + +##### Install recommended dependencies + +To take full advantage of global you should install 2 extra packages in addition to global: pygments and ctags (exuberant). You can do this using your normal OS package manager, e.g., on Ubuntu + +```sh +sudo apt-get install exuberant-ctags python-pygments +``` + +or e.g., Archlinux: + +```sh +sudo pacman -S ctags python-pygments +``` + +##### Install with recommended features + +Download the latest tar.gz archive, then run these commands: + +```sh +tar xvf global-6.5.3.tar.gz +cd global-6.5.3 +./configure --with-exuberant-ctags=/usr/bin/ctags +make +sudo make install +``` + +##### Configure your environment to use pygments and ctags + +To be able to use pygments and ctags, you need to copy the sample gtags.conf either to /etc/gtags.conf or $HOME/.globalrc. For example: + +```sh +cp gtags.conf ~/.globalrc +``` + +Additionally you should define GTAGSLABEL in your shell startup file e.g. with sh/ksh: + +```sh +echo export GTAGSLABEL=pygments >> .profile +``` + +### Load tags layer + +To use this configuration layer, add it to your `~/.SpaceVim.d/init.vim`. + +```vim +call SpaceVim#layers#load('tags') +``` From 0a8ac78a276f57e46a215a885edc827fc66fa1c3 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 2 Aug 2017 06:04:56 +0800 Subject: [PATCH 2/6] Add doc --- docs/layers/index.md | 9 ++-- docs/layers/tags.md | 97 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 4 deletions(-) diff --git a/docs/layers/index.md b/docs/layers/index.md index 6f1c3e5b6..fe64d1eac 100644 --- a/docs/layers/index.md +++ b/docs/layers/index.md @@ -2,14 +2,15 @@ | Name | Description | Documentation | | ------------- | :-------------------------------: | ---------------------------------------------------------- | -| default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default) | -| shell | shell support for SpaceVim | [documentation](https://spacevim.org/layers/shell) | -| checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers) | | autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete) | +| chat | chatting in vim | [documentation](https://spacevim.org/layers/chat) | +| checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers) | | chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese) | | colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme) | -| chat | chatting in vim | [documentation](https://spacevim.org/layers/chat) | +| default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default) | | lang#java | java development in vim | [documentation](https://spacevim.org/layers/lang/java) | | lang#lisp | lisp development in vim | [documentation](https://spacevim.org/layers/lang/lisp) | | lang#markdown | layer for editing markdown in vim | [documentation](https://spacevim.org/layers/lang/markdown) | | lang#php | php development in vim | [documentation](https://spacevim.org/layers/lang/php) | +| shell | shell support for SpaceVim | [documentation](https://spacevim.org/layers/shell) | +| tags | tags manager in vim | [documentation](https://spacevim.org/layers/tags) | diff --git a/docs/layers/tags.md b/docs/layers/tags.md index 0b2a302ec..66177cef7 100644 --- a/docs/layers/tags.md +++ b/docs/layers/tags.md @@ -15,6 +15,13 @@ title: "SpaceVim tags layer" * [Install with recommended features](#install-with-recommended-features) * [Configure your environment to use pygments and ctags](#configure-your-environment-to-use-pygments-and-ctags) * [Load tags layer](#load-tags-layer) +* [Usage](#usage) + * [Language Support](#language-support) + * [Built-in languages](#built-in-languages) + * [Exuberant ctags languages](#exuberant-ctags-languages) + * [Universal ctags languages](#universal-ctags-languages) + * [Pygments languages (plus symbol and reference tags)](#pygments-languages-plus-symbol-and-reference-tags) +* [Key bindings](#key-bindings) @@ -107,3 +114,93 @@ To use this configuration layer, add it to your `~/.SpaceVim.d/init.vim`. ```vim call SpaceVim#layers#load('tags') ``` + +## Usage + +Before using the gtags, remember to create a GTAGS database by the following methods: + +- From within SpaceVim, press `SPC m g c` to generate GTAGS database. If the language is not directly supported by GNU Global, you can choose ctags or pygments as a backend to generate tag database. +- From inside terminal, runs gtags at your project root in terminal: + +```sh +cd /path/to/project/root +gtags +``` + +If the language is not directly supported by gtags, and you have not set the GTAGSLABEL environment variable, use this command instead: + +```sh +gtags --gtagslabel=pygments +``` + +### Language Support + +#### Built-in languages + +If you do not have `ctags` or `pygments` enabled gtags will only produce tags for the following languages: + +- asm +- c/c++ +- java +- php +- yacc + +#### Exuberant ctags languages + +If you have enabled `exuberant ctags` and use that as the backend (i.e., GTAGSLABEL=ctags or –gtagslabel=ctags) the following additional languages will have tags created for them: + +- c# +- erlang +- javascript +- common-lisp +- emacs-lisp +- lua +- ocaml +- python +- ruby +- scheme +- vimscript +- windows-scripts (.bat .cmd files) + +#### Universal ctags languages + +Instead, If you have installed the newer/beta [universal ctags](https://github.com/universal-ctags/ctags) and use that as the backend (i.e., GTAGSLABEL=ctags or –gtagslabel=ctags) the following additional languages will have tags created for them: + +- clojure +- d +- go +- rust + +#### Pygments languages (plus symbol and reference tags) + +In order to look up symbol references for any language not in the built in parser you must use the pygments backend. When this backend is used global actually uses both ctags and pygments to find the definitions and uses of functions and variables as well as “other symbols”. + +If you enabled pygments (the best choice) and use that as the backend (i.e., GTAGSLABEL=pygments or –gtagslabel=pygments) the following additional languages will have tags created for them: + +- elixir +- fsharp +- haskell +- octave +- racket +- scala +- shell-scripts +- tex + +## Key bindings + +| Key Binding | Description | +| ----------- | --------------------------------------------------------- | +| `SPC m g c` | create a tag database | +| `SPC m g f` | jump to a file in tag database | +| `SPC m g g` | jump to a location based on context | +| `SPC m g G` | jump to a location based on context (open another window) | +| `SPC m g d` | find definitions | +| `SPC m g i` | present tags in current function only | +| `SPC m g l` | jump to definitions in file | +| `SPC m g n` | jump to next location in context stack | +| `SPC m g p` | jump to previous location in context stack | +| `SPC m g r` | find references | +| `SPC m g R` | resume previous helm-gtags session | +| `SPC m g s` | select any tag in a project retrieved by gtags | +| `SPC m g S` | show stack of visited locations | +| `SPC m g u` | manually update tag database | From a3c5eb2e2f024bebf4419b1263fe0a2a11ecc87e Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 4 Aug 2017 04:23:24 +0800 Subject: [PATCH 3/6] Fix errors --- autoload/SpaceVim/layers/tags.vim | 9 +++++++++ config/plugins/ctrlp.vim | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/tags.vim b/autoload/SpaceVim/layers/tags.vim index e69de29bb..1a7a1d0d8 100644 --- a/autoload/SpaceVim/layers/tags.vim +++ b/autoload/SpaceVim/layers/tags.vim @@ -0,0 +1,9 @@ +function! SpaceVim#layers#tags#plugins() + return [['ludovicchabant/vim-gutentags', {'merged' : 0}]] +endfunction + +function! SpaceVim#layers#tags#config() + + + +endfunction diff --git a/config/plugins/ctrlp.vim b/config/plugins/ctrlp.vim index 82f8ea656..e8169aafd 100644 --- a/config/plugins/ctrlp.vim +++ b/config/plugins/ctrlp.vim @@ -1,7 +1,7 @@ let g:ctrlp_map = get(g:,'ctrlp_map', '') let g:ctrlp_cmd = get(g:, 'ctrlp_cmd', 'CtrlP') let g:ctrlp_working_path_mode = get(g:, 'ctrlp_working_path_mode', 'ra') -let g:ctrlp_root_markers = get(g:, 'ctrlp_root_markers', 'pom.xml') +let g:ctrlp_root_markers = get(g:, 'ctrlp_root_markers', ['pom.xml']) let g:ctrlp_match_window = get(g:, 'ctrlp_match_window', 'bottom,order:btt,min:1,max:15,results:15') let g:ctrlp_show_hidden = get(g:, 'ctrlp_show_hidden', 1) "for caching From 29d7d9052f77725c462ac932fa932f334cdf9f24 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 4 Aug 2017 05:01:13 +0800 Subject: [PATCH 4/6] Add gtags.vim --- autoload/SpaceVim/layers/tags.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/tags.vim b/autoload/SpaceVim/layers/tags.vim index 1a7a1d0d8..ad8ac75d6 100644 --- a/autoload/SpaceVim/layers/tags.vim +++ b/autoload/SpaceVim/layers/tags.vim @@ -1,5 +1,8 @@ function! SpaceVim#layers#tags#plugins() - return [['ludovicchabant/vim-gutentags', {'merged' : 0}]] + return [ + \ ['ludovicchabant/vim-gutentags', {'merged' : 0}], + \ ['SpaceVim/gtags.vim', {'merged' : 0}], + \ ] endfunction function! SpaceVim#layers#tags#config() From 46b0b0b361db6fa27214b787d7ab06d81ccb0f9e Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 5 Aug 2017 17:48:45 +0800 Subject: [PATCH 5/6] Add TODO --- autoload/SpaceVim/layers/tags.vim | 16 +++++++++++++++- autoload/SpaceVim/mapping/space.vim | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/tags.vim b/autoload/SpaceVim/layers/tags.vim index ad8ac75d6..288c77580 100644 --- a/autoload/SpaceVim/layers/tags.vim +++ b/autoload/SpaceVim/layers/tags.vim @@ -6,7 +6,21 @@ function! SpaceVim#layers#tags#plugins() endfunction function! SpaceVim#layers#tags#config() + let g:_spacevim_mappings_space.m.g = {'name' : '+gtags'} + call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'c'], 'GtagsGenerate!', 'create a gtags database', 1) + call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'u'], 'GtagsGenerate', 'update tag database', 1) +" | `SPC m g f` | jump to a file in tag database | +" | `SPC m g g` | jump to a location based on context | +" | `SPC m g G` | jump to a location based on context (open another window) | +" | `SPC m g d` | find definitions | +" | `SPC m g i` | present tags in current function only | +" | `SPC m g l` | jump to definitions in file | +" | `SPC m g n` | jump to next location in context stack | +" | `SPC m g p` | jump to previous location in context stack | +" | `SPC m g r` | find references | +" | `SPC m g R` | resume previous helm-gtags session | +" | `SPC m g s` | select any tag in a project retrieved by gtags | +" | `SPC m g S` | show stack of visited locations | - endfunction diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 8473c555e..d45665316 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -18,6 +18,7 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.c = {'name' : '+Comments'} let g:_spacevim_mappings_space.f = {'name' : '+Files'} let g:_spacevim_mappings_space.j = {'name' : '+Jump/Join/Split'} + let g:_spacevim_mappings_space.m = {'name' : '+Major-mode'} let g:_spacevim_mappings_space.w = {'name' : '+Windows'} let g:_spacevim_mappings_space.p = {'name' : '+Projects'} let g:_spacevim_mappings_space.h = {'name' : '+Help'} From 2431cd6d50056caf80c8a208c0042ea6f41bf340 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 6 Aug 2017 00:01:32 +0800 Subject: [PATCH 6/6] Update mappings --- autoload/SpaceVim/layers/tags.vim | 17 +++-------------- docs/layers/tags.md | 15 +++------------ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/autoload/SpaceVim/layers/tags.vim b/autoload/SpaceVim/layers/tags.vim index 288c77580..c79a7cb82 100644 --- a/autoload/SpaceVim/layers/tags.vim +++ b/autoload/SpaceVim/layers/tags.vim @@ -9,18 +9,7 @@ function! SpaceVim#layers#tags#config() let g:_spacevim_mappings_space.m.g = {'name' : '+gtags'} call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'c'], 'GtagsGenerate!', 'create a gtags database', 1) call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'u'], 'GtagsGenerate', 'update tag database', 1) -" | `SPC m g f` | jump to a file in tag database | -" | `SPC m g g` | jump to a location based on context | -" | `SPC m g G` | jump to a location based on context (open another window) | -" | `SPC m g d` | find definitions | -" | `SPC m g i` | present tags in current function only | -" | `SPC m g l` | jump to definitions in file | -" | `SPC m g n` | jump to next location in context stack | -" | `SPC m g p` | jump to previous location in context stack | -" | `SPC m g r` | find references | -" | `SPC m g R` | resume previous helm-gtags session | -" | `SPC m g s` | select any tag in a project retrieved by gtags | -" | `SPC m g S` | show stack of visited locations | - - + call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Unite gtags/path', 'list all file in GTAGS', 1) + call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'Unite gtags/def', 'find definitions', 1) + call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'Unite gtags/ref', 'find references', 1) endfunction diff --git a/docs/layers/tags.md b/docs/layers/tags.md index 66177cef7..18645f3e8 100644 --- a/docs/layers/tags.md +++ b/docs/layers/tags.md @@ -191,16 +191,7 @@ If you enabled pygments (the best choice) and use that as the backend (i.e., GTA | Key Binding | Description | | ----------- | --------------------------------------------------------- | | `SPC m g c` | create a tag database | -| `SPC m g f` | jump to a file in tag database | -| `SPC m g g` | jump to a location based on context | -| `SPC m g G` | jump to a location based on context (open another window) | -| `SPC m g d` | find definitions | -| `SPC m g i` | present tags in current function only | -| `SPC m g l` | jump to definitions in file | -| `SPC m g n` | jump to next location in context stack | -| `SPC m g p` | jump to previous location in context stack | -| `SPC m g r` | find references | -| `SPC m g R` | resume previous helm-gtags session | -| `SPC m g s` | select any tag in a project retrieved by gtags | -| `SPC m g S` | show stack of visited locations | | `SPC m g u` | manually update tag database | +| `SPC m g f` | jump to a file in tag database | +| `SPC m g d` | find definitions | +| `SPC m g r` | find references |