Skip to content

Commit

Permalink
2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boocs committed Jan 21, 2024
1 parent 179fa58 commit 1814677
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 176 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@
## [Unreleased]

- Create command that shows clang and clangd version in terminal
- Add a way to add skeleton support for UE5 source intellisense (wont work but people will have a compile_flags.txt and a UE5 .clangd file to try to get it to work)

## [2.3.0] 2024-01-21
### Added
- clang-format: added "NamespaceIndentation: All" to default config when created
- Docs: Added Quick Start Guide section
### Changed
- Intellisense now uses DebugGame instead of Development.
- You should still use Development most of the time when Building or Running your project. (You will still get Intellisense)
- This prevents having to Rebuild when Running your project using Development
- Fixes fake red squiggles after Building your project
- When a Creating Project we now put the compile commands path in the .clangd file instead of the workspace cfg file.
- This will set the stage, for the future, for using a different .clangd file and compile commands/flags file for the Unreal Engine source files.
- Docs: Requirements section is less of a mess
- Docs: Changed Tidy Guide to a link to a separate Clang Tidy Guide
### Removed
- clang-tidy: removed -readability-static-accessed-through-instance to default config when created. Added because of Tidy crash in Lyra that's fixed in UE5.3. It was also the wrong way to fix the Check that caused the crash.

## [2.2.1] - 2023-10-21
### Changed
Expand Down
250 changes: 110 additions & 140 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "unreal-clangd",
"displayName": "Unreal Clangd",
"description": "clangd helper for UE 5.2+",
"version": "2.2.1",
"version": "2.3.0",
"engines": {
"vscode": "^1.77.3"
},
Expand Down
24 changes: 6 additions & 18 deletions src/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export function addDynamicDefaultSettingsToConfig(mainWorkspace: vscode.Workspac
return true;
}

const vscodeFolderPath = compileCommandsDirUri.fsPath;

if(configSettings.clangd?.settings.path?.value !== undefined){
configSettings.clangd.settings.path.value = clangdPath;
}
Expand All @@ -27,17 +25,6 @@ export function addDynamicDefaultSettingsToConfig(mainWorkspace: vscode.Workspac
return true;
}

const args = configSettings.clangd?.settings.arguments?.value;
if (args instanceof Array) {
args.push(`-compile-commands-dir=${vscodeFolderPath}`);
}
else{
console.error("Couldn't get clangd settings args!");
return true;
}

addSettingsToClangdCfg(mainWorkspace);

return false;
}

Expand Down Expand Up @@ -70,14 +57,15 @@ function addToClangdAdd(clangdExtYamlFiles: ExtensionYamlFiles, addition: string
}
}

function addSettingsToClangdCfg(mainWorkspace: vscode.WorkspaceFolder) {
export function addSettingsToClangdCfg(mainWorkspace: vscode.WorkspaceFolder, defaultClangdCfgSettings: ClangdCfgFileSettings, ccPath: string) {

defaultClangdCfgSettings.CompileFlags.CompilationDatabase = ccPath.replaceAll("\\", '/'); // Only foward slashes allowed

const unrealClangdCfg = vscode.workspace.getConfiguration(consts.CONFIG_SECTION_UNREAL_CLANGD, mainWorkspace);
const compilerPath = unrealClangdCfg.get<string>(consts.settingNames.unrealClangd.settings["creation.compilerPath"]);

if(!compilerPath){
return;
if(compilerPath){
defaultClangdCfgSettings.CompileFlags.Compiler = compilerPath.replaceAll("\\", '/'); // Only foward slashes allowed
}

consts.defaultGeneralClangdCfgSettings.CompileFlags.Compiler = compilerPath;

}
13 changes: 9 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ export async function activate(context: vscode.ExtensionContext) {
console.error(tr.COULDNT_GET_CLANG_TIDY_SETTINGS);
return;
}
const clangdExtYamlFiles: typ.ExtensionYamlFiles = getDefaultClangdExtYamlFiles(projectInfo, isClangTidyEnabled);

const defaultClangdCfgSettings = consts.defaultGeneralClangdCfgSettings;
dyn.addSettingsToClangdCfg(mainWorkspaceFolder, defaultClangdCfgSettings, getCompileCommandsPath(mainWorkspaceFolder.uri, {withFileName: false}).fsPath);

const clangdExtYamlFiles: typ.ExtensionYamlFiles = getDefaultClangdExtYamlFiles(projectInfo, defaultClangdCfgSettings, isClangTidyEnabled);

const defaultCfgSettings: typ.AllDefaultSettings = consts.defaultConfigSettings;

Expand Down Expand Up @@ -1464,7 +1468,7 @@ async function isUnrealProject(): Promise<boolean> {
}


function getDefaultClangdExtYamlFiles(projectInfo: typ.ProjectInfoVars, isTidyEnabled: boolean): typ.ExtensionYamlFiles {
function getDefaultClangdExtYamlFiles(projectInfo: typ.ProjectInfoVars, defaultClangdCfgSettings: typ.ClangdCfgFileSettings, isTidyEnabled: boolean): typ.ExtensionYamlFiles {

let pathMatch : string[] = [consts.CLANGD_PATHMATCH_COMPLETION_HELPER_PATH]; // Add completionHelper.cpp to .clangd file

Expand All @@ -1476,12 +1480,13 @@ function getDefaultClangdExtYamlFiles(projectInfo: typ.ProjectInfoVars, isTidyEn
}

}
consts.defaultGeneralClangdCfgSettings.If.PathMatch = pathMatch;

defaultClangdCfgSettings.If.PathMatch = pathMatch;

const installFolders = [projectInfo.mainWorkspaceFolder.uri];

const clangdCfgFile: typ.YamlFile = {
docObjects: [consts.defaultGeneralClangdCfgSettings],
docObjects: [defaultClangdCfgSettings],
stringifyOptions: consts.CLANGD_STRINGIFY_OPTIONS,
installFolders: installFolders,
topComment: "",
Expand Down
13 changes: 8 additions & 5 deletions src/libs/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AllDefaultSettings, AllSettingNames, CCppDefaultSettings, CCppSettingNa
import type { ClangdCfgFileSettings, CompileFlags, ClangArgWithValue } from "./types";
import type { Overwrite } from './indexTypes';

export const EXTENSION_VERSION = "2.2.1";
export const EXTENSION_VERSION = "2.3.0";
export const VALIDATE_UNREAL_VERSIONS: { min: ueHelpers.UnrealVersion, max: ueHelpers.UnrealVersion } =
{ min: { major: 5, minor: 2, patch: 0 }, max: { major: 6, minor: 0, patch: 0 } }; // The unreal versions this extension was created for

Expand Down Expand Up @@ -150,7 +150,7 @@ export const CLANGD_STRINGIFY_OPTIONS = {directives: true};
export const CLANG_FORMAT_STRINGIFY_OPTIONS = {directives: true};
export const CLANG_TIDY_STRINGIFY_OPTIONS = {directives: true};

export const UPDATE_COMPILE_COMMANDS_ARG_DEVELOPMENT = "Development";
export const UPDATE_COMPILE_COMMANDS_ARG_DEVELOPMENT = "DebugGame";
export const UPDATE_COMPILE_COMMANDS_ARG_GEN_CLANGDB = "-mode=GenerateClangDataBase";
export const UPDATE_COMPILE_COMMANDS_ARG_ARCHITECTURE_EMPTY = "-architecture=";
//export const UPDATE_COMPILE_COMMANDS_DBGCFG_ARG
Expand Down Expand Up @@ -256,7 +256,8 @@ export const defaultConfigSettings: AllDefaultSettings = {
export const defaultCompilerFlags: CompileFlags = {
"Add": [
"-D__INTELLISENSE__"
]
],
"CompilationDatabase" : ""
};

const defaultInlayHints: InlayHintsFlags = {
Expand All @@ -273,7 +274,7 @@ export const defaultGeneralClangdCfgSettings: ClangdCfgFileSettings = {
};

export const defaultGeneralClangTidySettings: ClangTidyFileSettings = {
Checks: "-*,\nreadability-*,\n-readability-static-accessed-through-instance,\ncppcoreguidelines-*,\nbugprone-*,\nmodernize-*,\nperformance-*,\nmisc-*",
Checks: "-*,\nreadability-*,\ncppcoreguidelines-*,\nbugprone-*,\nmodernize-*,\nperformance-*,\nmisc-*",
CheckOptions: [{key: "readability-function-cognitive-complexity.Threshold", value: 25}],
FormatStyle: "file"
};
Expand All @@ -285,7 +286,9 @@ export const defaultGeneralClangFormatFile: ClangFormatFileSettings = {
ColumnLimit: 120,
IndentWidth: 4,
SortIncludes: "false",
AccessModifierOffset: -4
AccessModifierOffset: -4,
NamespaceIndentation: "All"

};

export const completionHelperCppContent = "/*\n" +
Expand Down
16 changes: 9 additions & 7 deletions src/libs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ export interface ClangTidyFileSettings {

export interface ClangFormatFileSettings {
"BasedOnStyle": "LLVM",
"UseTab": "Never"
"IndentWidth": 2 | 4
"ColumnLimit": 80 | 100 | 120
"SortIncludes": "false" | "true"
"BreakBeforeBraces": "Allman"
"AccessModifierOffset": -4
"UseTab": "Never",
"IndentWidth": 2 | 4,
"ColumnLimit": 80 | 100 | 120,
"SortIncludes": "false" | "true",
"BreakBeforeBraces": "Allman",
"AccessModifierOffset": -4,
"NamespaceIndentation": "All"

}

export interface CompileCommands {
Expand Down Expand Up @@ -209,7 +211,7 @@ export type VSCodeSettingValues = string | string[] | ClangArgWithValue[] | bool
// [settingName: string]: { value: VSCodeSettingValues, configTarget: ConfigurationTarget | undefined }
// };

export type ClangArgs = "-compile-commands-dir" | "-header-insertion" | "-all-scopes-completion" | "-limit-results"
export type ClangArgs = "-header-insertion" | "-all-scopes-completion" | "-limit-results"
| "-header-insertion-decorators" | "-completion-style" | "-background-index" | "-limit-references"
| "-function-arg-placeholders";
export type ClangArgWithValue = `${ClangArgs}=${string}`;
Expand Down

0 comments on commit 1814677

Please sign in to comment.