2020-05-22 22:05:40 +00:00
|
|
|
;; Made by Julien Palard <julien@palard.fr>
|
2014-06-22 16:16:14 +00:00
|
|
|
;;
|
|
|
|
;; Started on Sun Nov 16 12:00:18 2008 Julien Palard
|
|
|
|
;;
|
2020-05-22 22:05:40 +00:00
|
|
|
;; Packages I typically use can be reinstalled by using:
|
|
|
|
;; M-x package-install-selected-packages
|
2016-07-23 11:07:07 +00:00
|
|
|
|
2014-06-22 16:16:14 +00:00
|
|
|
(setq user-full-name "Julien Palard")
|
|
|
|
(setq user-mail-address "julien@palard.fr")
|
2021-03-22 10:18:41 +00:00
|
|
|
(require 'use-package)
|
2019-03-19 08:41:15 +00:00
|
|
|
(require 'package)
|
|
|
|
(package-initialize)
|
2020-06-04 13:05:39 +00:00
|
|
|
|
|
|
|
;; If there are no archived package contents, refresh them
|
|
|
|
(when (not package-archive-contents)
|
|
|
|
(package-refresh-contents))
|
|
|
|
|
2019-03-19 08:41:15 +00:00
|
|
|
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
|
|
|
|
("org" . "https://orgmode.org/elpa/")
|
|
|
|
("melpa" . "https://melpa.org/packages/")))
|
2014-06-22 16:16:14 +00:00
|
|
|
|
2021-09-19 12:37:32 +00:00
|
|
|
(use-package ido
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(ido-mode t))
|
|
|
|
|
2021-09-29 19:26:18 +00:00
|
|
|
(use-package magit
|
|
|
|
:ensure t)
|
|
|
|
|
2021-09-19 12:37:32 +00:00
|
|
|
(use-package lsp-mode
|
|
|
|
:ensure t
|
|
|
|
:custom
|
|
|
|
(lsp-diagnostics-provider :flycheck)
|
|
|
|
(lsp-jedi-hover-disable-keyword-all t)
|
|
|
|
(lsp-ui-sideline-show-code-actions nil)
|
|
|
|
(lsp-ui-sideline-show-diagnostics nil)
|
|
|
|
(lsp-ui-sideline-show-hover nil)
|
|
|
|
(lsp-jedi-pylsp-extra-paths [])
|
|
|
|
:config
|
|
|
|
(set-face-attribute 'lsp-face-highlight-textual nil
|
|
|
|
:background "#666" :foreground "#ffffff"
|
|
|
|
)
|
|
|
|
(lsp-register-client
|
|
|
|
(make-lsp-client
|
|
|
|
:new-connection (lsp-stdio-connection "po-language-server")
|
|
|
|
:activation-fn (lsp-activate-on "gettext" "plaintext")
|
|
|
|
:priority -1
|
|
|
|
:server-id 'po
|
|
|
|
))
|
|
|
|
(add-to-list 'lsp-language-id-configuration '(po-mode . "gettext"))
|
|
|
|
:hook ((po-mode python-mode) . lsp)
|
|
|
|
:commands lsp-mode
|
|
|
|
|
|
|
|
)
|
2014-06-22 16:16:14 +00:00
|
|
|
|
2021-09-19 12:37:32 +00:00
|
|
|
(use-package lsp-ui)
|
2021-03-22 10:18:41 +00:00
|
|
|
|
2021-09-19 12:37:32 +00:00
|
|
|
(use-package lsp-jedi
|
|
|
|
:ensure t
|
|
|
|
:after lsp-mode
|
|
|
|
:config
|
|
|
|
(with-eval-after-load "lsp-mode"
|
|
|
|
(add-to-list 'lsp-disabled-clients 'pyls)
|
|
|
|
))
|
2021-06-29 16:32:31 +00:00
|
|
|
|
2021-09-29 21:06:35 +00:00
|
|
|
;; Test using flycheck-verify-setup
|
2021-09-19 12:37:32 +00:00
|
|
|
(use-package flycheck
|
2021-09-29 21:06:35 +00:00
|
|
|
:ensure t
|
2021-09-19 12:37:32 +00:00
|
|
|
:config
|
2021-09-29 21:06:35 +00:00
|
|
|
(global-flycheck-mode t)
|
2021-09-19 12:37:32 +00:00
|
|
|
(setq-default flycheck-disabled-checkers '(lsp))
|
2021-09-29 21:06:35 +00:00
|
|
|
(add-hook 'python-mode-hook (setq flycheck-checker 'python-flake8)))
|
2021-05-01 08:40:41 +00:00
|
|
|
|
2021-09-19 12:37:32 +00:00
|
|
|
(use-package blacken
|
|
|
|
:ensure t
|
|
|
|
:commands (blacken-mode)
|
|
|
|
:hook (python-mode . blacken-mode))
|
2021-05-01 08:40:41 +00:00
|
|
|
|
2021-09-30 07:34:22 +00:00
|
|
|
(use-package org-fancy-priorities
|
|
|
|
:ensure t
|
|
|
|
:hook
|
|
|
|
(org-mode . org-fancy-priorities-mode)
|
|
|
|
:config
|
|
|
|
(setq org-fancy-priorities-list '("⚡" "⬆" "⬇" "☕")))
|
|
|
|
|
2021-05-01 08:40:41 +00:00
|
|
|
;; lsp-mode can only work on named buffers
|
|
|
|
(defun po-mode-name-buffer ()
|
|
|
|
(setq-local buffer-file-name "msgstr.po")
|
|
|
|
(lsp))
|
|
|
|
|
|
|
|
(defun po-mode-unname-buffer ()
|
|
|
|
(setq-local buffer-file-name nil))
|
|
|
|
|
|
|
|
(add-hook 'po-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(advice-add 'po-edit-msgstr :after 'po-mode-name-buffer)
|
|
|
|
(advice-add 'po-subedit-exit :before 'po-mode-unname-buffer)))
|
|
|
|
|
|
|
|
|
2016-07-23 11:07:07 +00:00
|
|
|
;; Disable all version control backends (Start faster):
|
2014-06-22 16:16:14 +00:00
|
|
|
(setq vc-handled-backends ())
|
|
|
|
|
2016-07-23 11:07:07 +00:00
|
|
|
;; Disable transient mark mode, I don't like it:
|
2014-06-22 16:16:14 +00:00
|
|
|
(transient-mark-mode nil)
|
|
|
|
|
2016-07-23 11:07:07 +00:00
|
|
|
;; Coding style
|
2017-11-05 23:02:53 +00:00
|
|
|
(setq-default indent-tabs-mode nil
|
|
|
|
tab-width 4
|
|
|
|
py-indent-offset 4
|
|
|
|
show-trailing-whitespace t)
|
|
|
|
|
|
|
|
;; Don't show trailing whitespaces in term-mode
|
2014-06-22 16:16:14 +00:00
|
|
|
(add-hook 'term-mode-hook
|
|
|
|
(lambda() (make-local-variable 'show-trailing-whitespace)
|
|
|
|
(setq show-trailing-whitespace nil)))
|
|
|
|
|
|
|
|
(setq inhibit-startup-message t)
|
|
|
|
|
|
|
|
(global-font-lock-mode t)
|
|
|
|
(column-number-mode t)
|
2017-11-05 23:02:53 +00:00
|
|
|
(show-paren-mode t)
|
2014-06-22 16:16:14 +00:00
|
|
|
|
|
|
|
(global-set-key "\C-cc" 'compile)
|
|
|
|
(global-set-key "\M-n" 'forward-paragraph)
|
|
|
|
(global-set-key "\M-p" 'backward-paragraph)
|
|
|
|
(global-set-key "\C-xrv" 'list-registers)
|
|
|
|
(global-set-key (kbd "M-h") 'backward-kill-word)
|
2016-07-23 11:07:07 +00:00
|
|
|
(global-set-key [f12] 'iwb)
|
2017-09-27 10:04:15 +00:00
|
|
|
(global-set-key "\C-cj" 'windmove-left)
|
|
|
|
(global-set-key "\C-ck" 'windmove-down)
|
|
|
|
(global-set-key "\C-cl" 'windmove-up)
|
|
|
|
(global-set-key "\C-c;" 'windmove-right)
|
2016-07-23 11:07:07 +00:00
|
|
|
(global-set-key "\C-x\M-%" 'query-replace-regexp) ;; As C-M-% is ~impossible to type in a terminal emulator:
|
2018-07-21 08:45:01 +00:00
|
|
|
(global-set-key "\C-cl" 'org-store-link)
|
|
|
|
(global-set-key "\C-ca" 'org-agenda)
|
|
|
|
(global-set-key "\C-cc" 'org-capture)
|
|
|
|
(global-set-key "\C-cb" 'org-switchb)
|
|
|
|
|
2014-06-22 16:16:14 +00:00
|
|
|
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
|
2021-05-01 08:40:57 +00:00
|
|
|
(add-hook 'after-init-hook 'global-company-mode)
|
2014-06-22 16:16:14 +00:00
|
|
|
|
|
|
|
;; Enable backup files.
|
|
|
|
(setq make-backup-files t)
|
|
|
|
|
2017-11-05 23:02:53 +00:00
|
|
|
;; Enable versioning of backup files.
|
2014-06-22 16:16:14 +00:00
|
|
|
(setq version-control t)
|
|
|
|
|
|
|
|
;; Save all backup file in this directory.
|
2020-06-02 12:52:40 +00:00
|
|
|
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/backup/"))))
|
2017-11-05 23:02:53 +00:00
|
|
|
(setq-default delete-old-versions t)
|
2014-06-22 16:16:14 +00:00
|
|
|
|
|
|
|
(fset 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
|
|
|
(setq-default truncate-partial-width-windows nil)
|
|
|
|
|
2015-11-28 16:54:06 +00:00
|
|
|
(menu-bar-mode -1)
|
2014-06-22 16:16:14 +00:00
|
|
|
|
|
|
|
(defun iwb ()
|
2016-07-23 11:07:07 +00:00
|
|
|
"Indent whole buffer."
|
2014-06-22 16:16:14 +00:00
|
|
|
(interactive)
|
|
|
|
(delete-trailing-whitespace)
|
|
|
|
(indent-region (point-min) (point-max) nil)
|
|
|
|
(untabify (point-min) (point-max)))
|
|
|
|
|
2017-11-05 23:02:53 +00:00
|
|
|
|
2016-07-23 11:07:07 +00:00
|
|
|
;; Highlight 80th column
|
|
|
|
(require 'whitespace)
|
2018-06-15 15:56:53 +00:00
|
|
|
(setq whitespace-line-column 88)
|
2016-07-23 11:07:07 +00:00
|
|
|
(setq whitespace-style '(face empty tabs lines-tail trailing))
|
|
|
|
(global-whitespace-mode t)
|
2015-11-28 16:54:06 +00:00
|
|
|
|
2017-11-05 23:02:53 +00:00
|
|
|
|
2015-11-28 16:54:06 +00:00
|
|
|
;; hex color
|
|
|
|
(defvar hexcolour-keywords
|
2020-06-03 09:37:25 +00:00
|
|
|
'(("#[a-fA-F[:digit:]]\\{3,6\\}"
|
2015-11-28 16:54:06 +00:00
|
|
|
(0 (let ((colour (match-string-no-properties 0)))
|
|
|
|
(if (or (= (length colour) 4)
|
|
|
|
(= (length colour) 7))
|
|
|
|
(put-text-property
|
|
|
|
(match-beginning 0)
|
|
|
|
(match-end 0)
|
|
|
|
'face (list :background (match-string-no-properties 0)
|
|
|
|
:foreground (if (>= (apply '+ (x-color-values
|
|
|
|
(match-string-no-properties 0)))
|
|
|
|
(* (apply '+ (x-color-values "white")) .6))
|
|
|
|
"black" ;; light bg, dark text
|
|
|
|
"white" ;; dark bg, light text
|
|
|
|
)))))
|
|
|
|
append))))
|
|
|
|
|
2017-11-05 23:02:53 +00:00
|
|
|
|
2015-11-28 16:54:06 +00:00
|
|
|
(defun hexcolour-add-to-font-lock ()
|
|
|
|
(interactive)
|
|
|
|
(font-lock-add-keywords nil hexcolour-keywords t))
|
|
|
|
|
|
|
|
(add-hook 'css-mode-hook 'hexcolour-add-to-font-lock)
|
|
|
|
(add-hook 'sass-mode-hook 'hexcolour-add-to-font-lock)
|
2020-06-03 09:37:25 +00:00
|
|
|
(add-hook 'emacs-lisp-mode-hook 'hexcolour-add-to-font-lock)
|
2020-06-04 13:05:39 +00:00
|
|
|
(add-hook 'conf-xdefaults-mode-hook 'hexcolour-add-to-font-lock)
|
2015-11-28 16:54:06 +00:00
|
|
|
|
2021-04-04 16:18:53 +00:00
|
|
|
(yas-global-mode 1)
|
|
|
|
|
2016-07-23 11:07:07 +00:00
|
|
|
(defun konix/find-file-hook ()
|
|
|
|
"Permits file opening with line suffix like foo.py:21."
|
|
|
|
(if (and
|
|
|
|
(string-match "^\\(.+\\):\\([0-9]+\\)$" buffer-file-name)
|
|
|
|
(not
|
|
|
|
(file-exists-p buffer-file-name)))
|
|
|
|
;; the given file does not exist and is of the form file_name:number, I
|
|
|
|
;; most likely wants to open file_name at line number
|
|
|
|
(progn
|
|
|
|
(let (
|
|
|
|
(old_buffer (current-buffer))
|
|
|
|
(file_name (match-string-no-properties 1 buffer-file-name))
|
|
|
|
(line (match-string-no-properties 2 buffer-file-name))
|
|
|
|
)
|
|
|
|
(if (file-exists-p file_name)
|
|
|
|
(progn
|
|
|
|
(find-file file_name)
|
|
|
|
(forward-line (string-to-number line))
|
|
|
|
(kill-buffer old_buffer)
|
|
|
|
nil)
|
|
|
|
nil)))
|
|
|
|
nil))
|
2021-09-19 12:37:32 +00:00
|
|
|
|
2016-07-23 11:07:07 +00:00
|
|
|
(add-to-list 'find-file-hook 'konix/find-file-hook)
|
2015-11-28 16:54:06 +00:00
|
|
|
|
2016-07-23 11:15:22 +00:00
|
|
|
(custom-set-variables
|
|
|
|
;; custom-set-variables was added by Custom.
|
|
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
|
|
;; Your init file should contain only one such instance.
|
|
|
|
;; If there is more than one, they won't work right.
|
2020-05-14 15:52:40 +00:00
|
|
|
'(c-basic-offset 4)
|
2021-03-22 10:18:41 +00:00
|
|
|
'(frame-background-mode 'dark)
|
2020-06-02 19:50:57 +00:00
|
|
|
'(package-selected-packages
|
2021-09-19 12:37:32 +00:00
|
|
|
'(company yasnippet-snippets use-package zenburn-theme markdown-mode org po-mode yaml-mode)))
|
2017-10-25 08:48:54 +00:00
|
|
|
|
2020-06-02 19:50:57 +00:00
|
|
|
(load-theme 'zenburn t)
|
2021-03-22 10:18:41 +00:00
|
|
|
(custom-set-faces
|
|
|
|
;; custom-set-faces was added by Custom.
|
|
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
|
|
;; Your init file should contain only one such instance.
|
|
|
|
;; If there is more than one, they won't work right.
|
|
|
|
)
|