Forráskód Böngészése

User can now pick the root for relative paths

Strahinja Val Markovic 12 éve
szülő
commit
8d20637295
3 módosított fájl, 26 hozzáadás és 0 törlés
  1. 16 0
      README.md
  2. 3 0
      plugin/youcompleteme.vim
  3. 7 0
      python/completers/general/filename_completer.py

+ 16 - 0
README.md

@@ -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
 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
 ---------------------------------
 
@@ -861,6 +865,17 @@ Default: `[]`
 
     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
 
 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
 [eclim]: http://eclim.org/
 [jedi]: https://github.com/davidhalter/jedi
+[ultisnips]: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt

+ 3 - 0
plugin/youcompleteme.vim

@@ -121,6 +121,9 @@ let g:ycm_confirm_extra_conf =
 let 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 =
       \ get( g:, 'ycm_semantic_triggers', {
       \   'c' : ['->', '.'],

+ 7 - 0
python/completers/general/filename_completer.py

@@ -18,9 +18,12 @@
 
 from completers.completer import GeneralCompleter
 import vim
+import vimsupport
 import os
 import re
 
+USE_WORKING_DIR = vimsupport.GetBoolValue(
+  'g:ycm_filepath_completion_use_working_dir' )
 
 class FilenameCompleter( GeneralCompleter ):
   """
@@ -74,6 +77,10 @@ class FilenameCompleter( GeneralCompleter ):
     match = self._path_regex.search( line )
     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:
       paths = os.listdir( path_dir )
     except: