diff --git a/.gitea/workflows/build-image.yaml b/.gitea/workflows/build-image.yaml index f530aa8..91eb68e 100644 --- a/.gitea/workflows/build-image.yaml +++ b/.gitea/workflows/build-image.yaml @@ -12,4 +12,5 @@ jobs: run: | cd ${{ gitea.workspace }} docker build . -t emacs-c - + #- name: Upload image to gitea package repository. + diff --git a/Dockerfile b/Dockerfile index 5f5b7fa..c7a8838 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,21 @@ FROM debian +# install emacs + clang + clangd as LSP. ENV DEBIAN_FRONTEND=noninteractive RUN apt update && \ - apt install -y emacs clang clangd && \ - apt clean all + apt install -y emacs build-essential git make cmake clang clang-format clangd && \ + apt clean all && \ + rm -rf /var/lib/apt/lists/* + +# copy emacs config +COPY emacs-init /root/.emacs + +# install emacs packages by running once beforehand, +# so we don't have to that every start-up +RUN emacs --batch -l /root/.emacs \ + --eval "(package-refresh-contents)" \ + --eval "(package-install-selected-packages)" -ENTRYPOINT ["/bin/emacs" "-nw"] +ENTRYPOINT ["/bin/emacs", "-nw"] diff --git a/emacs-init b/emacs-init index e983b6a..e33e5e8 100644 --- a/emacs-init +++ b/emacs-init @@ -1,8 +1,48 @@ -;; Require Emacs' package functionality +;; Package management (require 'package) - -;; Add the Melpa repository to the list of package sources -(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) - -;; Initialise the package system. +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) + +;; Install use-package if missing +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +;; Core setup +(setq inhibit-startup-screen t) +(electric-pair-mode 1) +(show-paren-mode 1) + +;; Packages +(use-package eglot + :ensure t + :hook ((c-mode c++-mode) . eglot-ensure)) + +(use-package company + :ensure t + :config + (global-company-mode) + (setq company-idle-delay 0.1)) + +(use-package flycheck + :ensure t + :init (global-flycheck-mode)) + +(use-package clang-format + :ensure t + :bind ("C-c f" . clang-format-buffer)) + +(use-package projectile + :ensure t + :init (projectile-mode)) + +(use-package which-key + :ensure t + :init (which-key-mode)) + +;; C-specific settings +(add-hook 'c-mode-hook + (lambda () + (setq c-basic-offset 4) + (setq tab-width 4) + (setq indent-tabs-mode nil)))