-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add init support for a user defined PATH/glob cmd #113
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
let s:regexp_keyword_word = 'KEYWORD' | ||
let s:engines = ['rg', 'ag'] | ||
|
||
let s:rg_base_cmd = "rg -n --auto-hybrid-regex --json" | ||
" let s:rg_base_cmd = "rg -n --auto-hybrid-regex --json" | ||
let s:rg_base_cmd = "rg --auto-hybrid-regex --json" | ||
let s:ag_base_cmd = "ag --nogroup --noheading" | ||
|
||
let s:rg_filetype_convertion_map = { | ||
|
@@ -127,7 +128,7 @@ fu! search#GetSearchEngineFileTypeSpecifier(engine, language) abort | |
if a:engine == 'rg' | ||
let file_lists_cmd = 'rg --files | rg ' . s:non_standard_ft_extensions_map_compiled[a:language] | ||
let files = split(system(file_lists_cmd), "\n") | ||
let cmd = join(map(files, {_,fname -> ('-f ' . fname)}), ' ') | ||
let cmd = join(map(files, {_,fname -> ('-f ' . fname)}), ' ') | ||
elseif a:engine == 'ag' | ||
let cmd = '-G ' . s:non_standard_ft_extensions_map_compiled[a:language] | ||
endif | ||
|
@@ -150,7 +151,7 @@ fu! s:GetRgIgnoreSpecifier() abort | |
endif | ||
|
||
for glob in g:any_jump_ignored_files | ||
let result = result . ' -g !' . string(glob) | ||
let result = result . " -g '!" . string(glob) . "'" | ||
endfor | ||
|
||
return result | ||
|
@@ -227,6 +228,7 @@ fu! search#SearchDefinitions(lang, keyword) abort | |
|
||
if search_engine == 'rg' | ||
let grep_results = s:RunRgDefinitionSearch(a:lang, regexp) | ||
" let resp = confirm('results: ' . join(grep_results)) | ||
elseif search_engine == 'ag' | ||
let grep_results = s:RunAgDefinitionSearch(a:lang, regexp) | ||
end | ||
|
@@ -325,9 +327,27 @@ endfu | |
fu! s:RunRgDefinitionSearch(language, patterns) abort | ||
let rg_ft = s:GetRgFiletype(a:language) | ||
|
||
let cmd = s:rg_base_cmd . ' -t ' . rg_ft | ||
" TODO: instead of disabling the .gitignore filtering | ||
" is there some way to just null out any `scan_results` | ||
" patterns which match current `.gitignore` patterns? | ||
let cmd = s:rg_base_cmd . ' -u' . ' -t ' . rg_ft | ||
" let cmd = s:rg_base_cmd . ' -t ' . rg_ft | ||
let cmd = cmd . s:GetRgIgnoreSpecifier() | ||
let cmd = cmd . ' ' . a:patterns | ||
|
||
" NOTE: the `-e` is ok here to be explicit right? | ||
let cmd = cmd . ' -e ' . a:patterns | ||
|
||
let scan_cmd = g:any_jump_glob_scanner | ||
if strlen(scan_cmd) | ||
let scan_results = system(scan_cmd) | ||
" echo 'Additional ' a:language . ' PATHs to scan: ' . scan_results | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was just left in for debugging, obviously can be removed. |
||
let cmd = cmd . ' ' . scan_results | ||
endif | ||
|
||
" TODO: is it more correct to pass `-g <glob>` flags here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would like feedback on whether this (or something else) is a better approach? Also see the TODOs in the description. |
||
" for glob in scan_results | ||
" let cmd = cmd . ' -g ' . string(dir) | ||
" endfor | ||
|
||
let raw_results = system(cmd) | ||
let grep_results = s:ParseRgResults(raw_results) | ||
|
@@ -361,7 +381,7 @@ fu! s:RunRgUsagesSearch(language, keyword) abort | |
\ && type(a:language) == v:t_string | ||
|
||
let rg_ft = s:GetRgFiletype(a:language) | ||
let cmd = cmd . ' -t ' . rg_ft | ||
let cmd = cmd . ' -t ' . rg_ft | ||
endif | ||
|
||
let raw_results = system(cmd) | ||
|
@@ -382,7 +402,7 @@ fu! s:RunAgUsagesSearch(language, keyword) abort | |
let cmd = cmd . ' --' . ag_ft | ||
endif | ||
|
||
let raw_results = system(cmd) | ||
let raw_results = system(cmd) | ||
|
||
let grep_results = s:ParseAgResults(raw_results) | ||
let grep_results = s:FilterGrepResults(a:language, grep_results) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,10 @@ call s:set_plugin_global_option('any_jump_disable_vcs_ignore', v:false) | |
" default is: ['*.tmp', '*.temp'] | ||
call s:set_plugin_global_option('any_jump_ignored_files', ['*.tmp', '*.temp']) | ||
|
||
" Custom glob scanning command used to dynamically | ||
" produce PATHs fed into `rg`/`ag` | ||
call s:set_plugin_global_option('any_jump_glob_scanner', '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sold on this name yet either 😂 suggestions welcome! |
||
|
||
" ---------------------------------------------- | ||
" Public customization methods | ||
" ---------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured it was better then being implicit?