Emacs personal configuration
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

128 rindas
5.7KB

  1. ;;; package --- Solidity mode
  2. ;;; Commentary:
  3. ;;; Code:
  4. (require-package 'solidity-mode)
  5. (require-package 'solidity-flycheck)
  6. (require-package 'company-solidity)
  7. ;; https://emacs.stackexchange.com/a/17565/12560
  8. (defun solidity-custom-settings ()
  9. (setq indent-tabs-mode nil)
  10. (setq tab-width 4)
  11. (setq c-basic-offset 4))
  12. (add-hook 'solidity-mode-hook 'solidity-custom-settings)
  13. (setq c-basic-offset 4)
  14. ;; https://github.com/ethereum/emacs-solidity
  15. ;(define-key map (kbd "C-c C-g") 'solidity-estimate-gas-at-point)
  16. (setq solidity-solc-path "/usr/local/bin/solc-static-linux-0.4.24")
  17. (setq solidity-solium-path "~/.nvm/versions/node/v9.4.0/bin/solium")
  18. (setq solidity-flycheck-solc-checker-active t)
  19. (setq solidity-flycheck-solium-checker-active t)
  20. (setq flycheck-solidity-solc-addstd-contracts t)
  21. (setq flycheck-solidity-solium-soliumrcfile "~/workspace/aragonOS/.soliumrc.json")
  22. (add-hook 'solidity-mode-hook
  23. (lambda ()
  24. (set (make-local-variable 'company-backends)
  25. (append '((company-solidity company-capf company-dabbrev-code))
  26. company-backends))))
  27. ;; https://gitlab.haskell.org/ghc/ghc/wikis/emacs
  28. (require 'whitespace)
  29. (defun solidity-custom-line-length ()
  30. (setq whitespace-style '(face lines-tail))
  31. (setq whitespace-line-column 145)
  32. (global-whitespace-mode t))
  33. (add-hook 'solidity-mode-hook 'solidity-custom-line-length)
  34. ;; See this issue about indentation and general solidity style:
  35. ;; https://github.com/ethereum/emacs-solidity/issues/32
  36. ;; Create ethereum c/c++ style
  37. (defconst ethereum-c-style
  38. '((c-tab-always-indent . t)
  39. ;; always syntactically analyze and indent macros
  40. (c-syntactic-indentation-in-macros . t)
  41. ;; auto align backslashes for continuation
  42. (c-auto-align-backslashes . t)
  43. (c-comment-only-line-offset . 4)
  44. (c-hanging-braces-alist . ((substatement-open after)
  45. (brace-list-open)))
  46. (c-hanging-colons-alist . ((member-init-intro before)
  47. (inher-intro)
  48. (case-label after)
  49. (label after)
  50. (access-label after)))
  51. (c-cleanup-list . (scope-operator
  52. empty-defun-braces
  53. defun-close-semi))
  54. (c-offsets-alist . (
  55. ;; lineup the current argument line under the
  56. ;; first argument
  57. ;; (arglist-close . c-lineup-arglist)
  58. (arglist-close . 0) ;; <-- or not
  59. (arglist-cont-nonempty . 4)
  60. (substatement-open . 0)
  61. (case-label . 0)
  62. (label . 0)
  63. (block-open . 4)
  64. ;; Don't indent first brace of a class's function
  65. (inline-open . 0)
  66. ;; all opens should be indented
  67. (brace-list-open . 4)
  68. ;; indent after case
  69. (statement-case-intro . 4)
  70. ;; indent after entering a block
  71. (statement-block-intro . 4)
  72. ;; indent after entering a function definition
  73. (defun-block-intro . 4)
  74. ;; indent when entering class/struct
  75. (inclass . 4)
  76. ;; don't indent the first line in a topmost construct
  77. (topmost-intro . 0)
  78. ;; first line after if/while/for/do/else
  79. (substatement . 4)
  80. ;; don't indent when in extern scope
  81. (inextern-lang . 0)
  82. ;; when ; does not end a stmt do indent
  83. (statement-cont . 4)
  84. ;; c++ constructor member initi no indent
  85. (member-init-intro . 4)
  86. (member-init-cont . 4)
  87. ;; don't indent c++ namespace
  88. (innamespace . 0)
  89. ;; don't indent first comments
  90. (comment-intro . 0)
  91. ))
  92. ;; echo syntactic info when presing TAB. If `t' helps with debugging.
  93. (c-echo-syntactic-information-p . t))
  94. "Ethereum C/C++ programming style.")
  95. (c-add-style "ethereum" ethereum-c-style)
  96. (defun ethereum-c-mode-hook ()
  97. "C/C++ hook for ethereum development."
  98. (subword-mode 1) ;all word movement goes across Capitalized words
  99. ;; (setq-default c-indent-tabs-mode t) ; tabs instead of spaces
  100. ;; (setq-default indent-tabs-mode t) ; tabs instead of spaces
  101. ;; (setq-default c-indent-level 4) ; A TAB is equivalent to 4 spaces
  102. ;; (setq-default c-basic-offset 4)
  103. ;; (setq-default tab-width 4) ; Default tab width is 4
  104. (setq-default c-argdecl-indent 0) ; Do not indent argument decl's extra
  105. (setq-default c-tab-always-indent t)
  106. ;; (setq-default backward-delete-function nil) ; DO NOT expand tabs when deleting
  107. (c-set-style "ethereum"))
  108. (add-hook 'solidity-mode-hook 'ethereum-c-mode-hook)
  109. (provide 'init-solidity)
  110. ;;; init-solidity.el ends here