Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic C# completer #365

Merged
merged 14 commits into from Jul 18, 2013
Merged
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -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_
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
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
successfully so if you can't, it's probably because you have a peculiar
Expand All @@ -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
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
have encountered may have already been fixed. **Don't forget to recompile
ycm_core.so too** (usually by just running `install.sh` again).
Expand Down Expand Up @@ -80,3 +85,4 @@ Creating good pull requests
change is known. _What goal are you trying to accomplish?_

[build-bots]: https://travis-ci.org/Valloric/YouCompleteMe
[ycm-users]: https://groups.google.com/forum/?hl=en#!forum/ycm-users
29 changes: 23 additions & 6 deletions README.md
Expand Up @@ -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
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
`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
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,
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:

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`.
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
`-DUSE_SYSTEM_LIBCLANG=ON` to cmake _instead of_ the
Expand Down Expand Up @@ -1256,7 +1262,7 @@ current file and simple prefix-based fitering.

### 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
fixed, Vim trunk landed the `pyeval()` function which improved YCM performance
even more since less time was spent serializing and deserializing data between
Expand All @@ -1276,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
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
-------

If you have questions, bug reports, suggestions, etc. please use the [issue
tracker][tracker]. The latest version is available at
If you have questions about the plugin or need help, please use the
[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/>.

The author's homepage is <http://val.markovic.io>.
Expand Down Expand Up @@ -1320,4 +1336,5 @@ This software is licensed under the [GPL v3 license][gpl].
[exuberant-ctags]: http://ctags.sourceforge.net/
[ctags-format]: http://ctags.sourceforge.net/FORMAT
[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
5 changes: 5 additions & 0 deletions cpp/BoostParts/CMakeLists.txt
Expand Up @@ -118,3 +118,8 @@ if( MSVC )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
set_target_properties( ${PROJECT_NAME} PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" )
endif()

if( SYSTEM_IS_SUNOS )
# SunOS needs this setting for thread support
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthreads" )
endif()
4 changes: 4 additions & 0 deletions cpp/CMakeLists.txt
Expand Up @@ -28,6 +28,10 @@ if ( ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" )
set( SYSTEM_IS_FREEBSD true )
endif()

if ( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
set( SYSTEM_IS_SUNOS true )
endif()

# Check if platform is 64 bit
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set( 64_BIT_PLATFORM 0 )
Expand Down
5 changes: 5 additions & 0 deletions cpp/ycm/CMakeLists.txt
Expand Up @@ -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 )
18 changes: 11 additions & 7 deletions install.sh
Expand Up @@ -102,20 +102,19 @@ function linux_cmake_install {
}

function usage {
echo "Usage: $0 [--clang-completer] [--cs-completer]"
echo "Usage: $0 [--clang-completer [--system-libclang]] [--omnisharp-completer]"
exit 0
}

if [[ $# -gt 2 ]]; then
usage
fi

cmake_args=''
cmake_args=""
omnisharp_completer=false
for flag in $@; do
case "$flag" in
--clang-completer)
cmake_args='-DUSE_CLANG_COMPLETER=ON'
cmake_args="-DUSE_CLANG_COMPLETER=ON"
;;
--system-libclang)
cmake_args="$cmake_args -DUSE_SYSTEM_LIBCLANG=ON"
;;
--omnisharp-completer)
omnisharp_completer=true
Expand All @@ -126,6 +125,11 @@ for flag in $@; do
esac
done

if [[ $cmake_args == *-DUSE_SYSTEM_LIBCLANG=ON* ]] && \
[[ $cmake_args != *-DUSE_CLANG_COMPLETER=ON* ]]; then
usage
fi

if ! command_exists cmake; then
echo "CMake is required to build YouCompleteMe."
cmake_install
Expand Down
12 changes: 5 additions & 7 deletions plugin/youcompleteme.vim
Expand Up @@ -21,13 +21,11 @@ set cpo&vim

if exists( "g:loaded_youcompleteme" )
finish
elseif v:version < 704
if v:version < 703 || !has( 'patch584' )
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" |
\ echohl None
finish
endif
elseif v:version < 703 || (v:version == 703 && !has('patch584'))
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" |
\ echohl None
finish
elseif !has( 'python' )
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires python 2.x" |
Expand Down
26 changes: 17 additions & 9 deletions python/ycm/completers/general/filename_completer.py
Expand Up @@ -82,13 +82,13 @@ def ComputeCandidates( self, unused_query, start_column ):
# We do what GCC does for <> versus "":
# http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
include_current_file_dir = '<' not in include_match.group()
return GenerateCandidatesForPaths(
return _GenerateCandidatesForPaths(
self.GetPathsIncludeCase( path_dir, include_current_file_dir ) )

path_match = self._path_regex.search( line )
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 ):
Expand All @@ -110,7 +110,7 @@ def GetPathsIncludeCase( self, path_dir, include_current_file_dir ):
return sorted( set( paths ) )


def GetPathsStandardCase( path_dir ):
def _GetPathsStandardCase( path_dir ):
if not USE_WORKING_DIR and not path_dir.startswith( '/' ):
path_dir = os.path.join( os.path.dirname( vim.current.buffer.name ),
path_dir )
Expand All @@ -124,11 +124,19 @@ def GetPathsStandardCase( path_dir ):
for relative_path in relative_paths )


def GenerateCandidatesForPaths( absolute_paths ):
def GenerateCandidateForPath( absolute_path ):
def _GenerateCandidatesForPaths( absolute_paths ):
seen_basenames = set()
completion_dicts = []

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 )
return { 'word': os.path.basename( absolute_path ),
'dup': 1,
'menu': '[Dir]' if is_dir else '[File]' }
completion_dicts.append( { 'word': basename,
'dup': 1,
'menu': '[Dir]' if is_dir else '[File]' } )

return [ GenerateCandidateForPath( path ) for path in absolute_paths ]
return completion_dicts