Adds text insertion functinos and keys
This commit is contained in:
parent
69078f8d9b
commit
698a981e8c
|
@ -137,3 +137,18 @@ Called interactively it prompts for a directory."
|
||||||
(highlight-lines-matching-regexp "byebug")
|
(highlight-lines-matching-regexp "byebug")
|
||||||
(highlight-lines-matching-regexp "binding.irb")
|
(highlight-lines-matching-regexp "binding.irb")
|
||||||
(highlight-lines-matching-regexp "binding.pry")))
|
(highlight-lines-matching-regexp "binding.pry")))
|
||||||
|
|
||||||
|
|
||||||
|
;; Insert text
|
||||||
|
|
||||||
|
(defun spacemacs/ruby-insert-frozen-string-literal-comment ()
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert "# frozen_string_literal: true\n")))
|
||||||
|
|
||||||
|
(defun spacemacs/ruby-insert-shebang ()
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert "#!/usr/bin/env ruby\n")))
|
||||||
|
|
|
@ -93,6 +93,8 @@
|
||||||
#'spacemacs/ruby-maybe-highlight-debugger-keywords))
|
#'spacemacs/ruby-maybe-highlight-debugger-keywords))
|
||||||
:config
|
:config
|
||||||
(spacemacs/set-leader-keys-for-major-mode 'enh-ruby-mode
|
(spacemacs/set-leader-keys-for-major-mode 'enh-ruby-mode
|
||||||
|
"if" 'spacemacs/ruby-insert-frozen-string-literal-comment
|
||||||
|
"is" 'spacemacs/ruby-insert-shebang
|
||||||
"r{" 'enh-ruby-toggle-block
|
"r{" 'enh-ruby-toggle-block
|
||||||
"r}" 'enh-ruby-toggle-block)))
|
"r}" 'enh-ruby-toggle-block)))
|
||||||
|
|
||||||
|
@ -283,9 +285,7 @@
|
||||||
("\\.\\(rb\\|rabl\\|ru\\|builder\\|rake\\|thor\\|gemspec\\|jbuilder\\|pryrc\\)\\'" . ruby-mode))
|
("\\.\\(rb\\|rabl\\|ru\\|builder\\|rake\\|thor\\|gemspec\\|jbuilder\\|pryrc\\)\\'" . ruby-mode))
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
;; This might have been important 10 years ago but now it's frustrating.
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mi" "insert")
|
||||||
(setq ruby-insert-encoding-magic-comment nil)
|
|
||||||
|
|
||||||
(spacemacs/declare-prefix-for-mode 'ruby-mode "mt" "test")
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mt" "test")
|
||||||
(spacemacs/declare-prefix-for-mode 'ruby-mode "mT" "toggle")
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mT" "toggle")
|
||||||
|
|
||||||
|
@ -294,11 +294,18 @@
|
||||||
(add-hook 'ruby-mode-hook #'spacemacs//ruby-setup-backend)
|
(add-hook 'ruby-mode-hook #'spacemacs//ruby-setup-backend)
|
||||||
(add-hook 'ruby-mode-local-vars-hook
|
(add-hook 'ruby-mode-local-vars-hook
|
||||||
#'spacemacs/ruby-maybe-highlight-debugger-keywords))
|
#'spacemacs/ruby-maybe-highlight-debugger-keywords))
|
||||||
:config (spacemacs/set-leader-keys-for-major-mode 'ruby-mode
|
:config
|
||||||
"r'" 'ruby-toggle-string-quotes
|
(progn
|
||||||
"r\"" 'ruby-toggle-string-quotes
|
;; This might have been important 10 years ago but now it's frustrating.
|
||||||
"r{" 'ruby-toggle-block
|
(setq ruby-insert-encoding-magic-comment nil)
|
||||||
"r}" 'ruby-toggle-block)))
|
|
||||||
|
(spacemacs/set-leader-keys-for-major-mode 'ruby-mode
|
||||||
|
"if" 'spacemacs/ruby-insert-frozen-string-literal-comment
|
||||||
|
"is" 'spacemacs/ruby-insert-shebang
|
||||||
|
"r'" 'ruby-toggle-string-quotes
|
||||||
|
"r\"" 'ruby-toggle-string-quotes
|
||||||
|
"r{" 'ruby-toggle-block
|
||||||
|
"r}" 'ruby-toggle-block))))
|
||||||
|
|
||||||
(defun ruby/init-ruby-refactor ()
|
(defun ruby/init-ruby-refactor ()
|
||||||
(use-package ruby-refactor
|
(use-package ruby-refactor
|
||||||
|
|
Loading…
Reference in a new issue