From 01f0209c9c4f02b8e39093eee7afd64e7d5e0595 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 17 May 2017 21:18:11 +0200 Subject: [PATCH] BUGFIX: Lookup tags file in parent folders --- rplugin/python3/neotags.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rplugin/python3/neotags.py b/rplugin/python3/neotags.py index af0d52e..b423cba 100644 --- a/rplugin/python3/neotags.py +++ b/rplugin/python3/neotags.py @@ -1,6 +1,6 @@ import neovim -import os import sys +import pathlib import fileinput import subprocess import locket @@ -49,12 +49,16 @@ class NeotagsPlugin(object): ]) def get_tags_file(self): - start_dir = os.path.dirname(self.filename) - self.log('tst: ' + start_dir) - # TODO: Why does it find the file? - for dirpath, __, filenames in os.walk(start_dir, topdown=False): - if self.tags_filename in filenames: - return os.path.join(dirpath, self.tags_filename) + path = pathlib.Path(self.filename) + + self.log('Test: ' + str(path.with_name(self.tags_filename))) + if path.with_name(self.tags_filename).is_file(): + return str(path.with_name(self.tags_filename)) + + for folder in path.parents: + self.log('Test: ' + str(folder.with_name(self.tags_filename))) + if folder.with_name(self.tags_filename).is_file(): + return str(folder.with_name(self.tags_filename)) raise ValueError('No tags file found in parent folders of given file')