Last active
March 22, 2023 15:54
-
-
Save davebraze/380cad0d2f7bd868bfc30d30fc4ca40e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; cribbed from: https://www.reddit.com/r/emacs/comments/yojd70/state_of_esseglot/ | |
;; | |
;; also see: | |
;; https://github.com/minad/corfu/wiki#configuring-corfu-for-eglot | |
;; https://github.com/minad/corfu/wiki#using-cape-to-tweak-and-combine-capfs | |
(use-package eglot | |
:defer t | |
:commands (eglot eglot-ensure) | |
:hook | |
((c-mode . eglot-ensure) | |
(c++-mode . eglot-ensure) | |
(ess-mode . eglot-ensure)) | |
:config | |
(setq eglot-stay-out-of '(company)) | |
(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10")) | |
) | |
(defun company-R-objects--prefix () | |
(unless (ess-inside-string-or-comment-p) | |
(let ((start (ess-symbol-start))) | |
(when start | |
(buffer-substring-no-properties start (point)))))) | |
(defun company-R-objects--candidates (arg) | |
(let ((proc (ess-get-next-available-process))) | |
(when proc | |
(with-current-buffer (process-buffer proc) | |
(all-completions arg (ess--get-cached-completions arg)))))) | |
(defun company-capf-with-R-objects--check-prefix (prefix) | |
(cl-search "$" prefix)) | |
(defun company-capf-with-R-objects (command &optional arg &rest ignored) | |
(interactive (list 'interactive)) | |
(cl-case command | |
(interactive (company-begin-backend 'company-R-objects)) | |
(prefix (company-R-objects--prefix)) | |
(candidates (if (company-capf-with-R-objects--check-prefix arg) | |
(company-R-objects--candidates arg) | |
(company-capf command arg))) | |
(annotation (if (company-capf-with-R-objects--check-prefix arg) | |
"R-object" | |
(company-capf command arg))) | |
(kind (if (company-capf-with-R-objects--check-prefix arg) | |
'field | |
(company-capf command arg))) | |
(doc-buffer (company-capf command arg)))) | |
(use-package ess | |
:ensure nil | |
:defer t | |
:commands (list R julia) | |
:load-path ("/home/matias/Programas/ESS/lisp") | |
:bind (:map ess-mode-map | |
("<C-tab>" . company-files) | |
("<M-tab>" . company-complete-common) | |
("M-P" . my/add-pipe) | |
("M-h" . company-show-doc-buffer)) | |
:init | |
(require 'ess-site) | |
(setq | |
ess-nuke-trailing-whitespace-p t | |
ess-toggle-underscore nil | |
ess-toggle-S-assign nil | |
ess-disable-underscore-assign t | |
;; ess-use-flymake nil | |
) | |
(company-posframe-mode 0) | |
(add-hook 'ess-mode-hook | |
(lambda() | |
(make-local-variable 'company-backends) | |
(setq company-backends '(company-files company-capf-with-R-objects)))) | |
:config | |
(progn (defalias 'ess-smart-S-assign 'self-insert-command))) | |
(defun my/add-pipe () | |
"Adds a pipe operator %>% with one space to the left and right" | |
(interactive) | |
(just-one-space 1) | |
(insert "%>%") | |
(just-one-space 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment