Javascript окружение в emacs

Я пытался начать с 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))))))
;; -----------------------------

Это та часть, которую я недавно добавил для настройки среды; Вы можете увидеть много комментированного кода, который показывает, что я пробовал то или иное отовсюду. Я следовал в основном: deadpansincerity, а затем пытался в последнее время с 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.

Хорошо, что мой jslint работает. Я установил его с помощью npm и добавил flymake.:) Также я могу использовать comint nodejs repl:)

Любая помощь будет оценена.

Мой полный файл Emacs здесь мой Emacs

1 ответ

Решение

Использование yas-global-mode после того, как вы установили yas-snippet-dirs, В противном случае вы должны использовать yas-reload-all что и случилось.

Следуйте примеру здесь

Другие вопросы по тегам