Skip to content

Commit

Permalink
grep_file_extensions for each workspace (parsed from workspace/.ved)
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Dec 22, 2024
1 parent 1e79dc7 commit 096a5da
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
10 changes: 9 additions & 1 deletion query.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
}
Expand Down
32 changes: 31 additions & 1 deletion ved.v
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}')
Expand Down Expand Up @@ -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
}

0 comments on commit 096a5da

Please sign in to comment.