#!/usr/bin/env bash

# https://packagecloud.io/AtomEditor/atom/packages/gpgkey
# https://packagecloud.io/AtomEditor/atom/packages/any/any/atom_1.53.0_amd64.deb
# https://packagecloud.io/AtomEditor/atom/packages/any/any/atom-beta_1.54.0-beta0_amd64.deb
# https://packagecloud.io/AtomEditor/atom/packages/any/any/atom-nightly_1.55.0-nightly0_amd64.deb

CODENAME=any
OS="any"
URL="packagecloud.io/AtomEditor/atom"

wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/atomeditor-keyring.gpg


echo "deb [arch=amd64 signed-by=/usr/share/keyrings/atomeditor-keyring.gpg] https://${URL}/${OS}/ ${CODENAME} main" | sudo tee /etc/apt/sources.list.d/atom-editor.list
#echo "deb-src [arch=amd64 signed-by=/usr/share/keyrings/atomeditor-keyring.gpg] https://${URL}/${OS}/ $CODENAME main" | sudo tee /etc/apt/sources.list-available/atom-editor.list
sudo ln -sf /etc/apt/sources.list-available/atom-editor.list /etc/apt/sources.list.d/atom-editor.list

sudo apt update

sudo apt install -y clang jsonlint
sudo apt install -y atom
#sudo apt install -y atom-beta
#sudo apt install -y atom-nightly

apm install \
	platformio-ide \
	platformio-ide-debugger \
	platformio-ide-terminal \
	atom-python-virtualenv \
	atom-build \
	build-docker-file \
	vim-mode-plus \
	vim-mode-clipboard-plus \
	minimap \
	minimap-linter \
	python-docstring-template \
	kite \
	pydoc \
	pydoc-headers \
	linter \
	linter-docker \
	linter-ui-default \
	linter-yaml \
	linter-python \
	linter-pydocstype \
	linter-clang \
	linter-golint \
	linter-shellcheck \
	linter-markdown \
	markdown-filepicker \
	linter-coverage \
	spell-check-urls \
	file-icons \
	intentions \
	busy-signal \
	atom-beautify \
	advanced-open-file \
	highlight-selected \
	open-recent \
	#linter-json-lint \
	# atom-ide-terminal # fork of platformio-ide-terminal that uses node-pty rather than pty.js

#	apm install ide-docker  # WIP  requires language server
# Dockerfile languageserver or docker image rcjsuen/docker-langserver
#npm install -g dockerfile-language-server-nodejs

#docker-langserver --node-ipc
#docker-langserver --stdio
#docker-langserver --socker=<port>
