mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:40:05 +08:00
Change: rename tags layer to gtags layer (#3030)
This commit is contained in:
parent
a04f1106b7
commit
1152eaabbd
47
autoload/SpaceVim/layers/gtags.vim
Normal file
47
autoload/SpaceVim/layers/gtags.vim
Normal file
@ -0,0 +1,47 @@
|
||||
"=============================================================================
|
||||
" tags.vim --- SpaceVim gtags layer
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#layers#gtags#plugins() abort
|
||||
return [
|
||||
\ ['SpaceVim/gtags.vim', {'merged' : 0}],
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#gtags#config() abort
|
||||
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)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'p'], 'Gtags -p', 'list all file in GTAGS', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'exe "Gtags -d " . expand("<cword>")', 'find definitions', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'exe "Gtags -r " . expand("<cword>")', 'find references', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 's'], 'exe "Gtags -s " . expand("<cword>")', 'find cursor symbol', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'g'], 'exe "Gtags -g " . expand("<cword>")', 'find cursor string', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Gtags -f %', 'list of objects', 1)
|
||||
augroup spacevim_layer_tags
|
||||
autocmd!
|
||||
autocmd BufEnter *
|
||||
\ if empty(&buftype) && &filetype != 'help'
|
||||
\| nnoremap <silent><buffer> <Leader>] :call MyTagfunc()<CR>
|
||||
\| nnoremap <silent><buffer> <Leader>[ :call MyTagfuncBack()<CR>
|
||||
\| endif
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! MyTagfunc() abort
|
||||
mark H
|
||||
let s:MyTagfunc_flag = 1
|
||||
UniteWithCursorWord -force-immediately tag
|
||||
endfunction
|
||||
|
||||
function! MyTagfuncBack() abort
|
||||
if exists('s:MyTagfunc_flag')&&s:MyTagfunc_flag
|
||||
exe 'normal! `H'
|
||||
let s:MyTagfunc_flag =0
|
||||
endif
|
||||
endfunction
|
||||
|
@ -1,54 +0,0 @@
|
||||
"=============================================================================
|
||||
" tags.vim --- SpaceVim tags layer
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#layers#tags#plugins() abort
|
||||
return [
|
||||
\ ['SpaceVim/gtags.vim', {'merged' : 0}],
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#tags#config() abort
|
||||
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)
|
||||
" if SpaceVim#layers#isLoaded('denite')
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Denite gtags_path', 'list all file in GTAGS', 1)
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'DeniteCursorWord gtags_def', 'find definitions', 1)
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'DeniteCursorWord gtags_ref', 'find references', 1)
|
||||
" elseif SpaceVim#layers#isLoaded('unite')
|
||||
" 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)
|
||||
" else
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Gtags -p', 'list all file in GTAGS', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'exe "Gtags -d " . expand("<cword>")', 'find definitions', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'exe "Gtags -r " . expand("<cword>")', 'find references', 1)
|
||||
" endif
|
||||
augroup spacevim_layer_tags
|
||||
autocmd!
|
||||
autocmd BufEnter *
|
||||
\ if empty(&buftype) && &filetype != 'help'
|
||||
\| nnoremap <silent><buffer> <Leader>] :call MyTagfunc()<CR>
|
||||
\| nnoremap <silent><buffer> <Leader>[ :call MyTagfuncBack()<CR>
|
||||
\| endif
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! MyTagfunc() abort
|
||||
mark H
|
||||
let s:MyTagfunc_flag = 1
|
||||
UniteWithCursorWord -force-immediately tag
|
||||
endfunction
|
||||
|
||||
function! MyTagfuncBack() abort
|
||||
if exists('s:MyTagfunc_flag')&&s:MyTagfunc_flag
|
||||
exe 'normal! `H'
|
||||
let s:MyTagfunc_flag =0
|
||||
endif
|
||||
endfunction
|
||||
|
@ -12,12 +12,9 @@ lang: cn
|
||||
- [模块简介](#模块简介)
|
||||
- [功能特性](#功能特性)
|
||||
- [安装及启用模块](#安装及启用模块)
|
||||
- [GNU Global (gtags)](#gnu-global-gtags)
|
||||
- [从源码编译安装](#从源码编译安装)
|
||||
- [安装依赖环境](#安装依赖环境)
|
||||
- [编译安装](#编译安装)
|
||||
- [配置 pygments 和 ctags 环境](#配置-pygments-和-ctags-环境)
|
||||
- [GNU Global](#gnu-global)
|
||||
- [启用模块](#启用模块)
|
||||
- [模块设置](#模块设置)
|
||||
- [使用模块](#使用模块)
|
||||
- [语言支持](#语言支持)
|
||||
- [内置的语言支持](#内置的语言支持)
|
||||
@ -44,7 +41,7 @@ tags 模块提供了项目 tags 管理工具,依赖 SpaceVim 自身的项目
|
||||
|
||||
## 安装及启用模块
|
||||
|
||||
### GNU Global (gtags)
|
||||
### GNU Global
|
||||
|
||||
首先需要安装 [GNU Global](https://www.gnu.org/software/global/download.html),可根据当前使用的操作系统,
|
||||
使用自带的软件包管理工具安装。
|
||||
@ -59,10 +56,6 @@ sudo apt-get install global
|
||||
brew install global --with-pygments --with-ctags
|
||||
```
|
||||
|
||||
#### 从源码编译安装
|
||||
|
||||
##### 安装依赖环境
|
||||
|
||||
如果需要启用 global 的所有特性,你需要安装 2 个额外的软件包:pygments 和 ctags。
|
||||
这两个可以使用系统自带的包管理器安装:
|
||||
|
||||
@ -78,7 +71,7 @@ sudo apt-get install exuberant-ctags python-pygments
|
||||
sudo pacman -S ctags python-pygments
|
||||
```
|
||||
|
||||
##### 编译安装
|
||||
**编译安装**
|
||||
|
||||
下载最新的 tar.gz 文件,执行如下命令:
|
||||
|
||||
@ -90,8 +83,6 @@ make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
##### 配置 pygments 和 ctags 环境
|
||||
|
||||
To be able to use pygments and ctags, you need to copy the sample gtags.conf either to /etc/gtags.conf or
|
||||
如果需要启用 pygments 和 ctags,需要复制示例 gtags.conf 至 `/etc/gtags.conf` 或者 `$HOME/.globalrc`。例如:
|
||||
|
||||
@ -114,24 +105,27 @@ echo export GTAGSLABEL=pygments >> .profile
|
||||
name = "tags"
|
||||
```
|
||||
|
||||
## 模块设置
|
||||
|
||||
|
||||
gtags 模块提供了以下模块选项:
|
||||
|
||||
- `gtagslabel`: 设置 gtags 命令所使用的后台工具,可以选择 `ctags` 或者 `pygments`,默认是空。
|
||||
|
||||
例如,使用 pygments 作为后台:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "gtags"
|
||||
gtagslabel = "pygments"
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 使用模块
|
||||
|
||||
在使用 gtags 之前,建议先新建 GTAGS 数据库,可通过如下两种方式新建数据库:
|
||||
|
||||
- 在 SpaceVim 内,使用快捷键 `SPC m g c` 来新建 GTAGS 数据库,
|
||||
如果 GUN Global 不能直接支持当前语言,可以选择 ctags 或者 pygments 作为生成数据库的后台工具。
|
||||
- 在命令行,可以直接在项目根目录执行 gtags 命令。
|
||||
|
||||
```sh
|
||||
cd /path/to/project/root
|
||||
gtags
|
||||
```
|
||||
|
||||
对于 gtags 不直接支持的语言,并且未 GTAGSLABEL 环境变量,此时可以使用如下命令以达到同样效果:
|
||||
|
||||
```sh
|
||||
gtags --gtagslabel=pygments
|
||||
```
|
||||
在使用 gtags 之前,建议先使用快捷键 `SPC m g c` 新建 GTAGS 数据库,
|
||||
这一数据库也会在保存文件时自动更新。
|
||||
|
||||
### 语言支持
|
||||
|
||||
|
@ -4,26 +4,22 @@ description: "This layer provide gtags manager for project"
|
||||
redirect_from: "/layers/tags/"
|
||||
---
|
||||
|
||||
# [Available Layers](../) >> tags
|
||||
# [Available Layers](../) >> gtags
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [Description](#description)
|
||||
- [Features](#features)
|
||||
- [Install](#install)
|
||||
- [Installation](#installation)
|
||||
- [GNU Global](#gnu-global)
|
||||
- [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)
|
||||
- [Layers](#layers)
|
||||
- [Configuration](#configuration)
|
||||
- [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)
|
||||
- [Pygments languages](#pygments-languages)
|
||||
- [Key bindings](#key-bindings)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
@ -34,48 +30,46 @@ This layer provide tags manager for project. This layer need `core` layer's proj
|
||||
|
||||
## 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.
|
||||
- Select any tag in a project retrieved by gtags
|
||||
- Resume previous 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/Automatically update tag database
|
||||
- Jump to next location in context stack
|
||||
- Jump to previous location in context stack
|
||||
- Jump to a file in tag database
|
||||
|
||||
## Install
|
||||
## Installation
|
||||
|
||||
### GNU Global
|
||||
|
||||
To use gtags, you first have to install [GNU Global](https://www.gnu.org/software/global/download.html).
|
||||
To use gtags layer, 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:
|
||||
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
|
||||
Install on OSX using Homebrew:
|
||||
|
||||
```sh
|
||||
brew install global --with-pygments --with-ctags
|
||||
```
|
||||
|
||||
#### Install on \*nix from source
|
||||
**Build 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
|
||||
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
|
||||
@ -87,8 +81,6 @@ or e.g., Archlinux:
|
||||
sudo pacman -S ctags python-pygments
|
||||
```
|
||||
|
||||
##### Install with recommended features
|
||||
|
||||
Download the latest tar.gz archive, then run these commands:
|
||||
|
||||
```sh
|
||||
@ -99,9 +91,10 @@ make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
##### Configure your environment to use pygments and ctags
|
||||
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:
|
||||
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
|
||||
@ -113,32 +106,34 @@ Additionally you should define GTAGSLABEL in your shell startup file e.g. with s
|
||||
echo export GTAGSLABEL=pygments >> .profile
|
||||
```
|
||||
|
||||
### Load tags layer
|
||||
### Layers
|
||||
|
||||
To use this configuration layer, update custom configuration file with:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "tags"
|
||||
name = "gtags"
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
gtags layer provides following options:
|
||||
|
||||
- `gtagslabel`: the backend of gtags command, you can use `ctags` or `pygments`. It is empty string by default.
|
||||
|
||||
for example, to use pygments as backend:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "gtags"
|
||||
gtagslabel = "pygments"
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
```
|
||||
Before using the gtags, remember to create a GTAGS database by `SPC m g c`.
|
||||
The database will also be updated automatically when saving files.
|
||||
|
||||
### Language Support
|
||||
|
||||
@ -146,52 +141,57 @@ gtags --gtagslabel=pygments
|
||||
|
||||
If you do not have `ctags` or `pygments` enabled gtags will only produce tags for the following languages:
|
||||
|
||||
- asm
|
||||
- c/c++
|
||||
- java
|
||||
- php
|
||||
- yacc
|
||||
- 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:
|
||||
If you have enabled `exuberant ctags` and use that as the backend
|
||||
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)
|
||||
- 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:
|
||||
Instead, If you have installed the newer/beta [universal ctags](https://github.com/universal-ctags/ctags)
|
||||
and use that as the backend the following additional languages will have tags created for them:
|
||||
|
||||
- clojure
|
||||
- d
|
||||
- go
|
||||
- rust
|
||||
- clojure
|
||||
- d
|
||||
- go
|
||||
- rust
|
||||
|
||||
#### Pygments languages (plus symbol and reference tags)
|
||||
#### Pygments languages
|
||||
|
||||
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”.
|
||||
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:
|
||||
If you enabled pygments (the best choice) and use that as the backend
|
||||
the following additional languages will have tags created for them:
|
||||
|
||||
- elixir
|
||||
- fsharp
|
||||
- haskell
|
||||
- octave
|
||||
- racket
|
||||
- scala
|
||||
- shell-scripts
|
||||
- tex
|
||||
- elixir
|
||||
- fsharp
|
||||
- haskell
|
||||
- octave
|
||||
- racket
|
||||
- scala
|
||||
- shell-scripts
|
||||
- tex
|
||||
|
||||
## Key bindings
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user