@@ -66,7 +66,8 @@ pub fn load_workspace(
6666 main_path : PathBuf ,
6767 mut workspace_folders : Vec < PathBuf > ,
6868 config_paths : Option < Vec < PathBuf > > ,
69- ignore : Option < Vec < String > > ,
69+ exclude_pattern : Option < Vec < String > > ,
70+ include_pattern : Option < Vec < String > > ,
7071) -> Option < EmmyLuaAnalysis > {
7172 let ( config_files, config_root) : ( Vec < PathBuf > , PathBuf ) =
7273 if let Some ( config_paths) = config_paths {
@@ -111,7 +112,12 @@ pub fn load_workspace(
111112 analysis. update_config ( Arc :: new ( emmyrc) ) ;
112113 analysis. init_std_lib ( None ) ;
113114
114- let file_infos = collect_files ( & workspace_folders, & analysis. emmyrc , ignore) ;
115+ let file_infos = collect_files (
116+ & workspace_folders,
117+ & analysis. emmyrc ,
118+ exclude_pattern,
119+ include_pattern,
120+ ) ;
115121 let files = file_infos
116122 . into_iter ( )
117123 . filter_map ( |file| {
@@ -140,10 +146,12 @@ pub fn load_workspace(
140146pub fn collect_files (
141147 workspaces : & Vec < PathBuf > ,
142148 emmyrc : & Emmyrc ,
143- ignore : Option < Vec < String > > ,
149+ exclude_pattern : Option < Vec < String > > ,
150+ include_pattern : Option < Vec < String > > ,
144151) -> Vec < LuaFileInfo > {
145152 let mut files = Vec :: new ( ) ;
146- let ( match_pattern, exclude, exclude_dir) = calculate_include_and_exclude ( emmyrc, ignore) ;
153+ let ( match_pattern, exclude, exclude_dir) =
154+ calculate_include_and_exclude ( emmyrc, exclude_pattern, include_pattern) ;
147155
148156 let encoding = & emmyrc. workspace . encoding ;
149157
@@ -167,21 +175,32 @@ pub fn collect_files(
167175/// File patterns for workspace scanning: (include_patterns, exclude_patterns, exclude_dirs)
168176type FilePatterns = ( Vec < String > , Vec < String > , Vec < PathBuf > ) ;
169177
170- pub fn calculate_include_and_exclude ( emmyrc : & Emmyrc , ignore : Option < Vec < String > > ) -> FilePatterns {
171- let mut include = vec ! [ "**/*.lua" . to_string( ) , "**/.editorconfig" . to_string( ) ] ;
178+ pub fn calculate_include_and_exclude (
179+ emmyrc : & Emmyrc ,
180+ exclude_pattern : Option < Vec < String > > ,
181+ include_pattern : Option < Vec < String > > ,
182+ ) -> FilePatterns {
183+ let mut include = Vec :: new ( ) ;
172184 let mut exclude = Vec :: new ( ) ;
173185 let mut exclude_dirs = Vec :: new ( ) ;
174186
175- for extension in & emmyrc. runtime . extensions {
176- if extension. starts_with ( "." ) {
177- log:: info!( "Adding extension: **/*{}" , extension) ;
178- include. push ( format ! ( "**/*{}" , extension) ) ;
179- } else if extension. starts_with ( "*." ) {
180- log:: info!( "Adding extension: **/{}" , extension) ;
181- include. push ( format ! ( "**/{}" , extension) ) ;
182- } else {
183- log:: info!( "Adding extension: {}" , extension) ;
184- include. push ( extension. clone ( ) ) ;
187+ if let Some ( p) = include_pattern {
188+ include. extend ( p) ;
189+ } else {
190+ include. push ( "**/*.lua" . to_string ( ) ) ;
191+ include. push ( "**/.editorconfig" . to_string ( ) ) ;
192+
193+ for extension in & emmyrc. runtime . extensions {
194+ if extension. starts_with ( "." ) {
195+ log:: info!( "Adding extension: **/*{}" , extension) ;
196+ include. push ( format ! ( "**/*{}" , extension) ) ;
197+ } else if extension. starts_with ( "*." ) {
198+ log:: info!( "Adding extension: **/{}" , extension) ;
199+ include. push ( format ! ( "**/{}" , extension) ) ;
200+ } else {
201+ log:: info!( "Adding extension: {}" , extension) ;
202+ include. push ( extension. clone ( ) ) ;
203+ }
185204 }
186205 }
187206
@@ -190,9 +209,9 @@ pub fn calculate_include_and_exclude(emmyrc: &Emmyrc, ignore: Option<Vec<String>
190209 exclude. push ( ignore_glob. clone ( ) ) ;
191210 }
192211
193- if let Some ( ignore ) = ignore {
194- log:: info!( "Adding ignores from \" --ignore\" : {:?}" , ignore ) ;
195- exclude. extend ( ignore ) ;
212+ if let Some ( p ) = exclude_pattern {
213+ log:: info!( "Adding excludes from \" --exclude(or -- ignore) \" : {:?}" , p ) ;
214+ exclude. extend ( p ) ;
196215 }
197216
198217 for dir in & emmyrc. workspace . ignore_dir {
0 commit comments