jlc / envim

The ensime for vim
54 stars 3 forks source link

Allow :Envim to start in source subdirectory #8

Closed megaannum closed 12 years ago

megaannum commented 12 years ago

I generally start an editing session in the source directory, not the root project directory. Currently, the :Envim command looks for the .ensime file in the current directory. With this patch to VimHelpers.py : def getEnsimeConfigFile():

configFile = os.getcwd() + '/' + '.ensime'

path = os.getcwd()
configFile = path + '/' + '.ensime'
while (not os.path.isfile(configFile)):
    path = os.path.dirname(path)
    if path == '/':
      echoe("Ensime configuration file (%s) doest not exist" % (configFile))
      return None
    configFile = path + '/' + '.ensime'
if not os.path.isfile(configFile):
  # todo: set a variable and add a function so to be able to restart connection-info
  echoe("Ensime configuration file (%s) doest not exist" % (configFile))
  return None

return configFile

It will start looking in the current directory and then if not found walk up the parent directories looking for the .ensime file. I've never written any python so there might be a better way to do this so this is a proof of concept patch only (but it seems to work).

jlc commented 12 years ago

Excelent, that's a good idea. I'll add it as soon as I get a bit of time! Thanks for idea and patch!

jlc commented 12 years ago

Has nicely reported by github, it has been done in last commits.

Thanks!