-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemacs
741 lines (632 loc) · 26.2 KB
/
emacs
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
;;;##############################################################
;;; linux settings
;;;##############################################################
(defun my-linux-conf ()
(if (eq window-system 'x)
(progn
(set-face-attribute 'default nil :family "Hack")
(set-fontset-font t 'hangul
(font-spec :name "D2Coding"))
;(setq face-font-rescale-alist '(("D2Coding" . 1.23)))
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "x-www-browser")
; unset unused keys
(global-unset-key (kbd "<f9>")) ; change to hanja
(global-set-key [(Hangul)] 'toggle-input-method)
(global-set-key [(Hangul_Hanja)] 'hangul-to-hanja-conversion)))
)
;;;##############################################################
;;; darwin settings
;;;##############################################################
(defun my-darwin-conf ()
(set-face-attribute 'default nil :family "Menlo")
;; To enable sRGB
(setq ns-use-srgb-colorspace t)
;; key bindings
(setq mac-option-modifier 'meta)
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
; (setq interprogram-cut-function 'paste-to-osx)
; (setq interprogram-paste-function 'copy-from-osx)
;; add brew path
(setq brew-bin-path "/usr/local/bin/")
(add-to-list 'exec-path brew-bin-path)
;; shell-command-to-string error
(setenv "PATH" (concat brew-bin-path ":" (getenv "PATH")))
;; add brew path to eshell's path
(defun my-darwin-brew-eshell-mode-hook ()
(setq eshell-path-env (concat brew-bin-path ":" eshell-path-env)))
(add-hook 'eshell-mode-hook #'my-darwin-brew-eshell-mode-hook)
)
;;;##############################################################
;;; jump to each conf functions
;;;##############################################################
(cond
((string-equal system-type "darwin") ; Mac OS X
(progn
(setq my-frame-height 50)
(setq my-frame-width 160)
(setq my-font-height 140)
(my-darwin-conf)))
((string-equal system-type "gnu/linux") ; linux
(progn
(setq my-frame-x 20)
(setq my-frame-y 20)
(setq my-frame-height 45)
(setq my-frame-width 150)
(setq my-font-height 85)
(my-linux-conf)))
)
;;;##############################################################
;;; window size
;;;##############################################################
; default window width and height
(defun my-custom-set-frame-size ()
(if (boundp 'my-frame-x)
(add-to-list 'default-frame-alist `(top . ,my-frame-x)))
(if (boundp 'my-frame-y)
(add-to-list 'default-frame-alist `(left . ,my-frame-y)))
(add-to-list 'default-frame-alist `(height . ,my-frame-height))
(add-to-list 'default-frame-alist `(width . ,my-frame-width)))
(my-custom-set-frame-size)
(add-hook 'before-make-frame-hook #'my-custom-set-frame-size)
;;;##############################################################
;;; font conf
;;;##############################################################
;; default font size (point * 10)
;;
;; WARNING! Depending on the default font,
;; if the size is not supported very well, the frame will be clipped
;; so that the beginning of the buffer may not be visible correctly.
(if (boundp 'my-font-height)
(set-face-attribute 'default nil :height my-font-height))
;;;##############################################################
;;; package managers
;;;##############################################################
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
;; Initialise the packages, avoiding a re-initialisation.
(unless (bound-and-true-p package--initialized)
(setq package-enable-at-startup nil)
(package-initialize))
;; Make sure `use-package' is available.
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package-ensure)
(setq use-package-always-ensure t)
;; Configure `use-package' prior to loading it.
(eval-and-compile
(setq use-package-always-defer nil)
(setq use-package-always-demand nil)
(setq use-package-expand-minimally nil)
(setq use-package-enable-imenu-support t)
;; The following is VERY IMPORTANT. Write hooks using their real name
;; instead of a shorter version: after-init ==> `after-init-hook'.
;;
;; This is to empower help commands with their contextual awareness,
;; such as `describe-symbol'.
(setq use-package-hook-name-suffix nil))
(eval-when-compile
(require 'use-package))
;;;##############################################################
;;; installs packages
;;;#############################################################
(defvar my-packages
'(flycheck py-autopep8 blacken magit))
(defun install-my-packages (package)
(unless (package-installed-p package)
(package-install package)))
(mapc #'install-my-packages my-packages)
;;;##############################################################
;;; load site-lisp
;;;#############################################################
(let ((default-directory "~/.emacs.d/site-lisp/"))
(normal-top-level-add-subdirs-to-load-path))
(add-to-list 'custom-theme-load-path
(file-name-as-directory "~/.emacs.d/site-lisp/midnight-dawn-theme"))
;;;##############################################################
;;; global setting
;;;##############################################################
(setq inhibit-startup-message t)
(setq column-number-mode t)
(display-time)
(defalias 'yes-or-no-p 'y-or-n-p) ; use y/n instead of yes/no
(show-paren-mode t) ; turn on paren match highlighting
(setq show-paren-style 'mixed)
;; show file size
(size-indication-mode)
;; auto save when lose input focus
(defun my-focus-out-hook ()
(save-some-buffers t))
(add-hook 'focus-out-hook #'my-focus-out-hook)
(auto-save-visited-mode) ; auto save files every 5 seconds
(require 'icomplete)
(icomplete-mode 1) ; incremental minibuffer completion
(setq icomplete-in-buffer t)
(auto-compression-mode t) ; auto handling with zipped files
;;;InteractivelyDoThings mode to auto complete in minibuffer
(require 'ido)
(require 'ido-completing-read+)
(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(setq ido-complete-space-or-hyphen-mode t)
(setq ido-confirm-unique-completion t)
(setq ido-ubiquitous-mode t)
(require 'amx)
(amx-mode 1)
(global-set-key (kbd "M-x") 'amx)
(global-set-key (kbd "M-X") 'amx-major-mode-commands)
;;; This is your old M-x.
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;; font-lock-mode
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
; enable color in console mode
(add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
;; Display line number on the left
(if (version<= "27.0" emacs-version)
(progn
(require 'display-line-numbers)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
(setq-default display-line-numbers-grow-only t)
(setq-default display-line-numbers-width 3)))
;; focus to the main buffer
(setq initial-buffer-choice t)
; for mule
(define-coding-system-alias 'utf8 'utf-8)
;; autocomplete paired brackets
(electric-pair-mode 1)
(autoload 'zap-up-to-char "misc"
"Kill up to, but not including ARGth occurrence of CHAR." t)
;; https://www.emacswiki.org/emacs/SavePlace
(save-place-mode 1)
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "M-z") 'zap-up-to-char)
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
(global-set-key (kbd "<home>") 'move-beginning-of-line)
(global-set-key (kbd "<end>") 'move-end-of-line)
; unset unused keys
(global-unset-key (kbd "S-SPC")) ; switch input method
(global-unset-key (kbd "C-x f")) ; don't set fill column
(global-unset-key (kbd "C-x C-n")) ; don't set-goal-column
(when window-system (global-unset-key (kbd "C-z"))) ; don't minimize
(global-unset-key (kbd "C-x C-z")) ; don't suspend
(global-unset-key (kbd "C-x z")) ; don't repeat
(global-unset-key [mode-line mouse-3]) ; don't enlarge mode-line
;;; clean up the mode line
(require 'minions)
(setq minions-mode-line-lighter "☰")
(minions-mode 1)
(setq minions-direct '(projectile-mode flycheck-mode))
;(require 'simple-modeline)
;(simple-modeline-mode)
(setq save-interprogram-paste-before-kill t
apropos-do-all t
mouse-yank-at-point t
require-final-newline t
load-prefer-newer t)
(if (version<= "27.0" emacs-version)
(progn
(require 'display-fill-column-indicator)
(setq-default fill-column 100)
(add-hook 'text-mode-hook #'display-fill-column-indicator-mode)
(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)))
(global-whitespace-mode 1)
(setq
whitespace-style
'(face ; viz via faces
trailing ; trailing blanks visualized
lines-tail ; lines beyond whitespace-line-column
space-before-tab
space-after-tab
newline ; lines with only blanks
indentation ; spaces used for indent when config wants tabs
empty ; empty lines at beginning or end
)
whitespace-line-column 100 ; whitespace-mode says the line is too long
)
;(display-battery-mode 1)
;(global-undo-tree-mode nil)
(use-package undo-tree
:config
(progn
(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-diff t)
(setq undo-tree-auto-save-history t)
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))
)
;;; show color codes in buffer
(use-package rainbow-mode
:config
(progn
(setq rainbow-x-colors nil)
(add-hook 'prog-mode-hook 'rainbow-mode)))
;;;##############################################################
;;; load theme
;;;#############################################################
(load-theme 'midnight-dawn t)
;;;##############################################################
;;; 프로그래밍 모드
;;;##############################################################
(require 'flycheck)
(defun my-flycheck-mode-hook ()
(flycheck-color-mode-line-mode))
; the default value was '(save idle-change new-line mode-enabled)
(setq flycheck-check-syntax-automatically '(save idle-change idle-buffer-switch))
(setq flycheck-idle-change-delay 3.0)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'my-flycheck-mode-hook))
;;;##############################################################
;;; 프로그래밍 모드 - lsp
;;;##############################################################
(setenv "GOPATH" (expand-file-name "~/local/go"))
(add-to-list 'exec-path (expand-file-name "~/local/go/bin"))
(setq lsp-prefer-capf t)
(setq lsp-signature-render-documentation nil) ; show only functions' signature
(setq lsp-signature-function #'eldoc-message) ; workaround signature two lines
(use-package lsp-mode
:commands (lsp lsp-deferred)
:hook
((python-mode-hook . lsp-deferred)
(go-mode-hook . lsp-deferred))
:config
(progn
(setq lsp-prefer-flymake nil)
(setq lsp-enable-snippet nil)
(setq lsp-auto-guess-root t) ; lsp with projectile
;(setq lsp-log-io nil)
(setq lsp-enable-folding nil)
(setq lsp-enable-symbol-highlighting nil)
(setq lsp-enable-links nil)
(setq lsp-client-packages '(lsp-pylsp lsp-go))
(push "[/\\\\][^/\\\\]*\\.\\(mod\\|sum\\)$" lsp-file-watch-ignored)
(setq lsp-restart 'auto-restart)
(lsp-register-custom-settings
'(("gopls.completeUnimported" t t)))
(lsp-register-client
(make-lsp-client :new-connection (lsp-tramp-connection "~/workplace/venv/bin/pylsp")
:major-modes '(python-mode)
:remote? t
:server-id 'remote-pylsp))
)
)
;;Optional - provides fancier overlays.
(use-package lsp-ui
:requires lsp-mode flycheck
:commands lsp-ui-mode)
(setq
lsp-modeline-code-actions-enable nil
lsp-ui-doc-position 'top
lsp-ui-doc-include-signature t
lsp-ui-doc-delay 0.5
lsp-ui-sideline-update-mode 'line
lsp-ui-sideline-delay 0.5
lsp-ui-sideline-code-actions-prefix "💡 "
lsp-ui-sideline-diagnostic-max-lines 3
lsp-ui-sideline-ignore-duplicate t)
;;;##############################################################
;;; 프로그래밍 모드 - company
;;;##############################################################
(use-package company
:config
(setq company-idle-delay 0.5)
(global-company-mode 1)
(global-set-key (kbd "C-<tab>") 'company-complete))
;;;##############################################################
;;; 프로그래밍 모드 - yasnippet
;;;##############################################################
(use-package yasnippet
:commands yas-minor-mode
:hook (go-mode-hook . yas-minor-mode))
;;;##############################################################
;;; 프로그래밍 모드 - python
;;;##############################################################
;;; example of .dir-locals.el
;;; (
;;; (python-mode . ((project-venv-path . "~/envs/some_env")))
;;; (python-mode . ((lsp-pylsp-server-command . ("/home/user/envs/some_env/bin/pylsp"))))
;;; (python-mode . ((pyvenv-activate . "~/envs/some_env")
;;; (subdirs . nil)))
;;; )
(defun my-python-mode-hook ()
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq python-indent-offset 4)
(setq python-indent-guess-indent-offset-verbose nil)
(setq show-trailing-whitespace t)
(setq my-default-venv-path (expand-file-name "~/.emacs.d/venv/"))
(pyvenv-activate my-default-venv-path)
;(setenv "WORKON_HOME" "~/local/anaconda3/envs") ; to use conda
(pyvenv-mode 1)
(pyvenv-tracking-mode 1)
(setq lsp-pylsp-plugins-flake8-max-line-length 100)
(setq lsp-pylsp-plugins-pydocstyle-ignore ["D100" "D101" "D102" "D103" "D107"]) ; ignore docstring warnings
)
(add-hook 'python-mode-hook #'my-python-mode-hook)
(require 'pyvenv)
(defun my-venv-with-window-buffer-change (newframe)
(if (eq major-mode 'python-mode)
(progn
(if (boundp 'project-venv-path)
(if (not (string-equal pyvenv-virtual-env project-venv-path))
(progn
(message "Activating %s." project-venv-path)
(hack-local-variables)
(pyvenv-activate project-venv-path)))
(if (not (string-equal pyvenv-virtual-env my-default-venv-path))
(progn
(message "Change to default venv.")
(hack-local-variables)
(pyvenv-activate my-default-venv-path)))))))
; after emacs 27.1
;(if (version<= "27.0" emacs-version)
; (add-hook 'window-buffer-change-functions #'my-venv-with-window-buffer-change))
; pip install python-lsp-server[all]
; pip install flake8 pylint mypy
(defun lsp-python-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t))
(add-hook 'python-mode-hook #'lsp-python-install-save-hooks)
;;;##############################################################
;;; 프로그래밍 모드 - jinja2
;;;##############################################################
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-engines-alist
'(("django" . "\\.html\\'")
("php" . "\\.php\\.")) )
(defun my-web-mode-hook ()
(setq indent-tabs-mode nil)
(setq default-tab-width 2)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
)
(add-hook 'web-mode-hook 'my-web-mode-hook)
;;;##############################################################
;;; 프로그래밍 모드 - golang
;;;##############################################################
(require 'go-mode)
(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode))
; go get github.com/golangci/golangci-lint/cmd/golangci-lint
; # binary will be $(go env GOPATH)/bin/golangci-lint
; curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.2
(defun my-golang-mode-hook ()
; Customize compile command to run go build
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go build -v && go test -v && go vet && golangci-lint run"))
(local-set-key (kbd "M-.") 'lsp-find-definition)
(local-set-key (kbd "M-*") 'pop-tag-mark)
(local-set-key (kbd "M-p") 'compile)
(local-set-key (kbd "M-P") 'recompile)
(local-set-key (kbd "M-]") 'next-error)
(local-set-key (kbd "M-[") 'previous-error)
(setq exec-path (append exec-path '("~/local/go/bin/")))
(setq tab-width 8)
(setq indent-tabs-mode t)
(setq show-trailing-whitespace t))
(add-hook 'go-mode-hook #'my-golang-mode-hook)
;go get -u golang.org/x/tools/gopls
;go get -u honnef.co/go/tools/cmd/staticcheck
;;Set up before-save hooks to format buffer and add/delete imports.
;;Make sure you don't have other gofmt/goimports hooks enabled.
(defun my-lsp-golang-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'my-lsp-golang-install-save-hooks)
;;;##############################################################
;;; slime
;;;##############################################################
;(require 'slime-autoloads)
;; Set your lisp system and, optionally, some contribs
;(setq inferior-lisp-program "/usr/local/bin/sbcl")
;(setq slime-contribs '(slime-fancy))
;;;##############################################################
;;; rainbow-delimiter
;;;##############################################################
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
;;;##############################################################
;; neotree
;;;##############################################################
(defun my-neotree-skip-other-window-hook (created)
(if (member 'window created)
(set-window-parameter neo-global--window 'no-other-window t)))
(use-package neotree
:init
(add-hook 'neo-after-create-hook #'my-neotree-skip-other-window-hook)
:config
(progn
(setq neo-smart-open t)
(setq neo-autorefresh t)
(setq neo-toggle-window-keep-p t)
(setq neo-theme 'ascii)
(setq neo-hide-cursor t)
(neotree-show)))
;;;##############################################################
;; search mode hook - like vim * search
;;;##############################################################
(defun my-isearch-word-at-point ()
(interactive)
(call-interactively 'isearch-forward-regexp))
(defun my-isearch-yank-word-hook ()
(when (equal this-command 'my-isearch-word-at-point)
(let ((string (concat "\\<"
(buffer-substring-no-properties
(progn (skip-syntax-backward "w_") (point))
(progn (skip-syntax-forward "w_") (point)))
"\\>")))
(if (and isearch-case-fold-search
(eq 'not-yanks search-upper-case))
(setq string (downcase string)))
(setq isearch-string string
isearch-message
(concat isearch-message
(mapconcat 'isearch-text-char-description
string ""))
isearch-yank-flag t)
(isearch-search-and-update))))
(add-hook 'isearch-mode-hook #'my-isearch-yank-word-hook)
(global-set-key (kbd "C-*") 'my-isearch-word-at-point)
;;;##############################################################
;;; dot emacs 설정
;;;##############################################################
(defun edit-dot-emacs ()
"Load the .emacs file into a buffer for editing."
(interactive)
(find-file "~/.emacs"))
(defun reload-dot-emacs ()
"Save .emacs, if it is in a buffer, and reload it."
(interactive)
(if (bufferp (get-file-buffer "~/.emacs"))
(save-buffer (get-buffer "~/.emacs")))
(load-file "~/.emacs"))
;;;##############################################################
;; highlight-symbol
;;;##############################################################
;(add-to-list 'load-path "~/.emacs.d/site-lisp/highlight-symbol/")
(require 'highlight-symbol)
(global-set-key (kbd "<M-up>") 'highlight-symbol-remove-all)
(global-set-key (kbd "<M-down>") 'highlight-symbol-at-point)
(setq highlight-symbol-on-navigation-p t)
(defun my-highlight-symbol-hook ()
(highlight-symbol-nav-mode t))
(when window-system
(add-hook 'prog-mode-hook #'my-highlight-symbol-hook))
;;;##############################################################
;; window-move
;;;##############################################################
;(if window-system
; (windmove-default-keybindings 'meta)
; (progn
; (global-set-key [(alt left)] 'windmove-left)
; (global-set-key [(alt up)] 'windmove-up)
; (global-set-key [(alt right)] 'windmove-right)
; (global-set-key [(alt down)] 'windmove-down)))
;;;##############################################################
;;; misc - vi style behaviours
;;;#############################################################
;;---
(defun kill-word-vi-style (arg)
"Delete continuous whitespaces or a word.
If the char under cursor is whitespace or tab, this would delete
the continuous whitespaces. If current cursor is at the end of
the line, this would delete the NEWLINE char and all leading
whitespaces of the next line. Otherwise it would kill current word."
(interactive "p")
(let ( (char (char-after (point))))
(if (or (char-equal char ?\x020)
(char-equal char ?\t))
(delete-horizontal-space)
(if (eolp)
(delete-indentation t)
(kill-word arg)))))
(global-set-key (kbd "C-d") 'kill-word-vi-style)
;;;##############################################################
;;; projectile
;;;##############################################################
(require 'projectile)
(setq projectile-mode-line "Projectile") ; to fix slow tramp mode
(setq projectile-enable-caching t
projectile-remember-window-configs t
projectile-indexing-method 'native
projectile-completion-system (quote ivy)
projectile-switch-project-action (quote projectile-dired)
venv-dirlookup-names '("venv" "venv3" "pyenv" ".venv")
)
(defun my-projectile-mode ()
(projectile-mode 1))
(add-hook 'prog-mode-hook #'my-projectile-mode)
;(setq projectile-globally-ignored-files '("TAGS" "GPATH" "GRTAGS" "GSYMS" "GTAGS"))
(eval-after-load 'projectile
(setq-default projectile-mode-line-prefix " Proj"))
;;;##############################################################
;;; flyspell
;;;#############################################################
(require 'flyspell)
(setq flyspell-issue-message-flag nil
ispell-dictionary "en_US"
ispell-program-name "/opt/homebrew/bin/aspell"
ispell-extra-args '("--sug-mode=ultra"))
(add-hook 'text-mode-hook #'flyspell-mode)
(add-hook 'prog-mode-hook #'flyspell-prog-mode)
;;;##############################################################
;;; misc
;;;#############################################################
(require 'tramp)
(setq tramp-default-method "ssh")
;(eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
;(setq tramp-debug-buffer t)
;(setq tramp-verbose 10)
(setq tramp-auto-save-directory "~/.emacs.d/tramp-autosave")
(defun tramp-set-auto-save ()
(auto-save-mode -1))
(setq enable-remote-dir-locals t)
(setq make-backup-files nil)
(setq create-lockfiles nil)
; tramp-lsp workaround
; https://github.com/emacs-lsp/lsp-mode/issues/2514
; (defun start-file-process-shell-command@around (start-file-process-shell-command name buffer &rest args)
; "Start a program in a subprocess. Return the process object for it.
;Similar to `start-process-shell-command', but calls `start-file-process'."
; ;; On remote hosts, the local `shell-file-name' might be useless.
; (let ((command (mapconcat 'identity args " ")))
; (funcall start-file-process-shell-command name buffer command)))
;
; (advice-add 'start-file-process-shell-command :around #'start-file-process-shell-command@around)
;; Put this in root directory of your project
;; Install pyls in the project environment
;; pip install python-lsp-server
;((python-mode . ((eval . (progn (require 'lsp-mode)
; (lsp-register-client
; (make-lsp-client :new-connection (lsp-tramp-connection "~/workplace/venv/bin/pylsp")
; :major-modes '(python-mode)
; :remote? t
; :server-id 'remote-pyls))))
; (eval . (setq lsp-clients-python-command '("~/.emacs.d/venv/bin/pylsp")))
; ))
;)
;(use-package tramp
; :ensure nil
; :config (progn
; (setq tramp-use-ssh-controlmaster-options nil
; remote-file-name-inhibit-locks t
; tramp-verbose 1
; vc-ignore-dir-regexp (format "%s\\|%s"
; vc-ignore-dir-regexp
; tramp-file-name-regexp))))
;eshell completion
(defun my-eshell-mode-hook ()
(setq pcomplete-cycle-completions nil))
(add-hook 'eshell-mode-hook #'my-eshell-mode-hook)
(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
'(dash rainbow-mode neotree web-mode blacken exec-path-from-shell minions simple-modeline fill-column-indicator magit py-autopep8 projectile pyvenv ido-completing-read+ amx highlight-symbol rainbow-delimiters yasnippet use-package company lsp-ui lsp-mode flycheck-color-mode-line go-mode popup 0xc w3m org jedi fuzzy flycheck f))
'(tramp-verbose 6))
(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.
)