Skip to content

Commit

Permalink
Add YouCompleteMe configuration file and ignore vim swap files
Browse files Browse the repository at this point in the history
YouCompleteMe (https://github.com/ycm-core/YouCompleteMe) is a
code-completion engine for vim. This PR adds a configuration file for it
that enables it to understand the C++ FFI code in llvmlite by pointing
to the correct include dirs (as long as one is working within a Conda
environment), setting the relevant C++ standard, and ensuring that all
header files are treated as C++.

Additionally, Vim swap files are added to the gitignore, so that they
don't show up in `git status`.
  • Loading branch information
gmarkall committed Feb 14, 2023
1 parent b40a72a commit c5edea6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ coverage.xml
MANIFEST
docs/_build/
docs/gh-pages/

.*.swp
40 changes: 40 additions & 0 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# YouCompleteMe (https://github.com/ycm-core/YouCompleteMe) configuration file
# that enables it to find the LLVM and Python includes from a conda
# environment, independent of the Conda environment location and Python and
# LLVM versions.

import os
import sys

from pathlib import Path

CONDA_PREFIX = os.environ['CONDA_PREFIX']
LLVMLITE_DIR = Path(__file__).parent
VER = sys.version_info
PYTHON_INCLUDE_NAME = f'python{VER.major}.{VER.minor}'

CONDA_INCLUDE_DIR = Path(CONDA_PREFIX, 'include')
PYTHON_INCLUDE_DIR = Path(CONDA_INCLUDE_DIR, PYTHON_INCLUDE_NAME)
FFI_DIR = Path(LLVMLITE_DIR, 'ffi')

flags = [
# Include dirs
f'-I{CONDA_INCLUDE_DIR}',
f'-I{PYTHON_INCLUDE_DIR}',
f'-I{FFI_DIR}',
# C++ standard to which LLVM 14 is developed
'-std=c++14',
# Force language to C++ so that core.h is treated as C++
'-x', 'c++',
]


# This function is called by YCM to obtain the config from this file.
def Settings(**kwargs):
return {'flags': flags}


# Executing this configuration file standalone outside of YCM prints the
# settings to aid with debugging the configuration.
if __name__ == '__main__':
print(Settings())

0 comments on commit c5edea6

Please sign in to comment.