TASK: Improve logging and make it configurable
This commit is contained in:
parent
d0b34f05f4
commit
0713b6d2fc
1 changed files with 19 additions and 8 deletions
|
@ -17,9 +17,17 @@ class NeotagsPlugin(object):
|
|||
self.ctags_cmd = 'ctags'
|
||||
# Perhaps fetch debugging settings?
|
||||
|
||||
def update_settings(self):
|
||||
try:
|
||||
self.logging = bool(self.nvim.vars['neotags_logging'])
|
||||
except neovim.api.nvim.NvimError:
|
||||
self.logging = false
|
||||
|
||||
# Check whether 'FileWritePost' is necessary
|
||||
@neovim.autocmd('BufWritePost', pattern='*', eval='expand("<afile>:p")')
|
||||
def update_tags_for_file(self, filename):
|
||||
self.update_settings()
|
||||
|
||||
self.log('Triggered for "%s"' % filename)
|
||||
|
||||
pwd = self.nvim.funcs.execute('pwd').strip()
|
||||
|
@ -30,7 +38,7 @@ class NeotagsPlugin(object):
|
|||
self.log('Start updating tags for "%s"' % filename)
|
||||
self.strip_existing_tags(tags_file, relative_filename)
|
||||
self.generate_tags(tags_file, relative_filename)
|
||||
self.log('Tags for file "%s"' % filename)
|
||||
self.log('Tags updated for "%s"' % filename)
|
||||
except:
|
||||
self.log(
|
||||
'Failed to update tags for "%s", reason: %s' % (
|
||||
|
@ -55,17 +63,20 @@ class NeotagsPlugin(object):
|
|||
|
||||
def get_tags_file(self, filename):
|
||||
path = pathlib.Path(filename)
|
||||
possible_file = path.with_name(self.tags_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))
|
||||
self.log('Search tags file: "%s"' % possible_file)
|
||||
if possible_file.is_file():
|
||||
return str(possible_file)
|
||||
|
||||
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))
|
||||
possible_file = folder.with_name(self.tags_filename)
|
||||
self.log('Search tags file: "%s"' % possible_file)
|
||||
if possible_file.is_file():
|
||||
return str(possible_file)
|
||||
|
||||
raise ValueError('No tags file found in parent folders of given file')
|
||||
|
||||
def log(self, message):
|
||||
self.nvim.out_write('neotags > ' + message + "\n")
|
||||
if self.logging:
|
||||
self.nvim.out_write('neotags > ' + message + "\n")
|
||||
|
|
Loading…
Reference in a new issue