@@ -218,28 +218,32 @@ impl Config {
218218
219219 /// Load configuration file from installation folder
220220 fn load_installed_config ( & mut self , messages : & mut dyn MessageHandler ) {
221- let config_relative_path = if cfg ! ( feature = "packaged" ) {
222- // relative to packaged bin folder
223- "../vhdl_libraries"
224- } else {
225- // relative to target/debug or target/release
226- "../../vhdl_libraries"
227- } ;
228-
229- let exe_path = env :: current_exe ( ) . expect ( "Executable path needed" ) ;
230- let exe_folder = exe_path . parent ( ) . expect ( "Executable folder must exist" ) ;
231-
232- let mut file_name = exe_folder. join ( config_relative_path ) ;
233- file_name. push ( "vhdl_ls.toml" ) ;
234-
235- if ! file_name. exists ( ) {
236- panic ! (
237- "Couldn't find installed libraries at {}." ,
238- file_name . to_string_lossy ( )
239- ) ;
221+ let search_paths = [
222+ "../vhdl_libraries" ,
223+ "../../ vhdl_libraries" ,
224+ "/usr/lib/rust_hdl/vhdl_libraries" ,
225+ ] ;
226+
227+ for dir in search_paths . into_iter ( ) {
228+ let mut file_name = PathBuf :: from ( dir ) ;
229+ // Expand a relative path
230+ if !file_name . is_absolute ( ) {
231+ let exe_path = env :: current_exe ( ) . expect ( "Executable path needed" ) ;
232+ let exe_folder = exe_path . parent ( ) . expect ( "Executable folder must exist" ) ;
233+ file_name = exe_folder . join ( file_name )
234+ }
235+ file_name. push ( "vhdl_ls.toml" ) ;
236+ if file_name . exists ( ) {
237+ self . load_config ( & file_name , "Installation" , messages ) ;
238+ return ;
239+ }
240240 }
241241
242- self . load_config ( & file_name, "Installation" , messages) ;
242+ // Panic if we did not yet find the installed libraries
243+ panic ! (
244+ "Couldn't find installed libraries at {}." ,
245+ search_paths. join( ", " )
246+ ) ;
243247 }
244248
245249 /// Load configuration file from home folder
0 commit comments