-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_gui.el
537 lines (398 loc) · 12.6 KB
/
init_gui.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
(windmove-default-keybindings)
(set-face-attribute 'default nil :height 168)
(setq exec-path-from-shell-check-startup-files -1)
;;(load-theme 'manoj-dark)
(use-package doom-themes
:ensure t
:init
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
:config
(doom-themes-visual-bell-config)
(doom-themes-org-config)
)
(load-theme 'material t)
(use-package powerline
:disabled
:ensure t
:config
(setq powerline-default-separator 'utf-8))
(use-package hideshow
:hook ((prog-mode . hs-minor-mode)))
(defun toggle-fold ()
(interactive)
(save-excursion
(end-of-line)
(hs-toggle-hiding)))
(global-set-key (kbd "C-=") 'hs-toggle-hiding)
;;modeline programming
;;============================================================================
(use-package minions
:ensure t
:config
(setq minions-mode-line-lighter ""
minions-mode-line-delimiters '("" . ""))
(minions-mode 1))
;;genral programming
;;============================================================================
(use-package git-gutter
:ensure t
:config
(global-git-gutter-mode 't)
:diminish git-gutter-mode)
(use-package git-timemachine
:ensure t)
(use-package aggressive-indent
:ensure t
:config
(global-aggressive-indent-mode 1)
(add-to-list 'aggressive-indent-excluded-modes 'html-mode))
(use-package bicycle
:ensure t
:after outline
:bind (:map outline-minor-mode-map
([C-tab] . bicycle-cycle)
([S-tab] . bicycle-cycle-global)))
(use-package prog-mode
:config
(add-hook 'prog-mode-hook 'outline-minor-mode)
(add-hook 'prog-mode-hook 'hs-minor-mode))
;;exec
;;============================================================================
(use-package exec-path-from-shell
:ensure t
:if (memq window-system '(mac ns x))
:config
(setq exec-path-from-shell-variables '("PATH" "GOPATH" "GOROOT" "GOBIN"))
(exec-path-from-shell-initialize))
(add-to-list 'exec-path "~/go_code/bin")
;; ;;golang
;; ;;============================================================================
(use-package company-go
:ensure t
)
;; (defvar go-tab-width 4
;; "Set the `tab-width' in Go mode. Default is 8.")
;; (defvar go-use-gometalinter nil
;; "Use gometalinter if the variable has non-nil value.")
(defun my-go-run-main ()
(interactive)
(shell-command
(format "go run %s" (shell-quote-argument (buffer-file-name)))
))
(defun spacemacs//go-enable-gometalinter ()
"Enable `flycheck-gometalinter' and disable overlapping `flycheck' linters."
(setq flycheck-disabled-checkers '(
go-vet
go-build
go-test
go-errcheck)))
(defun my-go-var-shortcut ()
(interactive)
(insert " := ")
)
(defun my-go-write-into-ch-shortcut ()
(interactive)
(insert "<-")
)
(use-package go-mode
:ensure t
:init (progn
(autoload 'go-mode "go-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
)
:config (progn
(if (string-match "make" compile-command)
(set (make-local-variable 'compile-command)
"go build -v && go test -v && go vet"))
(if (executable-find "goimports")
(setq gofmt-command "goimports")
(setq gofmt-args '("-local" "liftoff/")))
)
:bind (:map go-mode-map
("C-<" . my-go-write-into-ch-shortcut)
("C-;" . my-go-var-shortcut)
("M-." . godef-jump)
("M-*" . pop-tag-mark)
("C-c RET" . compile)
("<C-return>" . my-go-run-main))
)
(add-hook 'go-mode-hook
(lambda ()
(setq tab-width 4)
(setq indent-tabs-mode 1)
(flymake-mode -1)
(auto-complete-mode 1)
(spacemacs//go-enable-gometalinter)
) )
(add-hook 'before-save-hook 'gofmt-before-save)
;; (add-hook 'go-mode-hook 'flycheck-mode)
(use-package flycheck-gometalinter
:defer t
)
(use-package go-complete
:ensure t
:hook
(completion-at-point-functions . go-complete-at-point)
)
(use-package go-guru
:ensure t
:hook
(go-mode-hook . #'go-guru-hl-identifier-mode)
)
(use-package gorepl-mode
:ensure t
:hook
(go-mode-hook . #'gorepl-mode)
)
(use-package go-playground
:ensure t
)
;;web-mode
;;============================================================================
(use-package web-mode
:ensure t
:config
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.api\\'" . web-mode))
(add-to-list 'auto-mode-alist '("/some/react/path/.*\\.js[x]?\\'" . web-mode))
(setq web-mode-content-types-alist
'(("json" . "/some/path/.*\\.api\\'")
("xml" . "/other/path/.*\\.api\\'")
("jsx" . "/some/react/path/.*\\.js[x]?\\'")))
)
(use-package emmet-mode
:ensure t
:hook (html-mode . emmet-mode))
(add-hook 'web-mode-hook 'emmet-mode )
(use-package restclient
:ensure t)
;;dired-mode
;;===========================================D=================================
;;(use-package dired-details
;; :ensure t ;;load-path "~/.emacs.d/package/dired-details/"
;; :config
;; (setq-default dired-details-hidden-string "--- ")
;; (dired-details-install))
;;to refresh buffers
;; (global-auto-revert-mode 1)
;; ;; Also auto refresh dired, but be quiet about it
;; (setq global-auto-revert-non-file-buffers t)
;; (setq auto-revert-verbose nil)
;; (setq dried-dwim-target t)
;;sql specific
;;============================================================================
(setq sql-connection-alist
'((server1 (sql-product 'postgres)
(sql-port 5432)
(sql-server "localhost")
(sql-user "nithin")
(sql-database "kyc"))
)
)
(defun my-sql-connect (product connection)
;; load the password
(require my-password "my-password.el.gpg")
;; update the password to the sql-connection-alist
(let ((connection-info (assoc connection sql-connection-alist))
(sql-password (car (last (assoc connection my-sql-password)))))
(delete sql-password connection-info)
(nconc connection-info `((sql-password ,sql-password)))
(setq sql-connection-alist (assq-delete-all connection sql-connection-alist))
(add-to-list 'sql-connection-alist connection-info))
;; connect to database
(setq sql-product product)
(sql-connect connection)
)
;; Projectile mode
;;============================================================================
;;slack mode
;;============================================================================
(use-package slack
:commands (slack-start)
:init
(setq slack-buffer-emojify t) ;; if you want to enable emoji, default nil
)
;;org mode
;;============================================================================
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
)
;; when opening a org file, don't collapse headings
(setq org-startup-folded nil)
;; wrap long lines. don't let it disappear to the right
(setq org-startup-truncated nil)
;; when in a url link, enter key should open it
(setq org-return-follows-link t)
;; make org-mode” syntax color embedded source code
(setq org-src-fontify-natively t)
;;
;; (use-package ox-beamer
;; :ensure t)
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
;; (use-package cython
;; :ensure t)
;; markdown mode
;;============================================================================
;;(setq markdown-command "multimarkdown"))
;;(setq markdown-command "pandoc")
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
;; JS mode
;;============================================================================
(use-package rjsx-mode
:ensure t
:mode "\\.js\\'")
;; npm install -g typescript
(defun setup-tide-mode()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(tide-hl-identifier-mode +1)
(company-mode +1)
)
(use-package tide
:ensure t
:after (rjsx-mode company flycheck)
:hook (rjsx-mode . setup-tide-mode)
)
(use-package prettier-js
:ensure t
:after (rjsx-mode)
:hook(rjsx-mode . prettier-js-mode))
(use-package xref-js2
:ensure t)
(use-package indium
:ensure t)
;; (use-package company-tern
;; :ensure t)
;; (add-to-list 'company-backends 'company-tern)
;; (add-hook 'js2-mode-hook (lambda ()
;; (tern-mode)
;; (company-mode)))
;; (define-key tern-mode-keymap (kbd "M-.") nil)
;; (define-key tern-mode-keymap (kbd "M-,") nil)
;;============================================================================
(use-package neotree
:ensure t
:config
(global-set-key [f8] 'neotree-toggle))
;; relative nliunm mode
;;============================================================================
(use-package nlinum
:ensure t
:bind ("M-[" . nlinum-mode)
)
;; (use-package nlinum-relative
;; :ensure t
;; :config
;; ;; something else you want
;; (nlinum-relative-setup-evil)
;; (setq nlinum-relative-redisplay-delay 0) ;; delay
;; (setq nlinum-relative-current-symbol "->") ;; or "" for display current line number
;; (setq nlinum-relative-offset 0)
;; (add-hook 'prog-mode-hook 'nlinum-relative-mode))
;; yaml support
;;============================================================================
(use-package highlight-indentation
:ensure t
:config
(setq highlight-indentation t)
)
(use-package smart-shift
:ensure t)
(defun aj-toggle-fold ()
"Toggle fold all lines larger than indentation on current line"
(interactive)
(let ((col 1))
(save-excursion
(back-to-indentation)
(setq col (+ 1 (current-column)))
(set-selective-display
(if selective-display nil (or col 1))))))
(global-set-key [(M C i)] 'aj-toggle-fold)
(use-package yaml-mode
:ensure t
:config
(setq yaml-indent-offset 2))
;; :hook (yaml-mode . smart-shift-mode-hook)) ;
(use-package flycheck-yamllint
:ensure t
:defer t
:init
(progn
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook 'flycheck-yamllint-setup))))
(use-package golden-ratio
:ensure t
)
;; lsp configrations
;;============================================================================
(use-package which-key
:ensure t)
(use-package lsp-mode
:ensure t
:hook ((python-mode . lsp)
(go-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
;; optionally
(use-package lsp-ui :ensure t :commands lsp-ui-mode)
(use-package company-lsp :ensure t :commands company-lsp)
(use-package company-lsp :commands company-lsp)
(use-package lsp-ivy :commands lsp-ivy-workspace-symbol)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(use-package flycheck
:ensure t
:hook (python-mode-hook . flycheck-mode)
)
(add-hook 'go-mode-hook #'lsp-deferred)
;; terminal mode setup
;;============================================================================
(use-package terminal-here
:ensure t
)
(global-set-key (kbd "C-<f6>") #'terminal-here-launch)
(global-set-key (kbd "C-<f7>") #'terminal-here-project-launch)
;; Writing book configrations
;;============================================================================
;; (use-package vmd-mode
;; :ensure t
;; :defer t)
(use-package ox-gfm
:ensure t)
;; (add-hook 'markdown-mode-hook 'vmd-mode)
(use-package cl-lib
:ensure t)
(use-package mmm-mode
:commands mmm-mode
:init (add-hook 'markdown-mode-hook (lambda () (mmm-mode 1)))
:config
(progn
(mmm-add-classes '((markdown-lisp
:submode lisp-mode
:front "^```lisp[\n\r]+"
:back "^```$")))
(mmm-add-classes '((markdown-ini
:submode conf-unix-mode
:face mmm-declaration-submode-face
:front "^```ini[\n\r]+"
:back "^```$")))
(mmm-add-classes '((markdown-python
:submode python-mode
:face mmm-declaration-submode-face
:front "^```python[\n\r]+"
:back "^```$")))
))