(add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
#+END_SRC
* Modules
+** Tree sitter
+#+BEGIN_SRC emacs-lisp
+(use-package tree-sitter
+ :ensure t
+ :defer 1
+ :config
+ (global-tree-sitter-mode)
+ )
+(use-package tree-sitter-langs
+ :ensure t
+ :defer 1
+ :after tree-sitter
+ :config
+ (defun dla/python-function-at-point ()
+ "Return a list of function arguments
+
+Borrowed from https://xenodium.com/emacs-generate-a-swift-initializer/
+"
+ (interactive)
+ (cl-assert (seq-contains local-minor-modes 'tree-sitter-mode) "tree-sitter-mode not enabled")
+ (let* ((node (tree-sitter-node-at-point 'function_definition)
+ )
+ (args)
+ (arg)
+ (ret))
+ (unless node
+ (error "Not in function"))
+ (mapc
+ (lambda (item)
+ (cond ((eq 'func_name
+ (car item))
+ ; (when arg
+ ; (setq args (append args (list arg)))
+ ; )
+ (setq arg (list (cons 'function (tsc-node-text
+ (cdr item))))))
+ ((eq 'ident
+ (car item))
+ (setq arg (map-insert arg 'ident (tsc-node-text
+ (cdr item)))))
+ ((eq 'ident_type
+ (car item))
+ (setq arg (map-insert arg 'ident_type (tsc-node-text
+ (cdr item)))))
+ ((eq 'ret_type
+ (car item))
+ (setq arg (map-insert arg 'ret_type (tsc-node-text
+ (cdr item)))))
+ ))
+ (tsc-query-captures
+ (tsc-make-query tree-sitter-language
+ "(function_definition (identifier) @func_name (parameters [(identifier) @ident (typed_parameter (identifier) @ident (type) @ident_type)]) (type)? @ret_type)")
+ (tree-sitter-node-at-point 'function_definition) nil))
+ (when arg
+ (setq args (append args (list arg))))
+ args))
+
+)
+#+END_SRC
** Spacemacs theme
#+BEGIN_SRC emacs-lisp
(use-package spacemacs-common
company-minimum-prefix-length 1
company-global-modes '(not)
company-lighter-base "(C)")
+ (setq company-backends '(company-capf
+ company-keywords
+ company-semantic
+ company-files
+ company-etags
+ company-elisp
+ company-clang
+ company-irony-c-headers
+ company-irony
+ company-jedi
+ company-cmake
+ company-ispell
+ company-yasnippet))
(global-company-mode 1)
:bind (:map company-active-map
("C-n" . company-select-next)
#+END_SRC
*** C/C++
#+BEGIN_SRC emacs-lisp
- (use-package company-c-headers
- :ensure t
- :config (progn
- (defun malb/ede-object-system-include-path ()
- "Return the system include path for the current buffer."
- (when ede-object
- (ede-system-include-path ede-object)))
-
- (setq company-c-headers-path-system
- #'malb/ede-object-system-include-path)
+(use-package company-c-headers
+ :ensure t
+ :config (progn
+ (defun malb/ede-object-system-include-path ()
+ "Return the system include path for the current buffer."
+ (when ede-object
+ (ede-system-include-path ede-object)))
- (add-to-list 'company-backends #'company-c-headers)))
+ (setq company-c-headers-path-system
+ #'malb/ede-object-system-include-path)))
#+END_SRC
*** Python
#+BEGIN_SRC emacs-lisp
-(use-package company-anaconda
+(use-package company-jedi
:ensure t
- :config (add-to-list 'company-backends #'company-anaconda))
+ :hook (python-mode . 'jedi:setup)
+ :config
+ (setq jedi:complete-on-dot t)
+ )
#+END_SRC
*** Perl
#+BEGIN_SRC emacs-lisp
)
)
#+END_SRC
+**** Bibtex
#+BEGIN_SRC emacs-lisp
(use-package company-bibtex
:ensure t
#+END_SRC
*** Shell
- #+BEGIN_SRC emacs-lisp
- (use-package company-shell
- :ensure t
- :config (progn
- (setq company-shell-modes '(sh-mode shell-mode))
- (add-to-list 'company-backends 'company-shell)))
- #+END_SRC
+#+BEGIN_SRC emacs-lisp
+(use-package company-shell
+ :ensure t
+ :config (progn
+ (setq company-shell-modes '(sh-mode shell-mode))
+ (add-to-list 'company-backends 'company-shell)))
+#+END_SRC
*** YaSnippet
- Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
+Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
- *Note:* Do this at the end of =company-mode= config.
+*Note:* Do this at the end of =company-mode= config.
- #+BEGIN_SRC emacs-lisp
- (defvar malb/company-mode/enable-yas t
- "Enable yasnippet for all backends.")
+#+BEGIN_SRC emacs-lisp
+(defvar malb/company-mode/enable-yas t
+ "Enable yasnippet for all backends.")
- (defun malb/company-mode/backend-with-yas (backend)
- (if (or (not malb/company-mode/enable-yas)
- (and (listp backend)
- (member 'company-yasnippet backend)))
- backend
- (append (if (consp backend) backend (list backend))
- '(:with company-yasnippet))))
+(defun malb/company-mode/backend-with-yas (backend)
+ (if (or (not malb/company-mode/enable-yas)
+ (and (listp backend)
+ (member 'company-yasnippet backend)))
+ backend
+ (append (if (consp backend) backend (list backend))
+ '(:with company-yasnippet))))
- (setq company-backends
- (mapcar #'malb/company-mode/backend-with-yas company-backends))
- #+END_SRC
+(setq company-backends
+ (mapcar #'malb/company-mode/backend-with-yas company-backends))
+#+END_SRC
*** All the words
- Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
+Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
- #+BEGIN_SRC emacs-lisp
- (defun malb/toggle-company-ispell ()
- (interactive)
- (cond
- ((member '(company-ispell :with company-yasnippet) company-backends)
- (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
- (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
- (message "company-ispell disabled"))
- (t
- (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
- (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
- (message "company-ispell enabled!"))))
-
- (defun malb/company-ispell-setup ()
- ;; @see https://github.com/company-mode/company-mode/issues/50
- (when (boundp 'company-backends)
- (make-local-variable 'company-backends)
- (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
- (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
- ;; https://github.com/redguardtoo/emacs.d/issues/473
- (if (and (boundp 'ispell-alternate-dictionary)
- ispell-alternate-dictionary)
- (setq company-ispell-dictionary ispell-alternate-dictionary))))
- #+END_SRC
+#+BEGIN_SRC emacs-lisp
+(defun malb/toggle-company-ispell ()
+ (interactive)
+ (cond
+ ((member '(company-ispell :with company-yasnippet) company-backends)
+ (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
+ (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
+ (message "company-ispell disabled"))
+ (t
+ (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
+ (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
+ (message "company-ispell enabled!"))))
+
+(defun malb/company-ispell-setup ()
+ ;; @see https://github.com/company-mode/company-mode/issues/50
+ (when (boundp 'company-backends)
+ (make-local-variable 'company-backends)
+ (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
+ (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
+ ;; https://github.com/redguardtoo/emacs.d/issues/473
+ (if (and (boundp 'ispell-alternate-dictionary)
+ ispell-alternate-dictionary)
+ (setq company-ispell-dictionary ispell-alternate-dictionary))))
+#+END_SRC
*** Tab DWIM
(elpy-enable)
)
#+END_SRC
-# *** Jedi
-# #+BEGIN_SRC emacs-lisp
-# (use-package company-jedi
-# :ensure t
-# :hook (python-mode . (add-to-list 'company-backends 'company-jedi))
-# :hook (python-mode . 'jedi:setup)
-# :config
-# (setq jedi:complete-on-dot t)
-# )
-# #+END_SRC
*** Black
#+begin_src emacs-lisp :tangle yes
(use-package python-black