44import re
55import time
66import threading
7+ from typing import Any
78from .nwscript_doc_fixes import get_doc_fix
89
910def plugin_loaded ():
@@ -180,6 +181,16 @@ def __init__(self):
180181 # directory => set() of include-only files
181182 self .include_completions = None
182183
184+ def get_settings_value (self , key : str ) -> Any :
185+ proj = sublime .active_window ().project_data ()
186+ for k in ("settings" , "nwscript" , key ):
187+ if proj is not None :
188+ proj = proj .get (k )
189+ if proj is not None :
190+ return proj
191+
192+ return self .settings .get (key )
193+
183194 def on_query_completions (self , view : sublime .View , prefix : str , locations : (str , str , (int , int ))) -> list :
184195 if not view .scope_name (locations [0 ]).startswith ("source.nss" ):
185196 return
@@ -213,7 +224,7 @@ def on_query_completions(self, view: sublime.View, prefix: str, locations: (str,
213224 )
214225
215226 # Show include error if looking for symbol completions
216- if len (include_errors ) > 0 and self .settings . get ("enable_missing_include_popup" ) is True :
227+ if len (include_errors ) > 0 and self .get_settings_value ("enable_missing_include_popup" ) is True :
217228 text = "<br>" .join (include_errors )
218229 sublime .active_window ().active_view ().show_popup (
219230 '<html style="background-color: color(var(--background) blend(red 75%));"><p>' + text + '</p></html>' ,
@@ -229,13 +240,13 @@ def on_modified(self, view: sublime.View) -> None:
229240 if not view .scope_name (point ).startswith ("source.nss" ):
230241 return
231242
232- if self .settings . get ("enable_doc_popup" ) is False :
243+ if self .get_settings_value ("enable_doc_popup" ) is False :
233244 return
234245
235246 module_path , file_path = self .get_opened_file_paths (view )
236247 file_data = view .substr (sublime .Region (0 , view .size ()))
237248
238- if self .settings . get ("parse_on_modified" ) is True :
249+ if self .get_settings_value ("parse_on_modified" ) is True :
239250 self .parse_script_tree (module_path , file_path , file_data )
240251
241252 if view .substr (point ) in ['(' , ')' ] or point != view .sel ()[0 ].end ():
@@ -253,7 +264,7 @@ def on_hover(self, view: sublime.View, point: tuple, hover_zone) -> None:
253264 if not view .scope_name (point ).startswith ("source.nss" ):
254265 return
255266
256- if self .settings . get ("enable_doc_popup" ) is False :
267+ if self .get_settings_value ("enable_doc_popup" ) is False :
257268 return
258269
259270 # Ignore hover over non selected text
@@ -393,7 +404,7 @@ def find_file_by_resref(self, module_path: str, resref: str) -> str:
393404 path_list = []
394405 if module_path is not None :
395406 path_list .append (module_path )
396- path_list .extend (self .settings . get ("include_path" ))
407+ path_list .extend (self .get_settings_value ("include_path" ))
397408
398409 for path in path_list :
399410 file = os .path .join (path , resref + ".nss" )
@@ -514,7 +525,7 @@ def parse_script(self, file_path: str, file_data: str = None) -> None:
514525 doc = Documentation ()
515526 doc .signature = ("f" , fun_type , fun_name , args )
516527 doc .script_resref = resref
517- doc .fix = self .settings . get ("doc_fixes" ).get (resref , {}).get (fun_name , None )
528+ doc .fix = self .get_settings_value ("doc_fixes" ).get (resref , {}).get (fun_name , None )
518529 if doc .fix is None :
519530 doc .fix = get_doc_fix (resref , fun_name )
520531
@@ -636,7 +647,7 @@ def worker():
636647 path_list = []
637648 if module_path is not None :
638649 path_list .append (module_path )
639- path_list .extend (self .settings . get ("include_path" ))
650+ path_list .extend (self .get_settings_value ("include_path" ))
640651
641652 for dir_path in path_list :
642653 # Don't go through already parsed folders
@@ -673,7 +684,7 @@ def get_include_completions(self, module_path):
673684 path_list = []
674685 if module_path is not None :
675686 path_list .append (module_path )
676- path_list .extend (self .settings . get ("include_path" ))
687+ path_list .extend (self .get_settings_value ("include_path" ))
677688
678689 ret = []
679690 for path in path_list :
0 commit comments