Skip to content

Commit

Permalink
fix eager macro expansion error; add typescript-ts-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JJPandari committed Apr 19, 2024
1 parent 2372b74 commit 70f307d
Show file tree
Hide file tree
Showing 26 changed files with 149 additions and 32 deletions.
2 changes: 1 addition & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
(require 'init-org)
(require 'init-markdown)
(require 'init-csv)
(require 'init-web)
(require 'init-javascript)
(require 'init-web)
(require 'init-json)
(require 'init-coffeescript)
(require 'init-css)
Expand Down
6 changes: 4 additions & 2 deletions modes/init-evil.el
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
(setq evil-escape-excluded-states '(normal visual multiedit emacs motion)
evil-escape-excluded-major-modes '(neotree-mode treemacs-mode vterm-mode)
evil-escape-key-sequence "fd"
evil-escape-unordered-key-sequence t)
evil-escape-unordered-key-sequence nil)
;; (evil-define-key* '(insert replace visual operator) 'global "\C-g" #'evil-escape)
:demand t
:config
Expand Down Expand Up @@ -449,7 +449,9 @@

;; fix keys bound by motion state
"r" 'evil-replace
"d" 'evil-delete)
"d" 'evil-delete
"<C-i>" 'beginning-of-line-text
"C-o" 'move-end-of-line)

(general-define-key
:states 'motion
Expand Down
3 changes: 3 additions & 0 deletions modes/init-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

(global-hl-line-mode 1)

(setq pulse-delay 0.08
pulse-iterations 2)

(use-package highlight-parentheses
:demand t
:init
Expand Down
2 changes: 1 addition & 1 deletion modes/init-formatter.el
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; (push (expand-file-name "apheleia" jester-submodules-dir) load-path)
(use-package apheleia
:init
(jester/with-major-leader '(js2-mode-map web-mode-map typescript-mode-map)
(jester/with-major-leader '(js2-mode-map web-mode-map typescript-mode-map typescript-ts-mode-map)
"f" 'apheleia-format-buffer)
:commands (apheleia-format-buffer))

Expand Down
21 changes: 11 additions & 10 deletions modes/init-ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ If called interactively, let the user select start directory first."

(use-package ivy-hydra
:demand t
:after ivy
:after (hydra ivy)
:config
;; TODO eager macro expansion error
;; (defhydra+ hydra-ivy ()
;; ("a" nil)
;; ("<escape>" keyboard-escape-quit :exit t)
;; ("q" keyboard-escape-quit :exit t))
)
;; learned from doom: putting macro in eval avoids following error:
;; error: Eager macro-expansion failure: (void-variable hydra-ivy/params)
(eval '(defhydra+ hydra-ivy ()
("a" nil)
("<escape>" keyboard-escape-quit :exit t)
("q" keyboard-escape-quit :exit t))))


(use-package wgrep
Expand All @@ -172,7 +172,8 @@ If called interactively, let the user select start directory first."
:after ivy
:if window-system
:config
(setq ivy-posframe-hide-minibuffer t)
(setq ivy-posframe-hide-minibuffer t
ivy-posframe-width 9999)
(add-hook! 'load-theme-hook
(setq ivy-posframe-parameters
`((background-color . ,(face-attribute 'default :background))
Expand Down Expand Up @@ -239,8 +240,8 @@ If called interactively, let the user select start directory first."
(defmacro jester/make-fuzzy-search-dwim-command (search-cmd)
"Make a dwim fuzzy search command, using `search-cmd'."
`(defun ,(intern (format "jester/%s-dwim" search-cmd)) ()
,(format "If region is not active, just start %s. If region contain 1 char, grab the symbol as %s input, otherwise use the region content.
If %s started with any input, enable ivy-hydra automatically. (so I can h/j/k/l the list)"
,(format "If region is not active, just start `%s'. If region contain 1 char, grab the symbol as `%s' input, otherwise use the region content.
If `%s' started with any input, enable ivy-hydra automatically. (so I can h/j/k/l the list)"
search-cmd search-cmd search-cmd)
(interactive)
(if (region-active-p)
Expand Down
23 changes: 6 additions & 17 deletions modes/init-javascript.el
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,15 @@
(modify-syntax-entry ?_ "w" rjsx-mode-syntax-table))


(use-package typescript-mode
:custom (typescript-indent-level 2)
:init
(after-load 'flycheck
(flycheck-add-mode 'javascript-eslint 'typescript-mode))
;; lsp would set checker to lsp, set it back
;; lsp and eslint show different errors, using lsp for now...
;; `flycheck-add-next-checker'
;; (add-hook! :append 'typescript-mode-hook
;; (setq flycheck-checker 'javascript-eslint))
(use-package typescript-ts-mode
:mode "\\.ts\\'"
:config

// remove auto mode for tsx files because we want web-mode there
(setq auto-mode-alist (cl-remove "\\.tsx\\'" auto-mode-alist :test 'string-equal :key 'car))
(setq auto-mode-alist (cl-remove "\\.tsx?\\'" auto-mode-alist :test 'string-equal :key 'car))

;; (require 'ansi-color)
;; (defun colorize-compilation-buffer ()
;; (ansi-color-apply-on-region compilation-filter-start (point-max)))
;; (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
)
// web-mode is also removed, add it back
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook! 'typescript-ts-mode-hook (setq mode-name "TypeScript(ts)")))


(use-package eacl
Expand Down
4 changes: 3 additions & 1 deletion modes/init-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"b n" 'bookmark-set
"b j" 'bookmark-jump)

;; TODO "SPC '" to cycle evil markers in current buffer (hydra it)

;;----------------------------------------------------------------------------
;; xref
;;----------------------------------------------------------------------------
Expand All @@ -26,7 +28,7 @@

(general-define-key
:states '(normal motion)
:keymaps '(typescript-mode-map web-mode-map js2-mode-map)
:keymaps '(typescript-mode-map typescript-ts-mode-map web-mode-map js2-mode-map)
"g d" 'lsp-bridge-find-def
"g p" 'lsp-bridge-find-def-return
"g r" 'lsp-bridge-find-references
Expand Down
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/array-type
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Array type
# key: ar
# --
Array<$0>
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/async
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: async
# key: as
# --
async
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/await
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: await
# key: aw
# --
await
11 changes: 11 additions & 0 deletions snippets/typescript-ts-mode/cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: cl (command)
# key: cl
# type: command
# --
(let ((in-js-p
(save-excursion
(move-beginning-of-line 1)
(looking-at "^[ \t]*$"))))
(yas-expand-snippet
(if in-js-p "console.log($0);" "className=\"$0\"")))
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/debugger
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: debugger
# key: db
# --
debugger;
8 changes: 8 additions & 0 deletions snippets/typescript-ts-mode/fori
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor:
# name: fori
# key: fori
# --
for (let i=0 ; i<$1 ; i++) {
$0
}
8 changes: 8 additions & 0 deletions snippets/typescript-ts-mode/forin
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor:
# name: forin
# key: forin
# --
for(${1:const ${2:key}} in ${3:obj}) {
$0
}
8 changes: 8 additions & 0 deletions snippets/typescript-ts-mode/forof
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor:
# name: forof
# key: forof
# --
for (${1:const ${2:item}} of ${3:array}) {
$0
}
7 changes: 7 additions & 0 deletions snippets/typescript-ts-mode/function
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: function
# key: fn
# --
function $1($2): $3 {
$0
}
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/import
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: import
# key: imp
# --
import ${2:\{ $0 \}} from '$1';
7 changes: 7 additions & 0 deletions snippets/typescript-ts-mode/interface
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: interface
# key: int
# --
interface $1 {
$0
}
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: jq
# key: jq
# --
$('$0')
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/jqt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: jqt
# key: jqt
# --
$(this)
8 changes: 8 additions & 0 deletions snippets/typescript-ts-mode/lam
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor:
# name: lam
# key: lam
# --
${1:()} => {
$0
}
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/oa
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: oa
# key: oa
# --
Object.assign(${1:\{\}}, $0)
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/olm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: olm
# key: olm
# --
$1 => $0
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/string-interpolation
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: string interpolation
# key: si
# --
\${$0}
8 changes: 8 additions & 0 deletions snippets/typescript-ts-mode/try-catch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: try-catch
# key: tc
# --
try {
$0
} catch (e) {
}
5 changes: 5 additions & 0 deletions snippets/typescript-ts-mode/ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: ts
# key: ts
# --
\${$1}

0 comments on commit 70f307d

Please sign in to comment.