emacs中的Javascript环境

阿什什尼吉

我一直在尝试从emacs开始进行基于node.js的项目开发。

我无法为此设置我的emacs。它更像是反复试验的黑匣子,导致沮丧。您能帮我设置一下吗:

我安装了插件 M-x package-install

我的emacs文件看起来像:

;; added for javascript -------
; Use dictionaries by default
(setq-default ac-sources (add-to-list 'ac-sources 'ac-source-dictionary))
(global-auto-complete-mode t)
; Start auto-completion after 2 characters of a word
(setq ac-auto-start 2)
; case sensitivity is important when finding matches
(setq ac-ignore-case nil)

(require 'yasnippet)
;; now enable the yasnippet for snippets
(yas-global-mode 1)

;; set the snippets directory
(setq yas-snippet-dirs
      '( "~/.emacs.d/plugins_old/yasnippet/yasmate/snippets" ;; the yasmate collection
        "~/.emacs.d/plugins_old/yasnippet/snippets" ;; the snippet collection
        "~/.emacs.d/elpa/yasnippet/snippets"         ;; the default collection
        ))

(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")

;; (define-key yas-minor-mode-map (kbd "TAB") 'yas-expand)
;; (define-key yas-minor-mode-map (kbd "<tab>") 'yas-expand)
;; (setq yas-trigger-key "")
;; (setq yas-next-field-key "")
;; (setq yas-prev-field-key "")


;; Let's have snippets in the auto-complete dropdown
(add-to-list 'ac-sources 'ac-source-yasnippet)

;; adding lint node
;; (add-to-list 'load-path "~/.emacs.d/plugins_old/lintnode")

;; finally followed this : http://www.emacswiki.org/emacs/FlymakeJavaScript to install jslint in emacs
(require 'flymake-jslint)
(add-hook 'js-mode-hook 'flymake-jslint-load)

;; Make sure we can find the lintnode executable
;; (setq lintnode-location "~/.emacs.d/plugins_old/lintnode")
;; JSLint can be... opinionated
;; (setq lintnode-jslint-excludes (list 'nomen 'undef 'plusplus 'onevar 'white))
;; Start the server when we first open a js file and start checking
;; (add-hook 'js-mode-hook
;;           (lambda ()
;;             (lintnode-hook)))

;; added red cursor for wrong lint node errors
(require 'flymake-cursor)

;; fold the functions
( add-hook 'js-mode-hook
       (lambda ()
         ;; Scan the file for nested code blocks
         (imenu-add-menubar-index)
         ;; Activate the folding mode
         (hs-minor-mode t)))
;; Show-hide
(global-set-key (kbd "") 'hs-show-block)
(global-set-key (kbd "") 'hs-show-all)
(global-set-key (kbd "") 'hs-hide-block)
(global-set-key (kbd "") 'hs-hide-all)

;; repl for javascript
(require 'js-comint)
;; Use node as our repl
(setq inferior-js-program-command "node")

(setq inferior-js-mode-hook
      (lambda ()
        ;; We like nice colors
        (ansi-color-for-comint-mode-on)
        ;; Deal with some prompt nonsense
        (add-to-list 'comint-preoutput-filter-functions
                     (lambda (output)
                       (replace-regexp-in-string ".*1G\.\.\..*5G" "..."
                     (replace-regexp-in-string ".*1G.*3G" "&gt;" output))))))
;; -----------------------------

这是我最近添加的用于设置环境的部分;您可能会看到很多注释的代码,这些代码显示了我在任何地方都尝试过此操作。我主要关注:不道德的尝试,然后最近尝试使用turnongtx

我最想要的是yasnippet和jslint自动完成工作吗?其他功能也可以添加,但是我仅用这些就挣扎了两天。

我的emacs版本是24.3.1,其中很多事情确实中断了。

我观察到经过1天的反复试验,yasnippet开始工作,但是重新启动emacs之后却无法工作。这意味着在重新加载.emacs文件的过程中,我可能在emacs会话中做了一些正确的事情。但是我又不知道在哪里发生了什么。

当我打开任何js文件并编写if并击中TAB任何内容时都不会发生。

另外,M-x yas-expand写完之后if什么也没但是确实有消息You can run the command "yas-expand" with TAB,但是有时也会发生。

我记得在某一时间上面做的任何事情都显示了昨天的if-expand。

好消息是我的jslint正在工作。我使用npm安装了它,并添加了flymake。:)我也可以使用comint nodejs repl :)

任何帮助,将不胜感激。

我完全emacs的文件是在这里我的emacs

若奥·塔沃拉(Joao Tavora)

设置yas-global-mode 使用yas-snippet-dirs否则,您必须使用yas-reload-all,这就是发生的情况。

请在此处遵循示例

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章