2

node.js ベースのプロジェクト開発を行うために、emacs から始めようとしています。

このために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))))))
;; -----------------------------

これは、環境をセットアップするために最近追加した部分です。どこからでもこれまたはあれを試したことを示す多くのコメント付きコードが表示される場合があります。私は主にフォローしました:deadpansincerityそして最近turnongtxで試しました

私が主に望んでいるのは、yasnippetとjslintでオートコンプリートが機能することですか? 他の機能はアドオンになる可能性がありますが、これらだけで2日間苦労しています.

私の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 展開された昨日が表示されていたことを覚えています。

良いことは、私のjslintが機能していることです。npm を使用してインストールし、flymake を追加しました。:) また、comint nodejs repl を使用できます:)

どんな助けでも大歓迎です。

私の完全なemacsファイルはここにありますmy emacs

4

1 に答える 1