Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
---
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: false
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterAttributes: Always
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: "/** .*"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeIsMainRegex: ""
IncludeIsMainSourceRegex: ""
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
Language: Cpp
LineEnding: LF
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PPIndentWidth: -1
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
QualifierAlignment: Right
ReferenceAlignment: Pointer
ReflowComments: false
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInSquareBrackets: false
Standard: c++17
TabWidth: 4
UseTab: Never
1 change: 1 addition & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
third_party/**/*
30 changes: 30 additions & 0 deletions .github/actions/initialize-linux-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: initialize-env
description: Initialize environment
runs:
using: 'composite'
steps:
- name: Update apt
shell: bash
run: sudo apt-get update
- name: Install ninja
shell: bash
run: sudo apt-get install ninja-build ccache
- name: Set environment variables
shell: bash
run: |
echo VCPKG_ROOT="$VCPKG_INSTALLATION_ROOT" >> "$GITHUB_ENV"
echo CCACHE_DIR=/home/runner/.ccache >> "$GITHUB_ENV"
echo CCACHE_TEMP_DIR=/home/runner/.ccache >> "$GITHUB_ENV"
echo CCACHE_MAXSIZE=1G >> "$GITHUB_ENV"
- name: Cache Vcpkg
id: cache-vcpkg
uses: actions/cache@v4
with:
path: /home/runner/.cache/vcpkg/archives
key: ${{ runner.os }}-vcpkg-cache
- name: Cache ccache
id: cache-ccache
uses: actions/cache@v4
with:
path: /home/runner/.ccache
key: ${{ runner.os }}-ccache-cache
18 changes: 18 additions & 0 deletions .github/actions/initialize-windows-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: initialize-env
description: Initialize environment
runs:
using: 'composite'
steps:
- name: Install ninja
shell: pwsh
run: choco install ninja -y
- name: Cache Vcpkg
id: cache-vcpkg
uses: actions/cache@v4
with:
path: ~\AppData\Local\vcpkg\archives
key: ${{ runner.os }}-vcpkg-cache
- name: Set environment variables
shell: pwsh
run: |
Write-Output "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_ENV
30 changes: 30 additions & 0 deletions .github/workflows/build-lsp-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: build-lsp-linux
on:
workflow_call

jobs:
build-lsp-linux:
strategy:
matrix:
with_gc: [with-gc, without-gc]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: ./.github/actions/initialize-linux-env
- name: Add gc option to cmake build
if: ${{ matrix.with_gc == 'with-gc' }}
run: |
echo LSPCPP_SUPPORT_BOEHM_GC=true >> "$GITHUB_ENV"
echo LSPCPP_CI_VCPKG_FEATURES=bdwgc >> "$GITHUB_ENV"
- name: configure cmake
run: cmake --preset ci/default
- name: build cmake
run: cmake --build --preset ci/default -j --target lspcpp
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: liblspcpp-linux-${{ matrix.with_gc }}
path: cmake-build-ci/liblspcpp.a
33 changes: 33 additions & 0 deletions .github/workflows/build-lsp-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build-lsp-windows
on:
workflow_call

jobs:
build-lsp-windows:
strategy:
matrix:
with_gc: [with-gc, without-gc]
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: ./.github/actions/initialize-windows-env
- name: Add gc option to cmake build
if: ${{ matrix.with_gc == 'with-gc' }}
run: |
Write-Output LSPCPP_SUPPORT_BOEHM_GC=true >> "$env:GITHUB_ENV"
Write-Output LSPCPP_CI_VCPKG_FEATURES=bdwgc >> "$env:GITHUB_ENV"
- name: configure and build cmake
run: |
$VsInfo = Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs
& "$($VsInfo.InstallLocation)\\Common7\\Tools\\Launch-VsDevShell.ps1" `
-Arch amd64 -HostArch amd64 -SkipAutomaticLocation
cmake --preset ci/default
cmake --build --preset ci/default -j --target lspcpp
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: liblspcpp-windows-${{ matrix.with_gc }}
path: cmake-build-ci/lspcpp.lib
22 changes: 22 additions & 0 deletions .github/workflows/check-format-cpp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: format-cpp
on:
workflow_call

jobs:
check-format-cpp:
runs-on: "ubuntu-24.04"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Print clang-format version
run: clang-format --version
- name: Generate list of files to be formatted
run: |
mkdir -p idir
find src include -type f -regex ".*\.\(cpp\|cc\|h\|hpp\)$" > idir/files-to-check-fmt.txt
- name: Run clang-format
run: clang-format --dry-run -Werror --files=idir/files-to-check-fmt.txt
22 changes: 22 additions & 0 deletions .github/workflows/pull-req-precheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pull-req-precheck
on:
pull_request:
branches:
- "master"
- "main"

jobs:
check-cpp-format:
uses: ./.github/workflows/check-format-cpp.yaml
build-lsp-linux:
uses: ./.github/workflows/build-lsp-linux.yaml
build-lsp-windows:
uses: ./.github/workflows/build-lsp-windows.yaml
lsp-precheck-pass:
runs-on: "ubuntu-22.04"
needs:
- check-cpp-format
- build-lsp-linux
- build-lsp-windows
steps:
- run: echo All prechecks pass!
30 changes: 30 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "ci/default",
"description": "Default profile for CI to build. uses vcpkg, C++17 and vcpkg rapidjson",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "release",
"USE_SYSTEM_RAPIDJSON": "true",
"LSPCPP_USE_CPP17": "true",
"LSPCPP_SUPPORT_BOEHM_GC": "$env{LSPCPP_SUPPORT_BOEHM_GC}",
"VCPKG_MANIFEST_FEATURES": "$env{LSPCPP_CI_VCPKG_FEATURES}",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
"binaryDir": "${sourceDir}/cmake-build-ci"
}
],
"buildPresets": [
{
"name": "ci/default",
"configurePreset": "ci/default"
}
]
}
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@
[It's here](https://github.com/kuafuwang/LspCpp/tree/master/examples)


## Development guide

For any merges into the master branch, ensure the C++ code complies with the clang-format standard.
As of currently, the latest clang-format version offered in ubuntu 24.04 (18) is used, but this
may change in the future as newer versions of clang-format is available for Ubuntu.

To check the current version of clang-format used, see the check-format-cpp workflow. It prints out
the version used. Ensure the C++ code is compliant with that version of clang-format.

`vcpkg.json` is optionally provided for convinence. It is not required for compiling LspCpp.


[1]: https://github.com/cquery-project/cquery "cquery:"
[2]: https://www.javacardos.com/tools "JcKit:"
[3]: https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore "Package Restore"

Loading