Merge branch 'master' of https://github.com/Chiel92/YouCompleteMe into multiple_sln

This commit is contained in:
Chiel92 2013-07-19 10:25:30 +02:00
commit 92032d7f54
9 changed files with 143 additions and 53 deletions

View File

@ -7,9 +7,12 @@ YCM to work on my machine" and the reason why is obviously related to your
machine configuration and the problem would not be resolved with _reasonable_ machine configuration and the problem would not be resolved with _reasonable_
changes to the YCM codebase, then the issue is likely to be closed. changes to the YCM codebase, then the issue is likely to be closed.
**A good place to ask questions is the [ycm-users][] Google group**. Rule of
thumb: if you're not sure whether your problem is a real bug, ask on the group.
**YCM compiles just fine**; [the build bots say so][build-bots]. If the bots are **YCM compiles just fine**; [the build bots say so][build-bots]. If the bots are
green and YCM doesn't compile on your machine, then _your machine is the root green and YCM doesn't compile on your machine, then _your machine is the root
cause_. Now read the previous paragraph again. cause_. Now read the first paragraph again.
Realize that quite literally _thousands_ of people have gotten YCM to work Realize that quite literally _thousands_ of people have gotten YCM to work
successfully so if you can't, it's probably because you have a peculiar successfully so if you can't, it's probably because you have a peculiar
@ -25,6 +28,8 @@ Further, **search the issue tracker for similar issues** before creating a new
one. There's no point in duplication; if an existing issue addresses your one. There's no point in duplication; if an existing issue addresses your
problem, please comment there instead of creating a duplicate. problem, please comment there instead of creating a duplicate.
You should also **search the archives of the [ycm-users][] mailing list**.
Lastly, **make sure you are running the latest version of YCM**. The issue you Lastly, **make sure you are running the latest version of YCM**. The issue you
have encountered may have already been fixed. **Don't forget to recompile have encountered may have already been fixed. **Don't forget to recompile
ycm_core.so too** (usually by just running `install.sh` again). ycm_core.so too** (usually by just running `install.sh` again).
@ -80,3 +85,4 @@ Creating good pull requests
change is known. _What goal are you trying to accomplish?_ change is known. _What goal are you trying to accomplish?_
[build-bots]: https://travis-ci.org/Valloric/YouCompleteMe [build-bots]: https://travis-ci.org/Valloric/YouCompleteMe
[ycm-users]: https://groups.google.com/forum/?hl=en#!forum/ycm-users

View File

@ -240,16 +240,22 @@ notify you to recompile it. You should then rerun the install process.
Now we need to generate the makefiles. If you DON'T care about semantic Now we need to generate the makefiles. If you DON'T care about semantic
support for C-family languages, run the following command in the `ycm_build` support for C-family languages, run the following command in the `ycm_build`
directory: `cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/cpp` directory:
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/cpp
If you DO care about semantic support for C-family languages, then your If you DO care about semantic support for C-family languages, then your
`cmake` call will be a bit more complicated. We'll assume you downloaded a `cmake` call will be a bit more complicated. We'll assume you downloaded a
binary distribution of LLVM+Clang from llvm.org in step 3 and that you binary distribution of LLVM+Clang from llvm.org in step 3 and that you
extracted the archive file to folder `~/ycm_temp/llvm_root_dir` (with `bin`, extracted the archive file to folder `~/ycm_temp/llvm_root_dir` (with `bin`,
`lib`, `include` etc. folders right inside that folder). With that in mind, `lib`, `include` etc. folders right inside that folder). With that in mind,
run the following command in the `ycm_build` directory: `cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/cpp` run the following command in the `ycm_build` directory:
Now that makefiles have been generated, simply run `make ycm_core`. cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/cpp
Now that makefiles have been generated, simply run:
make ycm_core
For those who want to use the system version of libclang, you would pass For those who want to use the system version of libclang, you would pass
`-DUSE_SYSTEM_LIBCLANG=ON` to cmake _instead of_ the `-DUSE_SYSTEM_LIBCLANG=ON` to cmake _instead of_ the
@ -383,6 +389,18 @@ But again, installing YCM with Vundle takes care of all of this for you.
In the future expect to see features like go-to-definition for Python as well. In the future expect to see features like go-to-definition for Python as well.
### C# semantic completion
YCM uses [omnisharp][] to provide semantic completion for C#.
YCM uses it as a git subrepo. If you're installing YCM with Vundle
(which is the recommended way) then Vundle will make sure that the subrepo is
checked out when you do `:BundleInstall`. If you're installing YCM by hand, then
you need to run `git submodule update --init --recursive` when you're checking
out the YCM repository.
OmniSharp is written in C# and has to be compiled. The install script takes care of this
if you pass `--omnisharp-completer` as an argument.
### Semantic completion for other languages ### Semantic completion for other languages
YCM will use your `omnifunc` (see `:h omnifunc` in Vim) as a source for semantic YCM will use your `omnifunc` (see `:h omnifunc` in Vim) as a source for semantic
@ -1244,7 +1262,7 @@ current file and simple prefix-based fitering.
### Why does YCM demand such a recent version of Vim? ### Why does YCM demand such a recent version of Vim?
During YCM's development several show-stopper bugs where encountered in Vim. During YCM's development several show-stopper bugs were encountered in Vim.
Those needed to be fixed upstream (and were). A few months after those bugs were Those needed to be fixed upstream (and were). A few months after those bugs were
fixed, Vim trunk landed the `pyeval()` function which improved YCM performance fixed, Vim trunk landed the `pyeval()` function which improved YCM performance
even more since less time was spent serializing and deserializing data between even more since less time was spent serializing and deserializing data between
@ -1264,12 +1282,22 @@ You'll have to learn to ignore them. It's a shitty "solution", I know.
Use the [delimitMate][] plugin instead. It does the same thing without Use the [delimitMate][] plugin instead. It does the same thing without
conflicting with YCM. conflicting with YCM.
### Is there some sort of YCM mailing list? I have questions
If you have questions about the plugin or need help, please use the
[ycm-users][] mailing list, _don't_ create issues on the tracker. The tracker is
for bug reports and feature requests.
Contact Contact
------- -------
If you have questions, bug reports, suggestions, etc. please use the [issue If you have questions about the plugin or need help, please use the
tracker][tracker]. The latest version is available at [ycm-users][] mailing list.
If you have bug reports or feature suggestions, please use the [issue
tracker][tracker].
The latest version of the plugin is available at
<http://valloric.github.io/YouCompleteMe/>. <http://valloric.github.io/YouCompleteMe/>.
The author's homepage is <http://val.markovic.io>. The author's homepage is <http://val.markovic.io>.
@ -1308,3 +1336,5 @@ This software is licensed under the [GPL v3 license][gpl].
[exuberant-ctags]: http://ctags.sourceforge.net/ [exuberant-ctags]: http://ctags.sourceforge.net/
[ctags-format]: http://ctags.sourceforge.net/FORMAT [ctags-format]: http://ctags.sourceforge.net/FORMAT
[vundle-bug]: https://github.com/gmarik/vundle/issues/48 [vundle-bug]: https://github.com/gmarik/vundle/issues/48
[ycm-users]: https://groups.google.com/forum/?hl=en#!forum/ycm-users
[omnisharp]: https://github.com/nosami/OmniSharpServer

View File

@ -118,3 +118,8 @@ if( MSVC )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
set_target_properties( ${PROJECT_NAME} PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" ) set_target_properties( ${PROJECT_NAME} PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" )
endif() endif()
if( SYSTEM_IS_SUNOS )
# SunOS needs this setting for thread support
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthreads" )
endif()

View File

@ -28,6 +28,10 @@ if ( ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" )
set( SYSTEM_IS_FREEBSD true ) set( SYSTEM_IS_FREEBSD true )
endif() endif()
if ( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
set( SYSTEM_IS_SUNOS true )
endif()
# Check if platform is 64 bit # Check if platform is 64 bit
if( CMAKE_SIZEOF_VOID_P EQUAL 4 ) if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set( 64_BIT_PLATFORM 0 ) set( 64_BIT_PLATFORM 0 )

View File

@ -313,4 +313,9 @@ endif()
############################################################################# #############################################################################
if( SYSTEM_IS_SUNOS )
# SunOS needs this setting for thread support
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthreads" )
endif()
add_subdirectory( tests ) add_subdirectory( tests )

View File

@ -102,25 +102,33 @@ function linux_cmake_install {
} }
function usage { function usage {
echo "Usage: $0 [--clang-completer]" echo "Usage: $0 [--clang-completer [--system-libclang]] [--omnisharp-completer]"
exit 0 exit 0
} }
if [[ $# -gt 1 ]]; then cmake_args=""
usage omnisharp_completer=false
fi for flag in $@; do
case "$flag" in
case "$1" in
--clang-completer) --clang-completer)
cmake_args='-DUSE_CLANG_COMPLETER=ON' cmake_args="-DUSE_CLANG_COMPLETER=ON"
;; ;;
'') --system-libclang)
cmake_args='' cmake_args="$cmake_args -DUSE_SYSTEM_LIBCLANG=ON"
;;
--omnisharp-completer)
omnisharp_completer=true
;; ;;
*) *)
usage usage
;; ;;
esac esac
done
if [[ $cmake_args == *-DUSE_SYSTEM_LIBCLANG=ON* ]] && \
[[ $cmake_args != *-DUSE_CLANG_COMPLETER=ON* ]]; then
usage
fi
if ! command_exists cmake; then if ! command_exists cmake; then
echo "CMake is required to build YouCompleteMe." echo "CMake is required to build YouCompleteMe."
@ -133,3 +141,20 @@ else
testrun $cmake_args $EXTRA_CMAKE_ARGS testrun $cmake_args $EXTRA_CMAKE_ARGS
fi fi
if $omnisharp_completer; then
buildcommand="msbuild"
if ! command_exists msbuild; then
buildcommand="xbuild"
if ! command_exists xbuild; then
echo "msbuild or xbuild is required to build Omnisharp"
exit 1
fi
fi
ycm_dir=`pwd`
build_dir=$ycm_dir"/python/ycm/completers/cs/OmniSharpServer"
cd $build_dir
$buildcommand
cd $ycm_dir
fi

View File

@ -21,13 +21,11 @@ set cpo&vim
if exists( "g:loaded_youcompleteme" ) if exists( "g:loaded_youcompleteme" )
finish finish
elseif v:version < 704 elseif v:version < 703 || (v:version == 703 && !has('patch584'))
if v:version < 703 || !has( 'patch584' )
echohl WarningMsg | echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" | \ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" |
\ echohl None \ echohl None
finish finish
endif
elseif !has( 'python' ) elseif !has( 'python' )
echohl WarningMsg | echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires python 2.x" | \ echomsg "YouCompleteMe unavailable: requires python 2.x" |

View File

@ -37,7 +37,8 @@ class CsharpCompleter( ThreadedCompleter ):
def __init__( self ): def __init__( self ):
super( CsharpCompleter, self ).__init__() super( CsharpCompleter, self ).__init__()
self.OmniSharpPort = int( vimsupport.GetVariableValue( "g:ycm_csharp_server_port" ) ) self.OmniSharpPort = int( vimsupport.GetVariableValue(
"g:ycm_csharp_server_port" ) )
self.OmniSharpHost = 'http://localhost:' + str( self.OmniSharpPort ) self.OmniSharpHost = 'http://localhost:' + str( self.OmniSharpPort )
if vimsupport.GetBoolValue( "g:ycm_auto_start_csharp_server" ): if vimsupport.GetBoolValue( "g:ycm_auto_start_csharp_server" ):
self._StartServer() self._StartServer()
@ -79,22 +80,17 @@ class CsharpCompleter( ThreadedCompleter ):
def _StartServer( self ): def _StartServer( self ):
""" Start the OmniSharp server """ """ Start the OmniSharp server """
if not self._ServerIsRunning(): if not self._ServerIsRunning():
folder = os.path.dirname( vim.current.buffer.name ) solutionfiles, folder = self._FindSolutionFiles()
solutionfiles = glob.glob1( folder, '*.sln' )
while not solutionfiles:
lastfolder = folder
folder = os.path.dirname( folder )
if folder == lastfolder:
break
solutionfiles = glob.glob1( folder, '*.sln' )
if len( solutionfiles ) == 0: if len( solutionfiles ) == 0:
vimsupport.PostVimMessage( 'Error starting OmniSharp server: no solutionfile found' ) vimsupport.PostVimMessage(
'Error starting OmniSharp server: no solutionfile found' )
return return
elif len( solutionfiles ) == 1: elif len( solutionfiles ) == 1:
solutionfile = solutionfiles[0] solutionfile = solutionfiles[0]
else: else:
choice = vimsupport.PresentDialog( "Which solutionfile should be loaded?", choice = vimsupport.PresentDialog(
"Which solutionfile should be loaded?",
[ str(i) + " " + s for i, s in enumerate( solutionfiles ) ] ) [ str(i) + " " + s for i, s in enumerate( solutionfiles ) ] )
if choice == -1: if choice == -1:
vimsupport.PostVimMessage( 'OmniSharp not started' ) vimsupport.PostVimMessage( 'OmniSharp not started' )
@ -106,7 +102,8 @@ class CsharpCompleter( ThreadedCompleter ):
'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) 'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
solutionfile = os.path.join ( folder, solutionfile ) solutionfile = os.path.join ( folder, solutionfile )
# command has to be provided as one string for some reason # command has to be provided as one string for some reason
command = [ omnisharp + ' -p ' + str( self.OmniSharpPort ) + ' -s ' + solutionfile ] command = [ omnisharp + ' -p ' + str( self.OmniSharpPort )
+ ' -s ' + solutionfile ]
stderrLogFormat = vimsupport.GetVariableValue( "g:ycm_csharp_server_stderr_logfile_format" ) stderrLogFormat = vimsupport.GetVariableValue( "g:ycm_csharp_server_stderr_logfile_format" )
if stderrLogFormat: if stderrLogFormat:
@ -132,6 +129,17 @@ class CsharpCompleter( ThreadedCompleter ):
""" Check if the OmniSharp server is running """ """ Check if the OmniSharp server is running """
return self._GetResponse( '/checkalivestatus', silent=True ) != None return self._GetResponse( '/checkalivestatus', silent=True ) != None
def _FindSolutionFiles( self ):
folder = os.path.dirname( vim.current.buffer.name )
solutionfiles = glob.glob1( folder, '*.sln' )
while not solutionfiles:
lastfolder = folder
folder = os.path.dirname( folder )
if folder == lastfolder:
break
solutionfiles = glob.glob1( folder, '*.sln' )
return solutionfiles, folder
def _GetCompletions( self ): def _GetCompletions( self ):
""" Ask server for completions """ """ Ask server for completions """
line, column = vimsupport.CurrentLineAndColumn() line, column = vimsupport.CurrentLineAndColumn()
@ -153,5 +161,6 @@ class CsharpCompleter( ThreadedCompleter ):
return json.loads( response.read() ) return json.loads( response.read() )
except Exception as e: except Exception as e:
if not silent: if not silent:
vimsupport.PostVimMessage('OmniSharp : Could not connect to ' + target + ': ' + str(e)) vimsupport.PostVimMessage('OmniSharp : Could not connect to '
+ target + ': ' + str(e))
return None return None

View File

@ -82,13 +82,13 @@ class FilenameCompleter( ThreadedCompleter ):
# We do what GCC does for <> versus "": # We do what GCC does for <> versus "":
# http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html # http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
include_current_file_dir = '<' not in include_match.group() include_current_file_dir = '<' not in include_match.group()
return GenerateCandidatesForPaths( return _GenerateCandidatesForPaths(
self.GetPathsIncludeCase( path_dir, include_current_file_dir ) ) self.GetPathsIncludeCase( path_dir, include_current_file_dir ) )
path_match = self._path_regex.search( line ) path_match = self._path_regex.search( line )
path_dir = os.path.expanduser( path_match.group() ) if path_match else '' path_dir = os.path.expanduser( path_match.group() ) if path_match else ''
return GenerateCandidatesForPaths( GetPathsStandardCase( path_dir ) ) return _GenerateCandidatesForPaths( _GetPathsStandardCase( path_dir ) )
def GetPathsIncludeCase( self, path_dir, include_current_file_dir ): def GetPathsIncludeCase( self, path_dir, include_current_file_dir ):
@ -110,7 +110,7 @@ class FilenameCompleter( ThreadedCompleter ):
return sorted( set( paths ) ) return sorted( set( paths ) )
def GetPathsStandardCase( path_dir ): def _GetPathsStandardCase( path_dir ):
if not USE_WORKING_DIR and not path_dir.startswith( '/' ): if not USE_WORKING_DIR and not path_dir.startswith( '/' ):
path_dir = os.path.join( os.path.dirname( vim.current.buffer.name ), path_dir = os.path.join( os.path.dirname( vim.current.buffer.name ),
path_dir ) path_dir )
@ -124,11 +124,19 @@ def GetPathsStandardCase( path_dir ):
for relative_path in relative_paths ) for relative_path in relative_paths )
def GenerateCandidatesForPaths( absolute_paths ): def _GenerateCandidatesForPaths( absolute_paths ):
def GenerateCandidateForPath( absolute_path ): seen_basenames = set()
is_dir = os.path.isdir( absolute_path ) completion_dicts = []
return { 'word': os.path.basename( absolute_path ),
'dup': 1,
'menu': '[Dir]' if is_dir else '[File]' }
return [ GenerateCandidateForPath( path ) for path in absolute_paths ] for absolute_path in absolute_paths:
basename = os.path.basename( absolute_path )
if basename in seen_basenames:
continue
seen_basenames.add( basename )
is_dir = os.path.isdir( absolute_path )
completion_dicts.append( { 'word': basename,
'dup': 1,
'menu': '[Dir]' if is_dir else '[File]' } )
return completion_dicts