Tasks Shell Input Extension
https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input
-
If you don't have
.vscodedirectory in you NSC directory yet:git clone https://github.com/doki-nordic/vscode_conf_for_ncs.git .vscode
-
If you already have
.vscodedirectory with configuration that you want to keep:mv .vscode _vscode_tmp git clone https://github.com/doki-nordic/vscode_conf_for_ncs.git .vscode # Now, try to merge your settings from "_vscode_tmp" into ".vscode". # You can use e.g. "meld" tool: meld _vscode_tmp .vscode # And delete "_vscode_tmp" when you are done. rm -Rf _vscode_tmp
After installation, you should see .vscode directory alongside with the nrf, zephyr, nrfxlib, e.t.c. You can now open NCS directory in VSCode and you can start any of the implemented tasks.
Add simple keyboard shortcut to show list of tasks. I am using
Pause/Breakkey.
- Open
File->Preferences->Keyboard shortcuts.- Type
workbench.action.tasks.runTaskto findTasks: Run Taskaction.- Double click it.
- Press key that you want to use (e.g.
Pause/Break). VSCode will show a message if it is already in use by other action.
example:change folder- change folder of current exampleFrom currenly opened CMakeLists.txt- if folder is not visible on the list, openCMakeLists.txtfile from the example folder and select this option.
change board- change current example boardFrom currenly opened board yaml file- if board is not visible on the list, open boardyamlfile and select this option.
build- build current examplerebuild- rebuild (clean and build) current examplepurge- delete build directory and rebuild current exampleflash- build and flash current examplemenuconfig- start menuconfig for current exampleguiconfig- start guiconfig for current examplechange arguments- add custom west build arguments. It has some issues - may not work.[[empty]]- no additional argumentsFrom terminal- prompt will be shown on terminal panel to provide the arguments
checkpatch:run- run check patch. You will be asked to select a repository and a branch that will be used as base for git compare.add git base- allows you to add new base branch in terminal panel
terminal- connect to board serial port in the terminal panelvscode:new instance- create a new independent instance of the Visual Studio Code that is able to open the same folder and select different example.hide comments- toggle color of the comment to almost invisible.
doc:rebuild- delete documetation build directory, rectreate it with CMake and build it.build- build the NCS documentation (requires that the build directory already exists and CMake was already called).build current file- determinate docset that contains currently opened file and build only this docset.server- start local HTTP server that serves current build output. Page content will be automatically reloaded if one of the above tasks was executed.
nrf_rpc_gen:regenerate this file- run nrf_rpc_generator on currenty opened file
-
Install Trigger Task on Save Extension
https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.triggertaskonsave -
Configure it to start docs build of recently saved file, e.g.:
"triggerTaskOnSave.tasks": { "doc: build current file": [ "**/*.rst", "**/*.h", "**/Kconfig*" ] }, "triggerTaskOnSave.showStatusBarToggle": true, "triggerTaskOnSave.resultIndicator": "statusBar.background", "triggerTaskOnSave.failureColour": "#800000", "triggerTaskOnSave.successColour": "#008800", "triggerTaskOnSave.restart": true,
-
Disable
Trigger Task on Saveusing button on status bar. -
Rebuild the docuemntatio if you have not already do that with
docs:rebuildtask. -
Start docs server with the
docs: servertask. -
Open file and build it with
docs: build current filetask. -
You can now reenable
Trigger Task on Saveon your status bar. -
Make some change in the file and save it.
Bacause of some issue in
Trigger Task on Saveextension, you have to startdocs: build current fileat least once before you enable this extension with the button on the status bar.
Tasks:
- Put Python tasks in a new file in the
.vscode/srcdirectory. - For each task create a new function. Function name must be unique, because task will be identified using this name.
- Add special docstring describing the task.
'''! task label, option 1, option 2, ... command line arguments '''task labelis any label you wantoptionsare currently:gcc- use gcc problem matcher for the task outputicon=xyz- set task icon, list of icons: https://code.visualstudio.com/api/references/icons-in-labels
command line arguments- arguments passed over command line. You can use vscode variables, e.g.${fileDirname}or${input:xyz}. You can useargv(n)fromcommonmodule to access arguments (nis zero-based and starts at the first argument ofcommand line arguments)- You can define multiple tasks for one function
- Run
tasks.pyor run taskvscode: refresh tasksin vscode to refreshtasks.json.
Inputs:
- Input is a function that has special docstring:
'''!input''' - It prints possible values one per line.
- Can be referenced in command line as
${input:your_function_name} - Other types of inputs:
- User input:
def func(): '''! input Please type your input: ''' pass - Static list pick:
def func(): '''! input Please select you number: One Two Three Four ''' pass
- User input: