Add basic font-lock support for Python f-strings
This commit is contained in:
parent
c66936f519
commit
e8fd8a9b1b
@ -2802,11 +2802,31 @@ Emacs support for the Language Server Protocol
|
||||
(add-hook 'python-mode-hook #'disable-tab-insert)
|
||||
#+END_SRC
|
||||
|
||||
Elpy is a python IDE package:
|
||||
Font-lock for f-strings:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
;; (use-package elpy
|
||||
;; :init (elpy-enable)
|
||||
;; :config (setq elpy-rpc-python-command "python3"))
|
||||
(with-eval-after-load 'python
|
||||
(setq python-font-lock-keywords
|
||||
(append python-font-lock-keywords
|
||||
'(;; this is the full string.
|
||||
;; group 1 is the quote type and a closing quote is matched
|
||||
;; group 2 is the string part
|
||||
("f\\(['\"]\\{1,3\\}\\)\\(.+?\\)\\1"
|
||||
;; these are the {keywords}
|
||||
("{[^}]*?}"
|
||||
;; Pre-match form
|
||||
(progn (goto-char (match-beginning 0)) (match-end 0))
|
||||
;; Post-match form
|
||||
(goto-char (match-end 0))
|
||||
;; face for this match
|
||||
(0 font-lock-variable-name-face t)))))))
|
||||
#+END_SRC
|
||||
|
||||
|
||||
Elpy is a python IDE package:
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(use-package elpy
|
||||
:init (elpy-enable)
|
||||
:config (setq elpy-rpc-python-command "python3"))
|
||||
#+END_SRC
|
||||
|
||||
Alternatively, use the LSP python client:
|
||||
|
Loading…
Reference in New Issue
Block a user