summary refs log tree commit diff
path: root/emacs/custom/fcuny-prog.el
blob: a3eec01a4d54f27451e2592d15510cef1b89ef4f (plain) (blame)
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
(require 'fcuny-vars)

(use-package man
  :init
  (setq Man-notify-method 'aggressive))

(use-package auto-fill
  :hook (prog-mode . auto-fill-mode)
  :custom
  ;; this does not seem to work ..
  (comment-fill-column 80)
  (comment-auto-fill-only-comments t))

(use-package company
  :ensure t
  :diminish company-mode
  :custom
  (company-minimum-prefix-length 2)
  (company-tooltip-align-annotations t)
  (company-tooltip-limit 12)
  (company-idle-delay 1))

(use-package lispy
  :ensure t
  :config
  (dolist (hook '(emacs-lisp-mode-hook))
    (add-hook hook #'lispy-mode)))

;; we need to install the following tools:
;; go get golang.org/x/tools/gopls@latest
;; go get golang.org/x/lint/golint@latest
;; go get honnef.co/go/tools/cmd/staticcheck
(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  :diminish lsp-mode
  :hook ((go-mode . lsp-deferred)
         (nix-mode . lsp-deferred)
         (lsp-mode . (lambda() (let ((lsp-keymap-prefix "C-c l"))
                                 (lsp-enable-which-key-integration)))))
  :config
  (define-key lsp-mode-map (kbd "C-c l") lsp-command-map)
  (lsp-register-custom-settings
   '(("gopls.completeUnimported" t t)
     ("gopls.staticcheck" t t)))
  :bind
  (("C-c l i" . lsp-ui-imenu))
  :custom
  (lsp-session-file (expand-file-name "lsp-session-v1" fcuny/path-emacs-var))
  (lsp-enable-snippet nil)
  (lsp-signature-doc-lines 5)
  (lsp-modeline-diagnostic-scope :workspace)
  (lsp-completion-provider :capf)
  (lsp-completion-enable t)
  (lsp-enable-indentation t)
  (lsp-eldoc-render-all t)
  (lsp-prefer-flymake nil))

(use-package lsp-ui
  :ensure t
  :hook (lsp-mode . lsp-ui-mode)
  :commands lsp-ui-mode
  :custom
  (lsp-ui-doc-delay 0.4)
  (lsp-ui-doc-enable t)
  (lsp-ui-doc-position 'top)
  (lsp-ui-doc-include-signature t)
  (lsp-ui-peek-enable t)
  (lsp-ui-sideline-enable t)
  (lsp-ui-imenu-enable t)
  (lsp-ui-flycheck-enable t))

(use-package lsp-ivy
  :ensure t
  :commands lsp-ivy-workspace-symbol)

(use-package lsp-treemacs
  :ensure t
  :config
  (lsp-treemacs-sync-mode 1))

(use-package dap-mode
  :ensure t
  :after (lsp-mode)
  :bind ("C-c d" . dap-hydra)
  :init
  (use-package dap-go)
  :custom
  (dap-utils-extension-path (expand-file-name ".extension" fcuny/path-emacs-var))
  (dap-breakpoints-file (expand-file-name "dap-breakpoints" fcuny/path-emacs-var))
  (dap-ui-controls-mode nil)
  (dap-ui-buffer-configurations
   `((,dap-ui--locals-buffer       . ((side . right) (slot . 1) (window-width . 0.2)))
     (,dap-ui--expressions-buffer  . ((side . right) (slot . 2) (window-width . 0.2)))
     (,dap-ui--sessions-buffer     . ((side . right) (slot . 3) (window-width . 0.2)))
     (,dap-ui--breakpoints-buffer  . ((side . right) (slot . 4) (window-width . 0.2)))
     (,dap-ui--repl-buffer         . ((side . bottom) (slot . 1) (window-width . 0.4)))
     (,dap-ui--debug-window-buffer . ((side . bottom) (slot . 2) (window-height . 0.2)))))
  :config
  (dap-mode t)
  (dap-ui-mode t)
  (dap-tooltip-mode t)
  (tooltip-mode t))

;; I don't want to have the icons as an overlay in the UI, I prefer to
;; use the bindings or the mapping provided by hydra
(eval-after-load 'lsp-mode '(advice-add 'dap-ui--update-controls :override #'ignore))

(use-package sh-script
  :mode ("bashrc" . sh-mode)
  :hook (after-save . executable-make-buffer-file-executable-if-script-p)
  :config
  (setq-default sh-indentation 2
                sh-basic-offset 2))

(use-package python
  :mode (("\\.py$"     . python-mode))
  :commands python-mode
  :hook ((python-mode . eldoc-mode))
  :custom (python-indent-offset 2))

(use-package make-mode
  :config
  (add-hook 'makefile-mode-hook (lambda () (setq-local tab-width 2))))


(defun fcuny/setup-go-mode-compile ()
  (if (not (string-match "go" compile-command))
      (set (make-local-variable 'compile-command)
           "go build -v")))

(use-package go-mode
  :ensure t
  :hook ((before-save . lsp-format-buffer)
         (before-save . lsp-organize-imports)
         (go-mode . fcuny/setup-go-mode-compile))
  :config
  (when (memq window-system '(mac ns))
    (exec-path-from-shell-copy-env "GOPATH"))
  :custom
  (tab-width 4))

(use-package gotest
  :ensure t)

(use-package lisp-mode
  :bind
  (("C-c C-e" . eval-buffer)
   ("C-c C-r" . eval-region)))

(use-package puppet-mode
  :ensure t
  :bind (:map puppet-mode-map
              ("C-c |" . puppet-align-block)))

(use-package compile
  :ensure nil
  :custom
  (compilation-scroll-output t)
   ;; Skip over warnings and info messages in compilation
  (compilation-skip-threshold 2)
  ;; Don't freeze when process reads from stdin
  (compilation-disable-input t)
  ;; Show three lines of context around the current message
  (compilation-context-lines 3))

(use-package nix-mode
  :ensure t
  :mode "\\.nix\\'"
  :hook ((before-save . nix-format-before-save))
  :config)

(provide 'fcuny-prog)