add vscode installation and config (fix #2)

This commit is contained in:
Jannik Beyerstedt 2019-10-14 09:18:29 +02:00
parent 5b133da522
commit a44b7ddd1c
7 changed files with 315 additions and 3 deletions

View File

@ -16,9 +16,17 @@ Role Variables
This role uses the apt package manager on Debian based hosts.
But for some operating systems the `ansible_os_family` variable is not set to "Debian" by the fact gathering even if it is Debian based (like Mendel GNU/Linux on the Google Coral Dev Board).
- `override_os_family`: Set to "Debian" in the host inventory, if `ansible_os_family` is not set correctly
The User Setup will change the user shell and global gitconfig. This can be disabled:
- `usersetup_chsh`: Boolean to disable changing the user shell to zsh
- `usersetup_gitconfig`: Boolean to disable overriding the global gitconfig
For a GUI/ Desktop machine, you can enable to install and configure VS Code:
- `user_vscode`: Boolean to install and set the basic configuration of VS Code
- `user_vscode_cpp`: Boolean to install C/C++ dev tools and configure VS Code
- `user_vscode_python`: Boolean to install Python dev tools and configure VS Code
Dependencies
------------
@ -57,11 +65,17 @@ You can simply run the whole role:
name: common
tasks_from: usersettings
# just for you main machine
- name: Basics - Install dotfiles
# just for you main machine (not included in the role's main.yml)
- name: Basics - Install user's working utilities
import_role:
name: common
tasks_from: usertools
# (not included in the role's main.yml)
- name: Basics - Install and configure VS Code
import_role:
name: common
tasks_from: vscode
```
Or call the different tasks individually:

View File

@ -6,3 +6,8 @@ usersetup_chsh: true
# override global gitconfig
usersetup_gitconfig: true
# install VS Code and selectively activate different programming languages
user_vscode: false
user_vscode_cpp: false
user_vscode_python: false

137
files/vscode-settings.json Normal file
View File

@ -0,0 +1,137 @@
{
"terminal.integrated.fontFamily": "Hack",
// "C_Cpp.clang_format_style": "{BasedOnStyle: LLVM, Language: Cpp, IndentWidth: 2, ColumnLimit: 110, BreakBeforeBraces: Attach, PointerAlignment: Left, AccessModifierOffset: -2, Cpp11BracedListStyle: true, AlignConsecutiveDeclarations: true, AlignConsecutiveAssignments: true, AlignEscapedNewlines: Left, AlignTrailingComments: true, IndentWrappedFunctionNames: false, AllowShortFunctionsOnASingleLine: Inline, SpacesBeforeTrailingComments: 2, FixNamespaceComments: true, ReflowComments: false, SortIncludes: false, SortUsingDeclarations: false}",
"C_Cpp.clang_format_style": "file",
"C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: LLVM, Language: Cpp, IndentWidth: 2, ColumnLimit: 110, BreakBeforeBraces: Attach, PointerAlignment: Left, AccessModifierOffset: -2, Cpp11BracedListStyle: true, AlignConsecutiveDeclarations: true, AlignConsecutiveAssignments: true, AlignEscapedNewlines: Left, AlignTrailingComments: true, IndentWrappedFunctionNames: false, AllowShortFunctionsOnASingleLine: Inline, SpacesBeforeTrailingComments: 2, FixNamespaceComments: true, ReflowComments: false, SortIncludes: false, SortUsingDeclarations: false}",
"C_Cpp.clang_format_path": "/usr/local/bin/clang-format",
"C_Cpp.intelliSenseEngine": "Tag Parser",
"editor.tabSize": 2,
"editor.renderWhitespace": "boundary",
"editor.minimap.enabled": false,
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.multiCursorModifier": "ctrlCmd",
"[json]": {
"editor.tabSize": 4
},
"[python]": {
"editor.tabSize": 4
},
"[html]": {
"editor.formatOnSave": false
},
"[plaintext]": {
"editor.tabSize": 2,
"editor.formatOnSave": false
},
"[latex]": {
"editor.formatOnSave": false,
"editor.wordWrap": "on"
},
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.pythonPath": "/usr/local/bin/python3",
"window.zoomLevel": 0,
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.recipes": [
{
"name": "latexmk 🔃",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex, biber, makeglossaries, pdflatex x2",
"tools": [
"pdflatex",
"biber",
"makeglossaries",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "makeglossaries",
"command": "makeglossaries",
"args": [
"%DOCFILE%"
]
},
{
"name": "biber",
"command": "biber",
"args": [
"%DOCFILE%"
],
"env": {}
}
],
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk",
"*.bcf",
"*.dvi",
"*.glsdefs",
"*.nlo",
"*.run.xml",
"*.slo",
"*.lol",
"*.ilg",
"*.nls",
"*.synctex.gz",
"*.slg",
"*.sls"
],
"markdown-pdf.displayHeaderFooter": false,
"markdown-pdf.margin.bottom": "1.5cm",
"markdown-pdf.margin.left": "2cm",
"markdown-pdf.margin.right": "1.5cm",
"debug.allowBreakpointsEverywhere": true,
"latex-workshop.latex.autoBuild.run": "never",
"git.confirmSync": false,
"explorer.confirmDelete": false,
"extensions.ignoreRecommendations": true,
"workbench.colorTheme": "Default Light+"
}

View File

@ -0,0 +1,35 @@
---
# Common/VSCode: Install and Configure VS Code - ArchLinux Version
# Install Visual Studio Code and Set Basic Configuration
- name: vscode - Basics
block:
- name: vscode - Basics - Install
package:
name: "{{ packages }}"
state: present
vars:
packages:
- visual-studio-code
- name: vscode - Basics - Copy global settings
copy:
src: "{{ role_path }}/files/vscode-settings.json"
dest: ~/.config/Code/User/settings.json
when: user_vscode == true
# VS Code - C/C++ Development Tools
- name: vscode - C/C++
block:
- name: vscode - C/C++ - Install developer tools
package:
name: "{{ packages }}"
state: latest
vars:
packages:
- clang-format
when: user_vscode == true and user_vscode_cpp == true
# VS Code - Python Development Tools
# all done in vscode.yml

35
tasks/vscode-Darwin.yml Normal file
View File

@ -0,0 +1,35 @@
---
# Common/VSCode: Install and Configure VS Code - macOS Version
# Install Visual Studio Code and Set Basic Configuration
- name: vscode - Basics
block:
- name: vscode - Basics - Install
homebrew_cask:
name: "{{ packages }}"
state: present
vars:
packages:
- visual-studio-code
- name: vscode - Basics - Copy global settings
copy:
src: "{{ role_path }}/files/vscode-settings.json"
dest: ~/Library/Application Support/Code/User/settings.json
when: user_vscode == true
# VS Code - C/C++ Development Tools
- name: vscode - C/C++
block:
- name: vscode - C/C++ - Install developer tools
homebrew:
name: "{{ packages }}"
state: latest
vars:
packages:
- clang-format
when: user_vscode == true and user_vscode_cpp == true
# VS Code - Python Development Tools
# all done in vscode.yml

37
tasks/vscode-Debian.yml Normal file
View File

@ -0,0 +1,37 @@
---
# Common/VSCode: Install and Configure VS Code - Debian Version
# Install Visual Studio Code and Set Basic Configuration
- name: vscode - Basics
block:
- name: vscode - Basics - Install
become: yes
package:
name: "{{ packages }}"
state: present
vars:
packages:
- visual-studio-code
- name: vscode - Basics - Copy global settings
copy:
src: "{{ role_path }}/files/vscode-settings.json"
dest: ~/.config/Code/User/settings.json
when: user_vscode == true
# VS Code - C/C++ Development Tools
- name: vscode - C/C++
block:
- name: vscode - C/C++ - Install developer tools
become: yes
package:
name: "{{ packages }}"
state: latest
vars:
packages:
- clang-format
when: user_vscode == true and user_vscode_cpp == true
# VS Code - Python Development Tools
# all done in vscode.yml

49
tasks/vscode.yml Normal file
View File

@ -0,0 +1,49 @@
---
# Common/VSCode: Install and Configure VS Code
- name: vscode - Install and configure VS Code
include_tasks: "{{ item }}"
with_first_found:
- "vscode-{{ ansible_distribution }}.yml"
- "vscode-{{ (override_os_family is defined) | ternary(override_os_family,ansible_os_family) }}.yml"
# Install Visual Studio Code and Set Basic Configuration
- name: vscode - Basics
block:
- name: vscode - Basics - Configure
shell: |
PATH=/usr/local/bin:$PATH
code --install-extension chiehyu.vscode-astyle
code --install-extension editorconfig
code --install-extension yzane.markdown-pdf
# code --install-extension james-yu.latex-workshop
# code --install-extension ban.spellright
when: user_vscode == true
# VS Code - C/C++ Development Tools
- name: vscode - C/C++
block:
- name: vscode - C/C++ - Configure VS Code
shell: |
PATH=/usr/local/bin:$PATH
code --install-extension ms-vscode.cpptools
when: user_vscode == true and user_vscode_cpp == true
# VS Code - Python Development Tools
- name: vscode - Python
block:
- name: vscode - Python - Install python dev packages
pip:
name:
- autopep8
- pylint
executable: /usr/local/bin/pip3
- name: vscode - Python - Configure VS Code
shell: |
PATH=/usr/local/bin:$PATH
code --install-extension ms-python.python
when: user_vscode == true and user_vscode_python == true