User can now pick the root for relative paths

This commit is contained in:
Strahinja Val Markovic 2013-04-22 21:44:18 -07:00
parent aa9127e3dc
commit 8d20637295
3 changed files with 26 additions and 0 deletions

View File

@ -67,6 +67,10 @@ YCM also provides semantic go-to-definition/declaration commands for C-family
languages. Expect more IDE features powered by the various YCM semantic engines languages. Expect more IDE features powered by the various YCM semantic engines
in the future. in the future.
You'll also find that YCM has filepath completers (try typing `./` in a file)
and a completer that integrates with [UltiSnips][].
Mac OS X super-quick installation Mac OS X super-quick installation
--------------------------------- ---------------------------------
@ -861,6 +865,17 @@ Default: `[]`
let g:ycm_extra_conf_globlist = [] let g:ycm_extra_conf_globlist = []
### The `g:ycm_filepath_completion_use_working_dir` option
By default, YCM's filepath completion will interpret relative paths like `../`
as being relative to the folder of the file of the currently active buffer.
Setting this option will force YCM to always interpret relative paths as being
relative to Vim's current working directory.
Default: `0`
let g:ycm_filepath_completion_use_working_dir = 0
### The `g:ycm_semantic_triggers` option ### The `g:ycm_semantic_triggers` option
This option controls the character-based triggers for the various semantic This option controls the character-based triggers for the various semantic
@ -1140,3 +1155,4 @@ This software is licensed under the [GPL v3 license][gpl].
[win-wiki]: https://github.com/Valloric/YouCompleteMe/wiki/Windows-Installation-Guide [win-wiki]: https://github.com/Valloric/YouCompleteMe/wiki/Windows-Installation-Guide
[eclim]: http://eclim.org/ [eclim]: http://eclim.org/
[jedi]: https://github.com/davidhalter/jedi [jedi]: https://github.com/davidhalter/jedi
[ultisnips]: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt

View File

@ -121,6 +121,9 @@ let g:ycm_confirm_extra_conf =
let g:ycm_extra_conf_globlist = let g:ycm_extra_conf_globlist =
\ get( g:, 'ycm_extra_conf_globlist', [] ) \ get( g:, 'ycm_extra_conf_globlist', [] )
let g:ycm_filepath_completion_use_working_dir =
\ get( g:, 'ycm_filepath_completion_use_working_dir', 0 )
let g:ycm_semantic_triggers = let g:ycm_semantic_triggers =
\ get( g:, 'ycm_semantic_triggers', { \ get( g:, 'ycm_semantic_triggers', {
\ 'c' : ['->', '.'], \ 'c' : ['->', '.'],

View File

@ -18,9 +18,12 @@
from completers.completer import GeneralCompleter from completers.completer import GeneralCompleter
import vim import vim
import vimsupport
import os import os
import re import re
USE_WORKING_DIR = vimsupport.GetBoolValue(
'g:ycm_filepath_completion_use_working_dir' )
class FilenameCompleter( GeneralCompleter ): class FilenameCompleter( GeneralCompleter ):
""" """
@ -74,6 +77,10 @@ class FilenameCompleter( GeneralCompleter ):
match = self._path_regex.search( line ) match = self._path_regex.search( line )
path_dir = os.path.expanduser( match.group() ) if match else '' path_dir = os.path.expanduser( match.group() ) if match else ''
if not USE_WORKING_DIR and not path_dir.startswith( '/' ):
path_dir = os.path.join( os.path.dirname( vim.current.buffer.name ),
path_dir )
try: try:
paths = os.listdir( path_dir ) paths = os.listdir( path_dir )
except: except: