diff --git a/query.v b/query.v index f1d506b..314af02 100644 --- a/query.v +++ b/query.v @@ -521,7 +521,7 @@ fn (mut ved Ved) git_grep() { } lines := s.output.split_into_lines() ved.gg_lines = [] - for line in lines { + top_loop: for line in lines { if line.contains('thirdparty/') { continue } @@ -531,6 +531,14 @@ fn (mut ved Ved) git_grep() { if line.contains('Binary file ') && line.contains(' matches') { continue } + // Handle grep file extensions to filter (defined in .ved file per workspace) + if ved.grep_file_exts[ved.workspace].len > 0 { + for ext in ved.grep_file_exts[ved.workspace] { + if !line.contains('.${ext}:') { + continue top_loop + } + } + } ved.gg_lines << line } } diff --git a/ved.v b/ved.v index 0453019..c73f21d 100644 --- a/ved.v +++ b/ved.v @@ -9,6 +9,7 @@ import os import time import uiold import clipboard +import json const exe_dir = os.dir(os.executable()) const home_dir = os.home_dir() @@ -80,10 +81,17 @@ mut: autocomplete_cache map[string][]AutocompleteField // autocomplete_cache["v.checker.Checker"] == [{"AnonFn", "void"}, {"cur_anon_fn", "AnonFn"}] debug_info string debugger Debugger - cur_fn_name string // Always displayed on the top bar + cur_fn_name string // Always displayed on the top bar + grep_file_exts map[string][]string // m['workspace_path'] == ['v', 'go'] // debugger_output DebuggerOutput } +// From parsed workspace/path/.ved json file +struct Workspace { + grep_file_extensions []string + // path string +} + // For syntax highlighting enum ChunkKind { a_string = 1 @@ -263,6 +271,7 @@ fn main() { } ved.open_workspace(0) } + ved.grep_file_exts = read_grep_file_exts(ved.workspaces) ved.load_session() ved.load_timer() println('first_launch=${first_launch}') @@ -2244,3 +2253,24 @@ fn (mut ved Ved) update_cur_fn_name() { } } } + +fn read_grep_file_exts(workspaces []string) map[string][]string { + mut res := map[string][]string{} + for w in workspaces { + path := '${w}/.ved' + if !os.exists(path) { + continue + } + f := os.read_file(path) or { + println(err) + continue + } + x := json.decode(Workspace, f) or { + println(err) + continue + } + res[w] = x.grep_file_extensions + println('got ${x.grep_file_extensions} exts for workspace ${w}') + } + return res +}