Skip to content

Instantly share code, notes, and snippets.

@ahushh
Last active November 26, 2019 12:04
Show Gist options
  • Save ahushh/cda4e9fe8a1be4e6a862 to your computer and use it in GitHub Desktop.
Save ahushh/cda4e9fe8a1be4e6a862 to your computer and use it in GitHub Desktop.
;; 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.
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")
;; ("marmalade" . "http://marmalade-repo.org/packages/")
))
(when (< emacs-major-version 27)
(package-initialize))
(global-flycheck-mode)
(setq create-lockfiles nil)
(show-paren-mode 1)
(column-number-mode 1)
(fset 'yes-or-no-p 'y-or-n-p)
(global-linum-mode 1)
(setq linum-format " %2d")
(global-hl-line-mode 1)
(delete-selection-mode t)
(use-package editorconfig
:ensure t
:init (editorconfig-mode 1))
(use-package which-key
:ensure t
:init (which-key-mode +1))
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)
(next-line)))
(global-set-key (kbd "C-c C-c") 'comment-or-uncomment-region-or-line)
;;(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-undo-tree-mode)
;; tabs
(setq-default indent-tabs-mode nil)
(setq tab-width 4)
(setq standard-indent 4)
;;
(projectile-mode +1)
;(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(setq projectile-project-search-path '("~/Projects/"))
(setq projectile-globally-ignored-directories
(append '("*auto-save-list/"
"node_modules"
".build"
".idea"
".vscode"
".env"
".git"
".hg"
".svn"
"cypress"
"Jenkinsfile"
"package-lock.json"
)
projectile-globally-ignored-directories))
;;(set-face-attribute 'default nil
;; :family "Inconsolata" :height 145 :weight 'normal)
(when (window-system)
(set-frame-font "Fira Code"))
(let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
(35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
(36 . ".\\(?:>\\)")
(37 . ".\\(?:\\(?:%%\\)\\|%\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
(45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
(46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=-]\\)")
(47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
(48 . ".\\(?:x[a-zA-Z]\\)")
(58 . ".\\(?:::\\|[:=]\\)")
(59 . ".\\(?:;;\\|;\\)")
(60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)")
(61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
(62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
(63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)")
(91 . ".\\(?:]\\)")
(92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
(94 . ".\\(?:=\\)")
(119 . ".\\(?:ww\\)")
(123 . ".\\(?:-\\)")
(124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
(126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)")
)
))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(tool-bar-mode -1)
(scroll-bar-mode -1)
(use-package rjsx-mode)
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
;; ivy
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(counsel-mode 1)
(global-set-key "\C-s" 'swiper)
(setq projectile-completion-system 'ivy)
(use-package counsel-projectile
:ensure t
:init (counsel-projectile-mode))
;; neotree sidebar
(global-set-key [f8] 'neotree-toggle)
(setq neo-smart-open t)
(setq projectile-switch-project-action 'neotree-projectile-action)
;; git
(global-set-key (kbd "C-x g") 'magit-status)
(setq tide-tsserver-executable "node_modules/typescript/bin/tsserver")
(setq exec-path (append exec-path '("/usr/local/bin")))
(add-hook 'after-init-hook 'global-company-mode)
;;(global-set-key "\t" 'company-complete-common)
(company-quickhelp-mode)
(centaur-tabs-mode t)
(global-set-key (kbd "C-x <up>") 'centaur-tabs-backward)
(global-set-key (kbd "C-x <down>") 'centaur-tabs-forward)
(setq centaur-tabs-style "alternate")
(setq centaur-tabs-set-icons t)
(setq centaur-tabs-set-modified-marker t)
(setq centaur-tabs-modified-marker "<*>")
;(centaur-tabs-counsel-switch-group)
(centaur-tabs-group-by-projectile-project)
;(centaur-tabs-group-buffer-groups)
;;;;;;;;;; typescript and js
(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)
;;;;;;; tsx
(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))))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)
;;;;;; tsx
(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)
;;(flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)
;; custom
(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.
'(custom-enabled-themes (quote (sanityinc-solarized-dark)))
'(custom-safe-themes
(quote
("4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" default)))
'(package-selected-packages
(quote
(counsel-package rjsx-mode ac-etags ag centaur-tabs company-quickhelp undo-tree multiple-cursors magit projectile web-mode company neotree counsel ivy color-theme-sanityinc-solarized tide use-package))))
(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.
)
(put 'downcase-region 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment