-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
121 lines (98 loc) · 3.69 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(tool-bar-mode -1)
(menu-bar-mode -1)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(require 'rust-mode)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
(quote
(lsp-mode cargo toml-mode flycheck-rust rust-mode cider company-tern company-web tide rjsx-mode use-package find-file-in-project projectile))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(require 'use-package)
(use-package elpy
:ensure t
:init
(elpy-enable))
(global-set-key (kbd "C-x pf") 'find-file-in-project)
(windmove-default-keybindings)
(setq x-select-enable-clipboard t)
(setq interprogram-cut-function 'x-select-text)
(xclip-mode 1)
(require 'flycheck)
(require 'company)
(require 'company-tern)
(add-to-list 'company-backends 'company-tern)
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (string-equal "jsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
;; configure jsx-tide checker to run after your default jsx checker
(flycheck-add-mode 'javascript-eslint 'web-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (string-equal "js" (file-name-extension buffer-file-name))
(setup-tide-mode))))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)
(setq web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")))
(setq web-mode-content-types-alist
'(("tsx" . "\\.ts[x]?\\'")))
(setq web-mode-script-padding 4)
(setq web-mode-style-padding 4)
(setq web-mode-js-indent-offset 4)
(setq package-check-signature nil)
(setq backup-directory-alist `(("." . "~/.saves")))
(setq backup-by-copying t)
(put 'upcase-region 'disabled nil)
(use-package toml-mode)
(use-package rust-mode
:hook (rust-mode . lsp))
;; Add keybindings for interacting with Cargo
(use-package cargo
:hook (rust-mode . cargo-minor-mode))
(use-package flycheck-rust
:config (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
(put 'downcase-region 'disabled nil)