Closed ghost closed 9 years ago
안녕하세요. 유용하게 사용하신다고 하니 저도 기쁘네요. 말씀하신 문제는 해당 함수에서 어떤 일이 일어나는지를 살펴봐야 알 수 있을 것 같습니다. 폴더 구조의 공개가 상관없으시다면, autoload/VIntSearch.vim의 GetRepoDirFrom()을 아래처럼 바꿔보시고 :VSpath를 실행한 후 결과를 올려주시면 살펴보도록 하겠습니다.
function! s:GetRepoDirFrom(filepath)
if a:filepath==#''
return ''
endif
python << EOF
repodirs = vim.eval('g:vintsearch_repodirs')
filepath = vim.eval('a:filepath')
dir = os.path.dirname(filepath)
while True:
prevdir = dir
dir = os.path.dirname(prevdir)
print prevdir, '---', dir
if dir==prevdir:
# no repository found case
vim.command('return \'\'')
break
else:
exist = False
for repodir in repodirs:
print os.path.join(dir, repodir)
if os.path.exists(os.path.join(dir, repodir)):
vim.command('return \'%s\''%dir)
exist = True
break
if exist:
break
print
EOF
endif
endfunction
답변 감사합니다.
결과는 아래와 같습니다.
/Users/hazedic/tools/dotfiles/vim/bundle/VIntSearch/autoload --- /Users/hazedic/tools/dotfiles/vim/bundle/VIntSearch VIntSearch: Search path is: /Users/hazedic/tools/dotfiles/vim/bundle/VIntSearch
이상하네요.. 처음 print 문 결과를 보면 prevdir!=dir 이기 때문에 else로 넘어가서 for루프 안의 print문이 실행되야하는데, 해당하는 출력값이 없네요. 좀 더 자세히 보기 위해 해당 함수를 아래처럼 바꾸고 실행해봐주실 수 있으실지요?
function! s:GetRepoDirFrom(filepath)
if a:filepath==#''
return ''
endif
python << EOF
repodirs = vim.eval('g:vintsearch_repodirs')
filepath = vim.eval('a:filepath')
dir = os.path.dirname(filepath)
while True:
prevdir = dir
dir = os.path.dirname(prevdir)
print prevdir, '---', dir
if dir==prevdir:
print 'if dir==prevdir'
print 'return (blank)'
# no repository found case
vim.command('return \'\'')
break
else:
print 'if dir!=prevdir'
print 'repodirs', repodirs
exist = False
for repodir in repodirs:
print os.path.join(dir, repodir)
if os.path.exists(os.path.join(dir, repodir)):
vim.command('return \'%s\''%dir)
print 'return \'%s\''%dir
exist = True
break
if exist:
break
print
EOF
endif
endfunction
테스트 진행한 스샷 첨부합니다.
https://github.com/nginx/nginx 를 Desktop 경로에 clone 해서 실제 테스트 해봤는데 .git 폴더 안이 아니라 nginx 폴더에 tags 파일이 생성이 되네요.
참고로 전 리눅스 환경이 아닌 맥 환경입니다.
2014-12-11 6:32 GMT+09:00 yssl notifications@github.com:
이상하네요.. 처음 print 문 결과를 보면 prevdir!=dir 이기 때문에 else로 넘어가서 for루프 안의 print문이 실행되야하는데, 해당하는 출력값이 없네요. 좀 더 자세히 보기 위해 해당 함수를 아래처럼 바꾸고 실행해봐주실 수 있으실지요?
function! s:GetRepoDirFrom(filepath) if a:filepath==#'' return '' endif python << EOF repodirs = vim.eval('g:vintsearch_repodirs') filepath = vim.eval('a:filepath') dir = os.path.dirname(filepath) while True: prevdir = dir dir = os.path.dirname(prevdir) print prevdir, '---', dir if dir==prevdir: print 'if dir==prevdir' print 'return (blank)'
no repository found case
vim.command('return \'\'') break else: print 'if dir!=prevdir' print 'repodirs', repodirs exist = False for repodir in repodirs: print os.path.join(dir, repodir) if os.path.exists(os.path.join(dir, repodir)): vim.command('return \'%s\''%dir) print 'return \'%s\''%dir exist = True break if exist: break print
EOF endif endfunction
— Reply to this email directly or view it on GitHub https://github.com/yssl/VIntSearch/issues/1#issuecomment-66527882.
아 처음부터 그 말씀을 하셨던 거군요. tags 파일은 원래 .git이 아니라 .git을 포함하는 폴더, 즉 프로젝트 최상위 폴더에 생성되도록 되어있습니다. 그 이유는 일단 .git, .hg 등의 폴더 내부는 해당 vcs가 컨트롤하는 것이 맞고, 의미적으로도 프로젝트의 태그 정보를 가지고 있는 tags파일은 프로젝트 최상위 폴더에 있는 것이 적절하다고 생각했기 때문입니다.
먼저 매우 유용한 플러그인(VIntSearch, QFEnter) 만들어주셔서 감사합니다.
한 가지 안되는 부분이 있어서 질문 드립니다. 제가 쓰는 vimrc 에 다음과 같이 설정했는데요.
let g:vintsearch_searchpathmode = 'rc' let g:vintsearch_tagfilename = 'tags' let g:vintsearch_repodirs = ['.git', '.hg', '.svn']
GetRepoDirFrom 함수에 의해 repodir을 제대로 못구해오는 듯합니다. 그래서 .git 나 .hg 또는 .svn에 tags 파일이 생성되지 않고 프로젝트 최상위 폴더에 tags 파일이 생성 됩니다.
어떻게 해결해야할까요..