@@ -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,7 @@ 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 ( & workspace_folders, & analysis. emmyrc , exclude_pattern , include_pattern ) ;
115116 let files = file_infos
116117 . into_iter ( )
117118 . filter_map ( |file| {
@@ -140,10 +141,11 @@ pub fn load_workspace(
140141pub fn collect_files (
141142 workspaces : & Vec < PathBuf > ,
142143 emmyrc : & Emmyrc ,
143- ignore : Option < Vec < String > > ,
144+ exclude_pattern : Option < Vec < String > > ,
145+ include_pattern : Option < Vec < String > > ,
144146) -> Vec < LuaFileInfo > {
145147 let mut files = Vec :: new ( ) ;
146- let ( match_pattern, exclude, exclude_dir) = calculate_include_and_exclude ( emmyrc, ignore ) ;
148+ let ( match_pattern, exclude, exclude_dir) = calculate_include_and_exclude ( emmyrc, exclude_pattern , include_pattern ) ;
147149
148150 let encoding = & emmyrc. workspace . encoding ;
149151
@@ -167,21 +169,28 @@ pub fn collect_files(
167169/// File patterns for workspace scanning: (include_patterns, exclude_patterns, exclude_dirs)
168170type FilePatterns = ( Vec < String > , Vec < String > , Vec < PathBuf > ) ;
169171
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 ( ) ] ;
172+ pub fn calculate_include_and_exclude ( emmyrc : & Emmyrc , exclude_pattern : Option < Vec < String > > , include_pattern : Option < Vec < String > > ) -> FilePatterns {
173+ let mut include = Vec :: new ( ) ;
172174 let mut exclude = Vec :: new ( ) ;
173175 let mut exclude_dirs = Vec :: new ( ) ;
174176
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 ( ) ) ;
177+ if let Some ( p) = include_pattern {
178+ include. extend ( p) ;
179+ } else {
180+ include. push ( "**/*.lua" . to_string ( ) ) ;
181+ include. push ( "**/.editorconfig" . to_string ( ) ) ;
182+
183+ for extension in & emmyrc. runtime . extensions {
184+ if extension. starts_with ( "." ) {
185+ log:: info!( "Adding extension: **/*{}" , extension) ;
186+ include. push ( format ! ( "**/*{}" , extension) ) ;
187+ } else if extension. starts_with ( "*." ) {
188+ log:: info!( "Adding extension: **/{}" , extension) ;
189+ include. push ( format ! ( "**/{}" , extension) ) ;
190+ } else {
191+ log:: info!( "Adding extension: {}" , extension) ;
192+ include. push ( extension. clone ( ) ) ;
193+ }
185194 }
186195 }
187196
@@ -190,9 +199,9 @@ pub fn calculate_include_and_exclude(emmyrc: &Emmyrc, ignore: Option<Vec<String>
190199 exclude. push ( ignore_glob. clone ( ) ) ;
191200 }
192201
193- if let Some ( ignore ) = ignore {
194- log:: info!( "Adding ignores from \" --ignore\" : {:?}" , ignore ) ;
195- exclude. extend ( ignore ) ;
202+ if let Some ( p ) = exclude_pattern {
203+ log:: info!( "Adding excludes from \" --exclude(or -- ignore) \" : {:?}" , p ) ;
204+ exclude. extend ( p ) ;
196205 }
197206
198207 for dir in & emmyrc. workspace . ignore_dir {
0 commit comments