From a44b7ddd1c89af7b2af5664122e2abb619977661 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Mon, 14 Oct 2019 09:18:29 +0200 Subject: [PATCH] add vscode installation and config (fix #2) --- README.md | 20 +++++- defaults/main.yml | 5 ++ files/vscode-settings.json | 137 +++++++++++++++++++++++++++++++++++++ tasks/vscode-Archlinux.yml | 35 ++++++++++ tasks/vscode-Darwin.yml | 35 ++++++++++ tasks/vscode-Debian.yml | 37 ++++++++++ tasks/vscode.yml | 49 +++++++++++++ 7 files changed, 315 insertions(+), 3 deletions(-) create mode 100644 files/vscode-settings.json create mode 100644 tasks/vscode-Archlinux.yml create mode 100644 tasks/vscode-Darwin.yml create mode 100644 tasks/vscode-Debian.yml create mode 100644 tasks/vscode.yml diff --git a/README.md b/README.md index 3fb54c0..80d79a0 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/defaults/main.yml b/defaults/main.yml index 2c3e830..195adb2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/files/vscode-settings.json b/files/vscode-settings.json new file mode 100644 index 0000000..2c212e1 --- /dev/null +++ b/files/vscode-settings.json @@ -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+" +} \ No newline at end of file diff --git a/tasks/vscode-Archlinux.yml b/tasks/vscode-Archlinux.yml new file mode 100644 index 0000000..ca58fde --- /dev/null +++ b/tasks/vscode-Archlinux.yml @@ -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 diff --git a/tasks/vscode-Darwin.yml b/tasks/vscode-Darwin.yml new file mode 100644 index 0000000..02c06dc --- /dev/null +++ b/tasks/vscode-Darwin.yml @@ -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 diff --git a/tasks/vscode-Debian.yml b/tasks/vscode-Debian.yml new file mode 100644 index 0000000..8c5e0e4 --- /dev/null +++ b/tasks/vscode-Debian.yml @@ -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 diff --git a/tasks/vscode.yml b/tasks/vscode.yml new file mode 100644 index 0000000..906ef3c --- /dev/null +++ b/tasks/vscode.yml @@ -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