diff --git a/README.md b/README.md index 6d864e5..f825461 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,22 @@ - [Quick Start](#quick-start) - [Docs](#docs) -##About +## About -VimsCode is IDE with vim for beginner or expert +VimsCode is an IDE with vim for beginner or expert -* VimsCode use arduino cli and espressif cli for code +* VimsCode use arduino-cli, idf-esp and platform.io-cli for remplace VScode only in terminal * Very easy to use * Very easy to install + + ![Example-picture](/pictures/image.png) -##Quick Start +## Quick Start 1. Introduction: - Installation requires [Git] and triggers [`git clone`] for each configured repository to ~/.vim/ by defautl. - - ![Example-picture](/pictures/image.png) + Installation requires git, wget, flex, bison, gperf, python3, python3-venv, cmake, ninja-build, ccache, libffi-dev, libssl-dev, dfu-util, libusb-1.0-0] + and triggers [`git clone`] for each configured repository to ~/.vim/ by defautl. 2. Set up VimsCode @@ -30,6 +31,6 @@ VimsCode is IDE with vim for beginner or expert Launch `vim` and run `:PluginInstall` -##Docs +## Docs https://projets.cohabit.fr/redmine/projects/accueil/wiki/Documentation_IDE_Vim diff --git a/ide-cli/arduino-cli/arduino-cli b/ide-cli/arduino-cli/arduino-cli new file mode 100755 index 0000000..550e83a Binary files /dev/null and b/ide-cli/arduino-cli/arduino-cli differ diff --git a/ide-cli/arduino-cli/completion/arduino-cli-zsh b/ide-cli/arduino-cli/completion/arduino-cli-zsh new file mode 100644 index 0000000..83ac92b --- /dev/null +++ b/ide-cli/arduino-cli/completion/arduino-cli-zsh @@ -0,0 +1,177 @@ +#compdef _arduino-cli arduino-cli + +# zsh completion for arduino-cli -*- shell-script -*- + +__arduino-cli_debug() +{ + local file="$BASH_COMP_DEBUG_FILE" + if [[ -n ${file} ]]; then + echo "$*" >> "${file}" + fi +} + +_arduino-cli() +{ + local shellCompDirectiveError=1 + local shellCompDirectiveNoSpace=2 + local shellCompDirectiveNoFileComp=4 + local shellCompDirectiveFilterFileExt=8 + local shellCompDirectiveFilterDirs=16 + + local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace + local -a completions + + __arduino-cli_debug "\n========= starting completion logic ==========" + __arduino-cli_debug "CURRENT: ${CURRENT}, words[*]: ${words[*]}" + + # The user could have moved the cursor backwards on the command-line. + # We need to trigger completion from the $CURRENT location, so we need + # to truncate the command-line ($words) up to the $CURRENT location. + # (We cannot use $CURSOR as its value does not work when a command is an alias.) + words=("${=words[1,CURRENT]}") + __arduino-cli_debug "Truncated words[*]: ${words[*]}," + + lastParam=${words[-1]} + lastChar=${lastParam[-1]} + __arduino-cli_debug "lastParam: ${lastParam}, lastChar: ${lastChar}" + + # For zsh, when completing a flag with an = (e.g., arduino-cli -n=) + # completions must be prefixed with the flag + setopt local_options BASH_REMATCH + if [[ "${lastParam}" =~ '-.*=' ]]; then + # We are dealing with a flag with an = + flagPrefix="-P ${BASH_REMATCH}" + fi + + # Prepare the command to obtain completions + requestComp="${words[1]} __complete ${words[2,-1]}" + if [ "${lastChar}" = "" ]; then + # If the last parameter is complete (there is a space following it) + # We add an extra empty parameter so we can indicate this to the go completion code. + __arduino-cli_debug "Adding extra empty parameter" + requestComp="${requestComp} \"\"" + fi + + __arduino-cli_debug "About to call: eval ${requestComp}" + + # Use eval to handle any environment variables and such + out=$(eval ${requestComp} 2>/dev/null) + __arduino-cli_debug "completion output: ${out}" + + # Extract the directive integer following a : from the last line + local lastLine + while IFS='\n' read -r line; do + lastLine=${line} + done < <(printf "%s\n" "${out[@]}") + __arduino-cli_debug "last line: ${lastLine}" + + if [ "${lastLine[1]}" = : ]; then + directive=${lastLine[2,-1]} + # Remove the directive including the : and the newline + local suffix + (( suffix=${#lastLine}+2)) + out=${out[1,-$suffix]} + else + # There is no directive specified. Leave $out as is. + __arduino-cli_debug "No directive found. Setting do default" + directive=0 + fi + + __arduino-cli_debug "directive: ${directive}" + __arduino-cli_debug "completions: ${out}" + __arduino-cli_debug "flagPrefix: ${flagPrefix}" + + if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then + __arduino-cli_debug "Completion received error. Ignoring completions." + return + fi + + while IFS='\n' read -r comp; do + if [ -n "$comp" ]; then + # If requested, completions are returned with a description. + # The description is preceded by a TAB character. + # For zsh's _describe, we need to use a : instead of a TAB. + # We first need to escape any : as part of the completion itself. + comp=${comp//:/\\:} + + local tab=$(printf '\t') + comp=${comp//$tab/:} + + __arduino-cli_debug "Adding completion: ${comp}" + completions+=${comp} + lastComp=$comp + fi + done < <(printf "%s\n" "${out[@]}") + + if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then + __arduino-cli_debug "Activating nospace." + noSpace="-S ''" + fi + + if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then + # File extension filtering + local filteringCmd + filteringCmd='_files' + for filter in ${completions[@]}; do + if [ ${filter[1]} != '*' ]; then + # zsh requires a glob pattern to do file filtering + filter="\*.$filter" + fi + filteringCmd+=" -g $filter" + done + filteringCmd+=" ${flagPrefix}" + + __arduino-cli_debug "File filtering command: $filteringCmd" + _arguments '*:filename:'"$filteringCmd" + elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then + # File completion for directories only + local subDir + subdir="${completions[1]}" + if [ -n "$subdir" ]; then + __arduino-cli_debug "Listing directories in $subdir" + pushd "${subdir}" >/dev/null 2>&1 + else + __arduino-cli_debug "Listing directories in ." + fi + + local result + _arguments '*:dirname:_files -/'" ${flagPrefix}" + result=$? + if [ -n "$subdir" ]; then + popd >/dev/null 2>&1 + fi + return $result + else + __arduino-cli_debug "Calling _describe" + if eval _describe "completions" completions $flagPrefix $noSpace; then + __arduino-cli_debug "_describe found some completions" + + # Return the success of having called _describe + return 0 + else + __arduino-cli_debug "_describe did not find completions." + __arduino-cli_debug "Checking if we should do file completion." + if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then + __arduino-cli_debug "deactivating file completion" + + # We must return an error code here to let zsh know that there were no + # completions found by _describe; this is what will trigger other + # matching algorithms to attempt to find completions. + # For example zsh can match letters in the middle of words. + return 1 + else + # Perform file completion + __arduino-cli_debug "Activating file completion" + + # We must return the result of this command, so it must be the + # last command, or else we must store its result to return it. + _arguments '*:filename:_files'" ${flagPrefix}" + fi + fi + fi +} + +# don't run the completion function when being source-ed or eval-ed +if [ "$funcstack[1]" = "_arduino-cli" ]; then + _arduino-cli +fi diff --git a/ide-cli/arduino-cli/completion/arduino-cli.sh b/ide-cli/arduino-cli/completion/arduino-cli.sh new file mode 100644 index 0000000..9f18ba9 --- /dev/null +++ b/ide-cli/arduino-cli/completion/arduino-cli.sh @@ -0,0 +1,259 @@ +# bash completion V2 for arduino-cli -*- shell-script -*- + +__arduino-cli_debug() +{ + if [[ -n ${BASH_COMP_DEBUG_FILE:-} ]]; then + echo "$*" >> "${BASH_COMP_DEBUG_FILE}" + fi +} + +# Macs have bash3 for which the bash-completion package doesn't include +# _init_completion. This is a minimal version of that function. +__arduino-cli_init_completion() +{ + COMPREPLY=() + _get_comp_words_by_ref "$@" cur prev words cword +} + +# This function calls the arduino-cli program to obtain the completion +# results and the directive. It fills the 'out' and 'directive' vars. +__arduino-cli_get_completion_results() { + local requestComp lastParam lastChar args + + # Prepare the command to request completions for the program. + # Calling ${words[0]} instead of directly arduino-cli allows to handle aliases + args=("${words[@]:1}") + requestComp="${words[0]} __complete ${args[*]}" + + lastParam=${words[$((${#words[@]}-1))]} + lastChar=${lastParam:$((${#lastParam}-1)):1} + __arduino-cli_debug "lastParam ${lastParam}, lastChar ${lastChar}" + + if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then + # If the last parameter is complete (there is a space following it) + # We add an extra empty parameter so we can indicate this to the go method. + __arduino-cli_debug "Adding extra empty parameter" + requestComp="${requestComp} ''" + fi + + # When completing a flag with an = (e.g., arduino-cli -n=) + # bash focuses on the part after the =, so we need to remove + # the flag part from $cur + if [[ "${cur}" == -*=* ]]; then + cur="${cur#*=}" + fi + + __arduino-cli_debug "Calling ${requestComp}" + # Use eval to handle any environment variables and such + out=$(eval "${requestComp}" 2>/dev/null) + + # Extract the directive integer at the very end of the output following a colon (:) + directive=${out##*:} + # Remove the directive + out=${out%:*} + if [ "${directive}" = "${out}" ]; then + # There is not directive specified + directive=0 + fi + __arduino-cli_debug "The completion directive is: ${directive}" + __arduino-cli_debug "The completions are: ${out[*]}" +} + +__arduino-cli_process_completion_results() { + local shellCompDirectiveError=1 + local shellCompDirectiveNoSpace=2 + local shellCompDirectiveNoFileComp=4 + local shellCompDirectiveFilterFileExt=8 + local shellCompDirectiveFilterDirs=16 + + if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then + # Error code. No completion. + __arduino-cli_debug "Received error from custom completion go code" + return + else + if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then + if [[ $(type -t compopt) = "builtin" ]]; then + __arduino-cli_debug "Activating no space" + compopt -o nospace + else + __arduino-cli_debug "No space directive not supported in this version of bash" + fi + fi + if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then + if [[ $(type -t compopt) = "builtin" ]]; then + __arduino-cli_debug "Activating no file completion" + compopt +o default + else + __arduino-cli_debug "No file completion directive not supported in this version of bash" + fi + fi + fi + + if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then + # File extension filtering + local fullFilter filter filteringCmd + + # Do not use quotes around the $out variable or else newline + # characters will be kept. + for filter in ${out[*]}; do + fullFilter+="$filter|" + done + + filteringCmd="_filedir $fullFilter" + __arduino-cli_debug "File filtering command: $filteringCmd" + $filteringCmd + elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then + # File completion for directories only + + # Use printf to strip any trailing newline + local subdir + subdir=$(printf "%s" "${out[0]}") + if [ -n "$subdir" ]; then + __arduino-cli_debug "Listing directories in $subdir" + pushd "$subdir" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return + else + __arduino-cli_debug "Listing directories in ." + _filedir -d + fi + else + __arduino-cli_handle_standard_completion_case + fi + + __arduino-cli_handle_special_char "$cur" : + __arduino-cli_handle_special_char "$cur" = +} + +__arduino-cli_handle_standard_completion_case() { + local tab comp + tab=$(printf '\t') + + local longest=0 + # Look for the longest completion so that we can format things nicely + while IFS='' read -r comp; do + # Strip any description before checking the length + comp=${comp%%$tab*} + # Only consider the completions that match + comp=$(compgen -W "$comp" -- "$cur") + if ((${#comp}>longest)); then + longest=${#comp} + fi + done < <(printf "%s\n" "${out[@]}") + + local completions=() + while IFS='' read -r comp; do + if [ -z "$comp" ]; then + continue + fi + + __arduino-cli_debug "Original comp: $comp" + comp="$(__arduino-cli_format_comp_descriptions "$comp" "$longest")" + __arduino-cli_debug "Final comp: $comp" + completions+=("$comp") + done < <(printf "%s\n" "${out[@]}") + + while IFS='' read -r comp; do + COMPREPLY+=("$comp") + done < <(compgen -W "${completions[*]}" -- "$cur") + + # If there is a single completion left, remove the description text + if [ ${#COMPREPLY[*]} -eq 1 ]; then + __arduino-cli_debug "COMPREPLY[0]: ${COMPREPLY[0]}" + comp="${COMPREPLY[0]%% *}" + __arduino-cli_debug "Removed description from single completion, which is now: ${comp}" + COMPREPLY=() + COMPREPLY+=("$comp") + fi +} + +__arduino-cli_handle_special_char() +{ + local comp="$1" + local char=$2 + if [[ "$comp" == *${char}* && "$COMP_WORDBREAKS" == *${char}* ]]; then + local word=${comp%"${comp##*${char}}"} + local idx=${#COMPREPLY[*]} + while [[ $((--idx)) -ge 0 ]]; do + COMPREPLY[$idx]=${COMPREPLY[$idx]#"$word"} + done + fi +} + +__arduino-cli_format_comp_descriptions() +{ + local tab + tab=$(printf '\t') + local comp="$1" + local longest=$2 + + # Properly format the description string which follows a tab character if there is one + if [[ "$comp" == *$tab* ]]; then + desc=${comp#*$tab} + comp=${comp%%$tab*} + + # $COLUMNS stores the current shell width. + # Remove an extra 4 because we add 2 spaces and 2 parentheses. + maxdesclength=$(( COLUMNS - longest - 4 )) + + # Make sure we can fit a description of at least 8 characters + # if we are to align the descriptions. + if [[ $maxdesclength -gt 8 ]]; then + # Add the proper number of spaces to align the descriptions + for ((i = ${#comp} ; i < longest ; i++)); do + comp+=" " + done + else + # Don't pad the descriptions so we can fit more text after the completion + maxdesclength=$(( COLUMNS - ${#comp} - 4 )) + fi + + # If there is enough space for any description text, + # truncate the descriptions that are too long for the shell width + if [ $maxdesclength -gt 0 ]; then + if [ ${#desc} -gt $maxdesclength ]; then + desc=${desc:0:$(( maxdesclength - 1 ))} + desc+="…" + fi + comp+=" ($desc)" + fi + fi + + # Must use printf to escape all special characters + printf "%q" "${comp}" +} + +__start_arduino-cli() +{ + local cur prev words cword split + + COMPREPLY=() + + # Call _init_completion from the bash-completion package + # to prepare the arguments properly + if declare -F _init_completion >/dev/null 2>&1; then + _init_completion -n "=:" || return + else + __arduino-cli_init_completion -n "=:" || return + fi + + __arduino-cli_debug + __arduino-cli_debug "========= starting completion logic ==========" + __arduino-cli_debug "cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}, cword is $cword" + + # The user could have moved the cursor backwards on the command-line. + # We need to trigger completion from the $cword location, so we need + # to truncate the command-line ($words) up to the $cword location. + words=("${words[@]:0:$cword+1}") + __arduino-cli_debug "Truncated words[*]: ${words[*]}," + + local out directive + __arduino-cli_get_completion_results + __arduino-cli_process_completion_results +} + +if [[ $(type -t compopt) = "builtin" ]]; then + complete -o default -F __start_arduino-cli arduino-cli +else + complete -o default -o nospace -F __start_arduino-cli arduino-cli +fi + +# ex: ts=4 sw=4 et filetype=sh diff --git a/ide-cli/arduino-cli/help b/ide-cli/arduino-cli/help new file mode 100644 index 0000000..7f09cbe --- /dev/null +++ b/ide-cli/arduino-cli/help @@ -0,0 +1,9 @@ +# exec arduino-cli +mv arduino-cli /usr/bin + + + +# autocomplétion arduino-cli +mkdir /etc/bash_completion.d/ or mkdir ~/completion_zsh/ +iadd fpath=($HOME/completion_zsh $fpath) at the beginning of your ~/.zshrc file # only if you use zsh +mv arduino-cli.sh /etc/bash_completion.d/ or mv _arduino-cli ~/completion_zsh/ diff --git a/ide-cli/idf-esp/help b/ide-cli/idf-esp/help new file mode 100644 index 0000000..7531dbb --- /dev/null +++ b/ide-cli/idf-esp/help @@ -0,0 +1,11 @@ +# Installation idf-esp +mkdir -p ~/esp && cd ~/esp +git clone --recursive https://github.com/espressif/esp-idf.git +cd ~/esp/esp-idf && ./install.sh esp32 +. $HOME/esp/esp-idf/export.sh + +# add to your bashrc or zshrc +alias get_idf='. $HOME/esp/esp-idf/export.sh' + +#for run projet +get_idf diff --git a/ide-cli/platform.io/help b/ide-cli/platform.io/help new file mode 100644 index 0000000..fc200df --- /dev/null +++ b/ide-cli/platform.io/help @@ -0,0 +1,11 @@ +# Installation platform.io-cli +python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" + +# Autcomplétion +export PATH=$PATH:$HOME/.local/bin +emulate sh -c '. ~/.profile' + +mkdir -p /usr/local/bin +sudo ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio +sudo ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio +sudo ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb