ESS应该如何开启高亮

我使用doom emacs,有关ESS的配置只有在init.el里面的

(ess +lsp)

但是写R没有高亮,请问这是为什么?以及写stata该如何配置呢?谢谢!

我是用use-package调用的ESS,也许是hook设置的不对,只有script高亮,inferior里没有,于是抄了这段:

;; -------- highlight function names & keywords in R --------
(dolist (hook '(ess-mode-hook ess-r-mode-hook inferior-ess-r-mode-hook))
  (add-hook hook
            '(lambda()
               (font-lock-add-keywords
                nil
                '(("\\<\\(if\\|for\\|function\\|return\\|$\\|@\\)\\>[\n[:blank:]]*(" 1
                   font-lock-keyword-face) ; must go first to override highlighting below
                  ("\\<\\([.A-Za-z][._A-Za-z0-9]*\\)[\n[:blank:]]*(" 1
                   font-lock-function-name-face) ; highlight function names
                  ("\\([(,]\\|[\n[:blank:]]*\\)\\([.A-Za-z][._A-Za-z0-9]*\\)[\n[:blank:]]*=[^=]"
                   2 font-lock-builtin-face)
                  ;; highlight numbers
                  ("\\(-?[0-9]*\\.?[0-9]*[eE]?-?[0-9]+[iL]?\\)" 1 font-lock-constant-face)
                  ;; highlight operators
                  ("\\(\\$\\|\\@\\|\\!\\|\\%\\|\\^\\|\\&\\|\\*\\|\(\\|\)\\|\{\\|\}\\|\\[\\|\\]\\|\\-\\|\\+\\|\=\\|\\/\\|\<\\|\>\\|:\\)" 1 font-lock-type-face)
                  ;; highlight S4 methods
                  ("\\(setMethod\\|setGeneric\\|setGroupGeneric\\|setClass\\|setRefClass\\|setReplaceMethod\\)" 1 font-lock-preprocessor-face)
                  ;; highlight packages called through ::, :::
                  ("\\(\\w+\\):\\{2,3\\}" 1 font-lock-type-face)
                  )))))
1 个赞

谢谢!比之前好多了

(setq inferior-R-font-lock-keywords
      '((ess-S-fl-keyword:prompt . t)
        (ess-R-fl-keyword:messages . t)
        (ess-R-fl-keyword:modifiers . t)
        (ess-R-fl-keyword:fun-defs . t)
        (ess-R-fl-keyword:keywords . t)
        (ess-R-fl-keyword:assign-ops . t)
        (ess-R-fl-keyword:constants . t)
        (ess-fl-keyword:matrix-labels . t)
        (ess-fl-keyword:fun-calls . t)
        (ess-fl-keyword:numbers . t)
        (ess-fl-keyword:operators . t)
        (ess-fl-keyword:delimiters . t)
        (ess-fl-keyword:= . t)
        (ess-R-fl-keyword:F&T . t)
        ;; (ess-R-fl-keyword:%op% . t)
        ))
1 个赞

一般的emacs,需要 (require 'ess-site)之类的