add: vscode user's set
This commit is contained in:
		
							parent
							
								
									cdd7ad932b
								
							
						
					
					
						commit
						adf02ff8ce
					
				
							
								
								
									
										68
									
								
								cpp/vscode/install.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								cpp/vscode/install.ps1
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
			
		||||
# 确定文件源
 | 
			
		||||
$sourceFiles = @("keybindings.json", "settings.json")
 | 
			
		||||
 | 
			
		||||
# 获取当前用户目录
 | 
			
		||||
$userProfile = [System.Environment]::GetFolderPath("UserProfile")
 | 
			
		||||
 | 
			
		||||
# 确定目标路径
 | 
			
		||||
switch ($env:OS) {
 | 
			
		||||
    "Windows_NT" {
 | 
			
		||||
        $targetPath = Join-Path -Path $userProfile -ChildPath "AppData\Roaming\Code\User"
 | 
			
		||||
    }
 | 
			
		||||
    "Unix" {
 | 
			
		||||
        if (Test-Path "$userProfile/.config/Code/User") {
 | 
			
		||||
            $targetPath = Join-Path -Path $userProfile -ChildPath ".config/Code/User"
 | 
			
		||||
        } else {
 | 
			
		||||
            Write-Host "目标目录 $userProfile/.config/Code/User 不存在"
 | 
			
		||||
            exit
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    "Darwin" {
 | 
			
		||||
        $targetPath = Join-Path -Path $userProfile -ChildPath "Library/Application Support/Code/User"
 | 
			
		||||
    }
 | 
			
		||||
    default {
 | 
			
		||||
        Write-Host "不支持的操作系统"
 | 
			
		||||
        exit
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# 确保目标路径存在
 | 
			
		||||
if (-not (Test-Path -Path $targetPath)) {
 | 
			
		||||
    Write-Host "目标路径 $targetPath 不存在"
 | 
			
		||||
    exit
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# 获取当前日期,不包括年份
 | 
			
		||||
$dateString = (Get-Date).ToString("MMddHHmmss")
 | 
			
		||||
 | 
			
		||||
# 遍历源文件并复制
 | 
			
		||||
foreach ($file in $sourceFiles) {
 | 
			
		||||
    $sourceFilePath = Join-Path -Path $PSScriptRoot -ChildPath $file
 | 
			
		||||
    $destinationFilePath = Join-Path -Path $targetPath -ChildPath $file
 | 
			
		||||
    
 | 
			
		||||
    # 打印源路径和目标路径
 | 
			
		||||
    Write-Host "源文件路径: $sourceFilePath"
 | 
			
		||||
    Write-Host "目标文件路径: $destinationFilePath"
 | 
			
		||||
	Write-Host ""
 | 
			
		||||
    
 | 
			
		||||
    if (Test-Path -Path $sourceFilePath) {
 | 
			
		||||
        if (Test-Path -Path $destinationFilePath) {
 | 
			
		||||
            # 如果目标路径下文件存在,重命名现有文件
 | 
			
		||||
            $fileBaseName = [System.IO.Path]::GetFileNameWithoutExtension($destinationFilePath)
 | 
			
		||||
			Write-Host "fileBaseName: $fileBaseName"
 | 
			
		||||
            $fileExtension = [System.IO.Path]::GetExtension($destinationFilePath)
 | 
			
		||||
			Write-Host "fileExtension: $fileExtension"
 | 
			
		||||
			$newFileName = "${fileBaseName}_${dateString}${fileExtension}"
 | 
			
		||||
			Write-Host "newFileName: $newFileName"
 | 
			
		||||
            $newFilePath = Join-Path -Path $targetPath -ChildPath $newFileName
 | 
			
		||||
            Rename-Item -Path $destinationFilePath -NewName $newFilePath
 | 
			
		||||
            Write-Host "已重命名原文件为: $newFilePath"
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        # 复制新文件
 | 
			
		||||
        Copy-Item -Path $sourceFilePath -Destination $destinationFilePath -Force
 | 
			
		||||
        Write-Host "已复制 $file 到 $targetPath"
 | 
			
		||||
    } else {
 | 
			
		||||
        Write-Host "源文件 $sourceFilePath 不存在"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								cpp/vscode/keybindings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								cpp/vscode/keybindings.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "command": "cmake.debugTarget",
 | 
			
		||||
        "key": "F5",
 | 
			
		||||
        "when": "cmake:enableFullFeatureSet && inCMakeProject && !cmake:hideDebugCommand && !inDebugMode"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "command": "editor.action.revealDefinition",
 | 
			
		||||
        "key": "ALT+G",
 | 
			
		||||
        "when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										43
									
								
								cpp/vscode/settings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								cpp/vscode/settings.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
			
		||||
{
 | 
			
		||||
    "cmake.showOptionsMovedNotification": false,
 | 
			
		||||
    "cmake.pinnedCommands": [
 | 
			
		||||
        "workbench.action.tasks.configureTaskRunner",
 | 
			
		||||
        "workbench.action.tasks.runTask"
 | 
			
		||||
    ],
 | 
			
		||||
    "editor.lineNumbers": "relative",
 | 
			
		||||
    "vim.leader": "<space>",
 | 
			
		||||
    "vim.useSystemClipboard": true,
 | 
			
		||||
    "vim.useCtrlKeys": true,
 | 
			
		||||
    "vim.normalModeKeyBindings": [
 | 
			
		||||
        {
 | 
			
		||||
            "before": [
 | 
			
		||||
                "<leader>",
 | 
			
		||||
                "g",
 | 
			
		||||
                "c"
 | 
			
		||||
            ],
 | 
			
		||||
            "commands": ["workbench.action.showCommands"],
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "before": [
 | 
			
		||||
                "<leader>",
 | 
			
		||||
                "c",
 | 
			
		||||
                "f"
 | 
			
		||||
            ],
 | 
			
		||||
            "commands": ["editor.action.formatDocument"]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "before": [
 | 
			
		||||
                "<leader>",
 | 
			
		||||
                "j",
 | 
			
		||||
            ],
 | 
			
		||||
            "commands": ["workbench.action.togglePanel"]        
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "before": [
 | 
			
		||||
                "g",
 | 
			
		||||
                "d"
 | 
			
		||||
            ],
 | 
			
		||||
            "commands": ["editor.action.revealDefinition"]
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user