Compare commits

..

10 Commits

Author SHA1 Message Date
e6d452cac2 Uses yasnippet-licenses through straight 2023-11-30 16:20:58 +01:00
44f4ee000f [emacs] Updates go-compile-commande 2023-11-20 13:57:17 +01:00
1d0c8b75a3 [emacs] Fixes atu/jupyter-ascending-sync 2023-11-20 13:38:26 +01:00
1b8095559b [emacs] jupyter-ascending integration via code-cells
Do not edit .ipynb files in the browser anymore.
2023-11-06 10:33:56 +01:00
b33cf55170 Improves cmake-before-save-hook
Do not erase wrongly formatted buffer
Keeps the current region
Writes nice message to buffer
2023-10-13 12:08:44 +02:00
0cf9d0d134 Groups snippet after other completion 2023-10-13 11:59:49 +02:00
c944c410c4 Enables projectile switching between C/C++ files 2023-10-05 12:31:59 +02:00
4cbf8c3088 Optimizes vertico 2023-10-04 17:30:55 +02:00
21a1f64a1e Adds consult/embark/vertico in emacs. 2023-10-04 13:38:40 +02:00
7cf57b9ab8 Makes company speaks yasnippet 2023-09-30 13:15:35 +02:00

555
.emacs
View File

@@ -5,55 +5,49 @@
(custom-set-variables (custom-set-variables
;; custom-set-variables was added by Custom. ;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(c-basic-offset 4) '(c-basic-offset 4)
'(c-default-style '(compilation-scroll-output 'first-error)
'((c++-mode . "tuleu-c++") '(custom-safe-themes
(java-mode . "java") '("162201cf5b5899938cfaec99c8cb35a2f1bf0775fc9ccbf5e63130a1ea217213" "e3daa8f18440301f3e54f2093fe15f4fe951986a8628e98dcd781efbec7a46f2" "6622bb651e72d8ebd66454bd86db6c3990324243ff4325c1b6df252aba63b13e" "2f8eadc12bf60b581674a41ddc319a40ed373dd4a7c577933acaff15d2bf7cc6" "f458b92de1f6cf0bdda6bce23433877e94816c3364b821eb4ea9852112f5d7dc" "016f665c0dd5f76f8404124482a0b13a573d17e92ff4eb36a66b409f4d1da410" "13096a9a6e75c7330c1bc500f30a8f4407bd618431c94aeab55c9855731a95e1" "8b148cf8154d34917dfc794b5d0fe65f21e9155977a36a5985f89c09a9669aa0" "bf948e3f55a8cd1f420373410911d0a50be5a04a8886cabe8d8e471ad8fdba8e" "680f62b751481cc5b5b44aeab824e5683cf13792c006aeba1c25ce2d89826426" "631c52620e2953e744f2b56d102eae503017047fb43d65ce028e88ef5846ea3b" default))
(awk-mode . "awk") '(display-time-24hr-format t)
(other . "gnu"))) '(display-time-default-load-average nil)
'(company-idle-delay 20.0) '(doom-modeline-github t)
'(compilation-scroll-output 'first-error) '(doom-modeline-indent-info t)
'(custom-safe-themes '(doom-modeline-minor-modes t)
'("162201cf5b5899938cfaec99c8cb35a2f1bf0775fc9ccbf5e63130a1ea217213" "e3daa8f18440301f3e54f2093fe15f4fe951986a8628e98dcd781efbec7a46f2" "6622bb651e72d8ebd66454bd86db6c3990324243ff4325c1b6df252aba63b13e" "2f8eadc12bf60b581674a41ddc319a40ed373dd4a7c577933acaff15d2bf7cc6" "f458b92de1f6cf0bdda6bce23433877e94816c3364b821eb4ea9852112f5d7dc" "016f665c0dd5f76f8404124482a0b13a573d17e92ff4eb36a66b409f4d1da410" "13096a9a6e75c7330c1bc500f30a8f4407bd618431c94aeab55c9855731a95e1" "8b148cf8154d34917dfc794b5d0fe65f21e9155977a36a5985f89c09a9669aa0" "bf948e3f55a8cd1f420373410911d0a50be5a04a8886cabe8d8e471ad8fdba8e" "680f62b751481cc5b5b44aeab824e5683cf13792c006aeba1c25ce2d89826426" "631c52620e2953e744f2b56d102eae503017047fb43d65ce028e88ef5846ea3b" default)) '(doom-modeline-total-line-number t)
'(display-time-24hr-format t) '(fill-column 80)
'(display-time-default-load-average nil) '(global-auto-revert-mode t)
'(doom-modeline-github t) '(global-display-line-numbers-mode t)
'(doom-modeline-indent-info t) '(global-subword-mode t)
'(doom-modeline-minor-modes t) '(gofmt-command "goimports")
'(doom-modeline-total-line-number t) '(inhibit-startup-screen t)
'(fill-column 80) '(lisp-body-indent 4)
'(global-auto-revert-mode t) '(lisp-indent-offset 4)
'(global-display-line-numbers-mode t) '(lisp-lambda-list-keyword-alignment t)
'(global-subword-mode t) '(lisp-lambda-list-keyword-parameter-alignment t)
'(gofmt-command "goimports") '(lisp-lambda-list-keyword-parameter-indentation 4)
'(inhibit-startup-screen t) '(lisp-loop-forms-indentation 4)
'(lisp-body-indent 4) '(lisp-loop-keyword-indentation 4)
'(lisp-indent-offset 4) '(lisp-simple-loop-indentation 4)
'(lisp-lambda-list-keyword-alignment t) '(lisp-tag-body-indentation 4)
'(lisp-lambda-list-keyword-parameter-alignment t) '(lisp-tag-indentation 4)
'(lisp-lambda-list-keyword-parameter-indentation 4) '(org-agenda-files '("~/org/1.TODO.org"))
'(lisp-loop-forms-indentation 4) '(package-enable-at-startup nil)
'(lisp-loop-keyword-indentation 4) '(package-selected-packages
'(lisp-simple-loop-indentation 4) '(code-cells clang-format+ cmake-format xterm-color dockerfile-mode web-mode prettier json-mode py-isort blacken pyvenv yaml-mode lsp-pyright ng2-mode lsp-ltex lsp-treemacs treemacs-nerd-icons treemacs-projectile treemacs lsp-ui lsp-mode which-key flycheck vterm projectile yasnippet-snippets yasnippet aggressive-indent doom-themes company-go zenburn-theme langtool smart-tabs-mode typescript-mode protobuf-mode opencl-mode glsl-mode go-mode markdown-mode srefactor irony cmake-mode company magit use-package))
'(lisp-tag-body-indentation 4) '(safe-local-variable-values
'(lisp-tag-indentation 4) '((vc-follow-symlinks . t)
'(org-agenda-files '("~/org/1.TODO.org")) (TeX-master . t)
'(package-enable-at-startup nil) (TeX-parse-self . t)))
'(package-selected-packages '(system-packages-noconfirm t)
'(clang-format+ cmake-format xterm-color dockerfile-mode web-mode prettier json-mode py-isort blacken pyvenv yaml-mode lsp-pyright ng2-mode lsp-ltex lsp-treemacs treemacs-nerd-icons treemacs-projectile treemacs lsp-ui lsp-mode which-key flycheck vterm projectile yasnippet-snippets yasnippet aggressive-indent doom-themes company-go zenburn-theme langtool smart-tabs-mode typescript-mode protobuf-mode opencl-mode glsl-mode go-mode markdown-mode srefactor irony cmake-mode company magit use-package)) '(tab-width 4)
'(safe-local-variable-values '(warning-suppress-log-types '((comp)))
'((vc-follow-symlinks . t) '(whitespace-style
(TeX-master . t) '(face trailing tabs lines-tail newline space-before-tab::tab space-before-tab::space space-before-tab tab-mark)))
(TeX-parse-self . t)))
'(system-packages-noconfirm t)
'(tab-width 4)
'(warning-suppress-log-types '((comp)))
'(whitespace-style
'(face trailing tabs lines-tail newline space-before-tab::tab space-before-tab::space space-before-tab tab-mark)))
(if (display-graphic-p) (if (display-graphic-p)
(if (fboundp 'tool-bar-mode) (if (fboundp 'tool-bar-mode)
@@ -75,22 +69,31 @@
(setq package-archives '(("melpa" . "https://melpa.org/packages/") (setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/"))) ("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize) (package-initialize)
(eval-when-compile
(unless (package-installed-p 'use-package)
(unless package-archive-contents
(package-refresh-contents))
(package-install 'use-package)
)
(require 'use-package)
)
(require 'use-package) (defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(require 'use-package-ensure) (require 'use-package-ensure)
(setq use-package-always-ensure t) (setq use-package-always-ensure t)
(use-package use-package-ensure-system-package) (use-package use-package-ensure-system-package)
;; required because vterm wants this before loading. ;; required because vterm wants this before loading.
(use-package emacs (use-package emacs
:demand t :demand t
@@ -98,9 +101,201 @@
(cmake . cmake) (cmake . cmake)
("/usr/include/vterm.h" . libvterm-dev) ("/usr/include/vterm.h" . libvterm-dev)
) )
:init
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
(setq read-extended-command-predicate
#'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t)
) )
;; Enable vertico
(use-package vertico
:init
(vertico-mode)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
(setq vertico-count 10)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
:config
(vertico-reverse-mode)
)
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; Optionally use the `orderless' completion style.
(use-package orderless
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion))))
)
;; Example configuration for Consult
(use-package consult
;; Replace bindings. Lazily loaded due by `use-package'.
:bind (;; C-c bindings in `mode-specific-map'
("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c M" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings in `ctl-x-map'
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings in `goto-map'
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings in `search-map'
("M-s d" . consult-find) ;; Alternative: consult-fd
("M-s D" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
:config
;; Optionally configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key "M-.")
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-theme :preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
;; :preview-key "M-."
:preview-key '(:debounce 0.4 any))
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; "C-+"
(autoload 'projectile-project-root "projectile")
(setq consult-project-function (lambda (_) (projectile-project-root)))
)
(use-package marginalia
:config
(marginalia-mode))
(use-package embark
:bind
("C-x m" . embark-act) ;; pick some comfortable binding
("M-." . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings) ;; alternative for `describe-bindings'
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
;; Show the Embark target at point via Eldoc. You may adjust the Eldoc
;; strategy, if you want to see the documentation from multiple providers.
(add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target)
;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:demand t
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package doom-modeline (use-package doom-modeline
:init :init
@@ -150,11 +345,11 @@
) )
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
) )
(use-package xterm-color (use-package xterm-color
:config :config
@@ -229,8 +424,26 @@
(use-package company (use-package company
:delight :delight
:bind ( ("M-TAB" . company-complete) ) :bind ( ("M-TAB" . company-complete) )
:init
(defun atu/company-prog-mode ()
"Starts yas company and set up backends accordingly"
(yas-minor-mode)
(company-mode)
)
:config :config
(global-company-mode t) (setq
company-minimum-prefix-length 1
company-idle-delay 0.5)
(setq company-backends
'(
(company-capf :separate company-yasnippet)
company-files
company-keywords
)
)
:hook
(prog-mode . atu/company-prog-mode)
) )
(use-package cmake-mode (use-package cmake-mode
@@ -238,28 +451,72 @@
(cmake . cmake) (cmake . cmake)
(pip . python3-pip) (pip . python3-pip)
(cmake-format . "pip install --user cmakelang[YAML]") (cmake-format . "pip install --user cmakelang[YAML]")
(cmake-language-server . "pip install --user cmake-language-server")
) )
:config :config
(setq cmake-tab-width 4) (setq cmake-tab-width 4)
(defun atu/create-or-erase-buffer (buffer-name)
""
(let ((existing-buffer (get-buffer buffer-name)))
(when existing-buffer
(with-current-buffer existing-buffer
(erase-buffer)))
(get-buffer-create buffer-name))
)
(defun atu/cmake-format-buffer () (defun atu/cmake-format-buffer ()
"Formats the current buffer using cmake-format" "Formats the current buffer using cmake-format"
(interactive) (interactive)
(shell-command-on-region (let ((error-buffer (atu/create-or-erase-buffer "*cmake-format:stderr*")))
;; region to execute on (setq-local atu/after-save-message nil)
(point-min) (if (eq 0 (call-process-region
(point-max) ;;region
;; command (point-min)
"cmake-format -" (point-max)
;; replace "cmake-format"
t nil ;do not delete buffer
;; name of the error bufer ;; discard stdout copy stderr to buffer
"* cmake-format Error Buffer *" error-buffer
;; nil ;dont-redisplay buffer
t)) "-"
))
(let ((current-point (point)))
(call-process-region
(point-min) (point-max)
"cmake-format"
t t t; replace current buffer and redisplay it
"-"
)
(goto-char (+ (point-min) current-point))
nil
)
(message
"cmake-format: could not format %s see buffer %s for details"
(buffer-name) error-buffer)
(current-message)
)
)
)
(defun atu/cmake-before-save-hook ()
""
(setq-local atu/after-save-message (atu/cmake-format-buffer))
)
(defun atu/cmake-after-save-hook ()
""
(when atu/after-save-message
(message atu/after-save-message)
)
)
:hook :hook
(cmake-mode . lsp-deferred) (cmake-mode . lsp-deferred)
(cmake-mode . (lambda () (add-hook 'before-save-hook 'atu/cmake-format-buffer nil 'local))) (cmake-mode . (lambda ()
(add-hook 'before-save-hook 'atu/cmake-before-save-hook nil 'local)
(add-hook 'after-save-hook 'atu/cmake-after-save-hook nil 'local))
)
) )
(use-package cc-mode (use-package cc-mode
@@ -281,15 +538,24 @@
(use-package yasnippet (use-package yasnippet
:delight yas-minor-mode :delight yas-minor-mode
:config :config
(yas-global-mode)
:after (company)
:bind ( :map yas-minor-mode-map :bind ( :map yas-minor-mode-map
("TAB" . nil) ("TAB" . nil)
) )
) )
(use-package yasnippet-snippets (use-package yasnippet-snippets
:after (yasnippet) :after yasnippet
)
(use-package yasnippet-licenses
:straight (yasnippet-licenses
:type git
:host github
:repo "atuleu/yasnippet-licenses"
:files (:defaults "*.el" "snippets")
)
:after yasnippet
) )
(use-package projectile (use-package projectile
@@ -306,6 +572,73 @@
:test "ng test --progress=false" :test "ng test --progress=false"
:run "ng serve" :run "ng serve"
:test-suffix ".spec") :test-suffix ".spec")
(defun atu/cmake-cc-inference (dir)
"Detects if the current root is a CMake C/C++ project"
(let ((cmakelists-file (projectile-expand-root "CMakeLists.txt" dir)))
(if (file-exists-p cmakelists-file)
(with-temp-buffer
(insert-file-contents cmakelists-file)
(goto-char (point-min))
(re-search-forward "project[[:space:]]*([^)]+\\([[:space:]]C\\(XX\\)?[[:space:]]\\)[^)]+)" nil t)
)))
)
(defun atu/cc-related-files (path)
"Returns related files path for a C/C++ file for a given path"
(let* (
(ext (file-name-extension path))
(basename (file-name-base path))
(dirpath (file-name-directory path))
(impl-rx "\\([.-]?[Ii]mp[l]?\\)$")
)
(if (member ext '("h" "hh" "hpp"))
(if (string-match impl-rx basename)
(list :other (concat dirpath
(string-replace
(match-string 1 basename)
""
basename)
"."
ext))
(list :other
(mapcar (lambda (sfx) (concat dirpath basename sfx))
(list
(concat "Imp." ext)
(concat "Impl." ext)
(concat "imp." ext)
(concat "impl." ext)
(concat ".Imp." ext)
(concat ".Impl." ext)
(concat ".imp." ext)
(concat ".impl." ext)
(concat "-Imp." ext)
(concat "-Impl." ext)
(concat "-imp." ext)
(concat "-impl." ext)
".cpp"
)))
)
(when (member ext '("c" "cc" "cpp"))
(list :other
(mapcar (lambda (sfx) (concat dirpath basename sfx))
'( ".h" ".hh" ".hpp" )))
)
)
)
)
(projectile-register-project-type 'cmake-cc #'atu/cmake-cc-inference
:project-file "CMakeLists.txt"
:configure "cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=On"
:compile "cmake --build build"
:test "cmake --build build --target check"
:related-files-fn
(list
#'atu/cc-related-files
(projectile-related-files-fn-test-with-suffix "cpp" "Test")
(projectile-related-files-fn-test-with-suffix "cpp" "UTest")
)
)
) )
(use-package vterm) (use-package vterm)
@@ -348,7 +681,6 @@
(setq lsp-keymap-prefix "C-c l") (setq lsp-keymap-prefix "C-c l")
:bind-keymap ("C-c l" . lsp-command-map) :bind-keymap ("C-c l" . lsp-command-map)
:config :config
(yas-minor-mode)
(if (display-graphic-p) (if (display-graphic-p)
(setq lsp-ui-doc-use-webkit t) (setq lsp-ui-doc-use-webkit t)
) )
@@ -360,6 +692,7 @@
) )
) )
) )
(setq lsp-completion-provider :none)
:bind ( :bind (
("C-c C-d" . lsp-ui-doc-toggle) ("C-c C-d" . lsp-ui-doc-toggle)
) )
@@ -538,8 +871,52 @@
(add-hook 'before-save-hook 'py-isort-before-save))) (add-hook 'before-save-hook 'py-isort-before-save)))
) )
(use-package code-cells
:mode ("\\.sync.py'" . code-cells-mode)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c-c++-header)) :config
(defun atu/jupyter-ascending-sync ()
"Runs synchronization with jupyter-ascending "
(interactive)
(when (string-match-p ".sync.py\\'" (buffer-name))
(unless (and (boundp 'atu/jupyter-sync-inhibit) atu/jupyter-sync-inhibit)
(call-process "python"
nil nil nil
"-m" "jupyter_ascending.requests.sync" "--filename" (buffer-file-name)
)
)
)
)
(defun atu/jupyter-ascending-eval (start end)
"Runs cell via jupyter-ascending or python-shell-send-region"
(interactive)
(if (not (string-match-p ".sync.py\\'" (buffer-name)))
(python-shell-send-region start end)
(setq-local atu/jupyter-sync-inhibit t)
(save-buffer)
(setq-local atu/jupyter-sync-inhibit nil)
(call-process "python"
nil nil nil
"-m" "jupyter_ascending.requests.execute"
"--filename" (buffer-file-name)
"--linenumber" (number-to-string (line-number-at-pos))
)
)
)
(setq code-cells-eval-region-commands
(mapcar (lambda (pair)
(if (eq (car pair) 'python-mode)
(cons 'python-mode 'atu/jupyter-ascending-eval)
pair))
code-cells-eval-region-commands))
:hook
(python-mode . code-cells-mode-maybe)
(code-cells-mode . (lambda ()
(add-hook 'after-save-hook 'atu/jupyter-ascending-sync nil 'local)))
)
(use-package markdown-mode) (use-package markdown-mode)
@@ -547,17 +924,19 @@
:after (projectile) :after (projectile)
:config :config
(unbind-key "C-c C-d" go-mode-map) (unbind-key "C-c C-d" go-mode-map)
(defun go-compile-command () (defun atu/go-compile-command ()
"returns a string to compile a go project" "returns a string to compile a go project"
(setq project-makefile (concat (file-name-as-directory (projectile-project-root)) "Makefile")) (interactive)
(if (file-exists-p project-makefile) (let ((project-makefile (concat (file-name-as-directory (projectile-project-root)) "Makefile")))
"make" (if (file-exists-p project-makefile)
"go build && go test && go vet" "make"
"go build && go test && go vet"
)
) )
) )
(projectile-update-project-type (projectile-update-project-type
'go 'go
:compile 'go-compile-command) :compile 'atu/go-compile-command)
:hook :hook
(go-mode . lsp-deferred) (go-mode . lsp-deferred)
(go-mode . (lambda () (go-mode . (lambda ()