From 7f2dd0642d7222304385f62e77532ae314f27bb6 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 7 Jun 2022 01:03:15 +0800 Subject: [PATCH] feat(cscope): add `list_files_command` layer option --- autoload/SpaceVim/layers/cscope.vim | 15 +++++++++++++++ bundle/cscope.vim/autoload/cscope.vim | 8 +++++++- doc/SpaceVim.txt | 11 +++++++++++ docs/cn/layers/cscope.md | 10 ++++++++++ docs/layers/cscope.md | 12 +++++++++++- 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim/layers/cscope.vim b/autoload/SpaceVim/layers/cscope.vim index b37fe4f0a..ec0610afd 100644 --- a/autoload/SpaceVim/layers/cscope.vim +++ b/autoload/SpaceVim/layers/cscope.vim @@ -29,6 +29,17 @@ scriptencoding utf-8 " 2. `cscope_command`: set the command or path of `cscope` executable. " 3. `open_location`: enable/disable open location list after searching. " 4. `preload_path`: set the proload paths. +" 5. `list_files_command`: set the command to list all files which should +" be involed to create cscope database, By default it is: +" +" `['rg', '--color=never', '--files']` +" +" To specific filetypes, use custom command, for example: +" > +" [[layers]] +" name = 'cscope' +" list_files_command = ['rg', '--color=never', '--files', '--type', 'c'] +" < " " @subsection key bindings " @@ -57,6 +68,7 @@ endif let s:cscope_command = 'cscope' let s:auto_update = 1 +let s:list_files_command = ['rg', '--color=never', '--files'] function! SpaceVim#layers#cscope#plugins() abort let plugins = [ @@ -109,6 +121,9 @@ function! SpaceVim#layers#cscope#set_variable(var) abort let g:cscope_preload_path = get(a:var, \ 'preload_path', \ '') + let g:cscope_list_files_command = get(a:ver, + \ 'list_files_command', + \ s:list_files_command) endfunction diff --git a/bundle/cscope.vim/autoload/cscope.vim b/bundle/cscope.vim/autoload/cscope.vim index 91c69c23a..a29b323b4 100644 --- a/bundle/cscope.vim/autoload/cscope.vim +++ b/bundle/cscope.vim/autoload/cscope.vim @@ -149,7 +149,13 @@ function! s:list_files_exit(id, date, event) abort endfunction function! s:list_project_files(dir, cscope_files, cscope_db, load) abort - let jobid = s:JOB.start(['rg', '--color=never', '--files', a:dir], { + if exists('g:cscope_list_files_command') + \ && type(g:cscope_list_files_command) ==# type([]) + let list_files_command = g:cscope_list_files_command + [a:dir] + else + let list_files_command = ['rg', '--color=never', '--files', a:dir] + endif + let jobid = s:JOB.start(list_files_command, { \ 'on_stdout' : function('s:list_files_stdout'), \ 'on_exit' : function('s:list_files_exit') \ }) diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 6a1018b5b..50c3a039b 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -1863,6 +1863,17 @@ The layer option can be used when loading the `cscope` layer, for example: 2. `cscope_command`: set the command or path of `cscope` executable. 3. `open_location`: enable/disable open location list after searching. 4. `preload_path`: set the proload paths. + 5. `list_files_command`: set the command to list all files which should be + involed to create cscope database, By default it is: + + `['rg', '--color=never', '--files']` + + To specific filetypes, use custom command, for example: +> + [[layers]] + name = 'cscope' + list_files_command = ['rg', '--color=never', '--files', '--type', 'c'] +< KEY BINDINGS diff --git a/docs/cn/layers/cscope.md b/docs/cn/layers/cscope.md index fa59e0091..918b44ba3 100644 --- a/docs/cn/layers/cscope.md +++ b/docs/cn/layers/cscope.md @@ -54,6 +54,16 @@ scoop install cscope - `auto_update`: 启用/禁用数据库自动更新,若启用,则在保存文件时自动更新数据库。 - `open_location`: 启用/禁用自动打开搜索结果列表。 - `preload_path`: 设置预加载的数据量路径。 +- `list_files_command`: 设置列出项目内需要生成cscope数据库的所有文件的命令,默认是: + ``` + ['rg', '--color=never', '--files'] + ``` + 如果需要指定哪些文件需要生成数据库,可以参考如下设置: + ``` + [[layers]] + name = 'cscope' + list_files_command = ['rg', '--color=never', '--files', '--type', 'c'] + ``` ## 快捷键 diff --git a/docs/layers/cscope.md b/docs/layers/cscope.md index c34357676..58a03d553 100644 --- a/docs/layers/cscope.md +++ b/docs/layers/cscope.md @@ -51,7 +51,17 @@ To use this configuration layer, add it to your configuration file. - `auto_update`: enable/disable auto udpate when saving files. - `open_location`: enable/disable open location list after searching. - `preload_path`: set the proload paths. - +- `list_files_command`: set the command to list all files which should be + involed to create cscope database, By default it is: + ``` + ['rg', '--color=never', '--files'] + ``` + To specific filetypes, use custom command, for example: + ``` + [[layers]] + name = 'cscope' + list_files_command = ['rg', '--color=never', '--files', '--type', 'c'] + ``` ## Key bindings