Skip to content

Instantly share code, notes, and snippets.

@juchiast
Created February 2, 2021 08:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juchiast/d42a587ac806509017d2c0f0ce9bffd5 to your computer and use it in GitHub Desktop.
Save juchiast/d42a587ac806509017d2c0f0ce9bffd5 to your computer and use it in GitHub Desktop.
YCM config for rust-analyzer with automatic features detection
from os import path
noDefaultFeatures = False
features = []
BASE = path.dirname(__file__)
try:
check_file = open(path.join(BASE, "check"), "r").read()
for line in check_file.splitlines():
line = line.strip()
if line.startswith("#"):
continue
if "--no-default-features" in line:
noDefaultFeatures = True
parts = line.split(" ")
idx = None
for (i, part) in enumerate(parts):
if part == "--features":
idx = i
break
if idx is not None and idx + 1 < len(parts):
features = parts[idx + 1].split(",")
except:
pass
print(noDefaultFeatures)
print(features)
def Settings( **kwargs ):
if kwargs[ 'language' ] == 'rust':
settings = { 'ls': { 'checkOnSave' : { 'enable': False } } }
settings['ls']['cargo'] = { 'noDefaultFeatures': noDefaultFeatures, 'features': features }
return settings
#!/usr/bin/bash
set -Eeuxo pipefail
# cargo check --no-default-features --features sinks-loki,loki-integration-tests --tests
# cargo check --no-default-features --features sinks-elasticsearch,es-integration-tests --tests
# cargo check --no-default-features --features sources-docker_logs,docker-logs-integration-tests --tests
cargo check --no-default-features --features sinks-gcp --tests
# cargo check --tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment